Gives the angle between a reference vector and this. The result is between [PI,-PI). In school coordinates, the angle is counted counter clockwise from reference to the vector. In game coordinates, the angle is counted clockwise from reference to the vector.
Optional ref: Vect[optional] reference vector. default: (1,0).
Not exactly the cross product, because seems not to be defined for 2d vectors.
"Gives the Z-component of 3d cross product, if the two given vectors where extended to 3d vectors." or "Determinant of a 2x2 matrix build by the two vectors."
Usefull to find the orientation of the two vectors.
Euclidean distance of two vectors.
Quadratic distance of two vectors.
Dot product of this and the given vector.
y isLeftOf
Manhatten/city block/Taxicab distance
Rotates the vector by the given angle. If you take the vector as a point, the default pivot is {x:0,y:0}
in radians
Optional pivot: Vect[optional] default is {x:0,y:0}
the rotated vector
Substracts a vector.
Product of two vectors needed for the Gauss's area formula.
Describes the doubled area of the shape that is enclosed by (this.x,0), (v.x,0), (v.x,v.y),(this.x,this.y). So its an area based on the x-axis. If you reflect it on the x-axis, you get the trapeze of which the area value is calculated.
Needed for orientation and area of a polygon.
Polygon.prototype.getArea() //TODO
const u = new Vect(3,5);
const v = new Vect(5,7);
const polygon = new Polygon(u, u.clone().mirrorOnX(), v.clone().mirrorOnY(), v);
const result = u.trapeze(v);
print(result);
draw(u,v,polygon);
Static fromGenerated using TypeDoc
Adds a vector.