1.0.1 • Published 4 months ago

joseffie-vector2 v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

UnityEngine.Vector2 written in JavaScript

Static properties

NameDescription
downShorthand for writing Vector2(0, -1).
leftShorthand for writing Vector2(-1, 0).
oneShorthand for writing Vector2(1, 1).
rightShorthand for writing Vector2(1, 0).
upShorthand for writing Vector2(0, 1).
zeroShorthand for writing Vector2(0, 0).

Properties

NameDescription
magnitudeThe length of this vector (read only).
normalizedThis vector with a magnitude of 1 (read only).
magnitudeSquaredThe squared length of this vector (read only).
xThe X component of the vector.
yThe Y component of the vector.

Object methods

NameDescription
addAdds another vector to the vector.
addScalarAdds scalar to the vector.
ceilCeils the vector's components to the nearest integer greater than or equal to the value.
cloneCreates a new instance of a vector and assigns it the x and y of the current vector.
divideDivides the vector by another vector.
divideScalarDivides the vector by scalar.
equalsReturns true if the given vector is exactly equal to this vector.
floorFloors the vector's components to the nearest integer less than or equal to the value.
multiplyMultiplies the vector by another vector.
multiplyScalarMultiplies the vector by scalar.
negateNegates the vector's components.
normalizeMakes the vector have a magnitude of 1.
roundRounds the vector's components to the nearest integer.
setSets the vector's components.
setLengthMakes the vector have a given magnitude.
setScalarSets the vector's components to the same scalar value.
subtractSubtracts another vector from the vector.
subtractScalarSubtracts scalar from the vector.
toStringReturns a string with this vector's components.

Static methods

NameDescription
addVectorsReturns an addition of two vectors.
angleGets the unsigned angle in degrees between two vectors.
distanceReturns the distance between two vectors.
distanceSquaredReturns the square distance between two vectors.
dotComputes the dot product of two vectors.
lerpLinearly interpolates between two vectors by interpolant clamped to the range 0; 1.
lerpUnclampedLinearly interpolates between two vectors without clamping the interpolant.
maxReturns a vector that is made from the largest components of two vectors.
minReturns a vector that is made from the smallest components of two vectors.
moveTowardsMoves a current vector towards target vector.
perpendicularReturns the 2D vector perpendicular to this 2D vector. The result is rotated 90-degrees in a counter-clockwise direction.
reflectReflects a vector off the vector defined by a normal.
scaleMultiplies two vectors component-wise.
subtractVectorsReturns a subtraction of two vectors.
1.0.1

4 months ago

1.0.0

4 months ago