https://github.com/niuee/point2point
A simple vector calculation helper functions collection.
https://github.com/niuee/point2point
vector2d
Last synced: 2 months ago
JSON representation
A simple vector calculation helper functions collection.
- Host: GitHub
- URL: https://github.com/niuee/point2point
- Owner: niuee
- License: mit
- Created: 2023-04-30T02:39:27.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T09:30:24.000Z (about 2 years ago)
- Last Synced: 2024-08-08T22:56:00.091Z (almost 2 years ago)
- Topics: vector2d
- Language: TypeScript
- Homepage:
- Size: 217 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# point2point
> This is a work in progress do not use it in any kind of production.
This is a minimal 2D vector calculation library that I wrote for my horse race track maker and parser as part of my horse racing game side project. Detail Documenation will follow in the near future.
The Overall wrapping class is ```PointCal```.
To install and try this out
```bash
npm install point2point
```
import the ```PointCal``` class
```javascript
import { PointCal } from "point2point";
```
The calculations that this library is capable of is listed below.
- Vector Addition
```javascript
PointCal.addVector({x: 0, y: 1}, {x: 1, y: 2})
// this would return a {x: number, y: number} object
// which in this case would be {x: 1, y: 3}
```
- Vector Subtraction
```javascript
PointCal.subVector({x: 0, y: 1}, {x: 1, y: 2})
// this would return a {x: number, y: number} object
// which in this case would be {x: -1, y: -1}
```
- Multiply A Vector With a Scalar Value
- Unit Vector of a Vector
- Unit Vector from Point A to Point B
- Magnitude of a Vector
- Distance between 2 Points
- Rotate a Vector $\theta$ radians (CCW is the positive direction)
- Dot Product
- Cross Product
- Angle from Vector A to Vector B