Creates a new ObservableVector3d instance.
The x-coordinate of the vector. Default is 0.
The y-coordinate of the vector. Default is 0.
Optional
callback: (() => void)The callback function to be called when the point changes. Default is undefined.
Gets the x-coordinate of the point.
Sets the x-coordinate of the point.
The new x-coordinate value.
Gets the y-coordinate of the point.
Sets the y-coordinate of the point.
The new y-coordinate value.
Update this vector values to absolute values
Reference to this object for method chaining
Add the passed vector to this vector
other vector
Reference to this object for method chaining
return the angle between this vector and the passed one
other vector
angle in radians
return a clone copy of this vector
Optional
cb: (() => void)callback function to override the clone values
new Vector2d
Copy the x,y values of the passed vector to this one
other vector
Reference to this object for method chaining
return the cross product of this vector and the passed one
other vector
The cross product.
Calculates the Euclidean distance between this vector and another vector.
The vector to which the distance is calculated.
The Euclidean distance between this vector and the given vector.
Divide this vector values by the passed value
the value to divide the vector by
Reference to this object for method chaining
return the dot product of this vector and the passed one
other vector
The dot product.
Checks if this vector is equal to another vector or a pair of coordinates.
Rest
...args: [number, number] | [Vector2d] | [ObservableVector2d]Either two numbers representing x and y coordinates or a single Vector2d object.
True if the coordinates are equal, false otherwise.
Linearly interpolate between this vector and the given one.
other vector
distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
Reference to this object for method chaining
Update this vector with the maximum value between this and the passed vector
other vector
Reference to this object for method chaining
Update this vector with the minimum value between this and the passed vector
other vector
Reference to this object for method chaining
interpolate the position of this vector towards the given one by the given maximum step.
vector to rotate towards
the maximum step per iteration (Negative values will push the vector away from the target)
Reference to this object for method chaining
normalize this vector (scale the vector so that its magnitude is 1)
Reference to this object for method chaining
change this vector to be perpendicular to what it was before.
(Effectively rotates it 90 degrees in a clockwise direction)
Reference to this object for method chaining
project this vector on to another vector.
The vector to project onto.
Reference to this object for method chaining
Project this vector onto a vector of unit length.
This is slightly more efficient than project
when dealing with unit vectors.
The unit vector to project onto.
Reference to this object for method chaining
Rotate this vector (counter-clockwise) by the specified angle (in radians).
The angle to rotate (in radians)
Optional
v: Vector2d | ObservableVector2dan optional point to rotate around
Reference to this object for method chaining
Multiply this vector values by the given scalar
x scale value
Optional
y: number = xy scale value, if not passed, it uses the x value
Reference to this object for method chaining
Multiply this vector values by the passed vector
other vector
Reference to this object for method chaining
Sets the x and y coordinates of the point.
The new x-coordinate value.
The new y-coordinate value.
Reference to this object for method chaining.
Sets the x and y coordinates of the point without triggering the callback.
The new x-coordinate value.
The new y-coordinate value.
Reference to this object for method chaining.
set the Vector x and y properties using the passed vector
other vector
Reference to this object for method chaining
set the Vector x and y properties to 0
Reference to this object for method chaining
Substract the passed vector to this vector
other vector
Reference to this object for method chaining
Convert this vector into 2d coordinate space
Reference to this object for method chaining
Convert this vector into isometric coordinate space
Reference to this object for method chaining
Represents a point in a 3D coordinate vector that can be observed for changes.