Class Vector2
Hierarchy
- Vector2
Index
Constructors
Properties
Methods
- add
- add
InPlace - add
ToRef - add
Vector3 - as
Array - clone
- copy
From - copy
From Floats - divide
- divide
InPlace - divide
ToRef - equals
- equals
With Epsilon - floor
- fract
- from
Array - get
Class Name - get
Hash Code - length
- length
Squared - multiply
- multiply
ByFloats - multiply
InPlace - multiply
ToRef - negate
- negate
InPlace - negate
ToRef - normalize
- scale
- scale
And Add ToRef - scale
InPlace - scale
ToRef - set
- subtract
- subtract
InPlace - subtract
ToRef - to
Array - to
String - Catmull
Rom - Center
- Center
ToRef - Clamp
- Distance
- Distance
OfPoint From Segment - Distance
Squared - Dot
- From
Array - From
Array ToRef - Hermite
- Lerp
- Maximize
- Minimize
- Normalize
- One
- Point
InTriangle - Transform
- Transform
ToRef - Zero
Constructors
constructor
-
Creates a new Vector2 from the given x and y coordinates
Parameters
-
Optional x: number
defines the first coordinate
-
Optional y: number
defines the second coordinate
Returns Vector2
-
Properties
xSearch playground for x
defines the first coordinate
ySearch playground for y
defines the second coordinate
Methods
addSearch playground for add
-
Add another vector with the current one
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
a new Vector2 set with the addition of the current Vector2 and the given one coordinates
-
add InPlaceSearch playground for addInPlace
-
Set the Vector2 coordinates by adding the given Vector2 coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
the current updated Vector2
-
add ToRefSearch playground for addToRef
-
Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
-
result: Vector2
defines the target vector
Returns Vector2
the unmodified current Vector2
-
add Vector3Search playground for addVector3
as ArraySearch playground for asArray
-
Copy the current vector to an array
Returns number[]
a new array with 2 elements: the Vector2 coordinates.
cloneSearch playground for clone
-
Gets a new Vector2 copied from the Vector2
Returns Vector2
a new Vector2
copy FromSearch playground for copyFrom
-
Sets the Vector2 coordinates with the given Vector2 coordinates
Parameters
-
source: DeepImmutable<Vector2>
defines the source Vector2
Returns Vector2
the current updated Vector2
-
copy From FloatsSearch playground for copyFromFloats
-
Sets the Vector2 coordinates with the given floats
Parameters
-
x: number
defines the first coordinate
-
y: number
defines the second coordinate
Returns Vector2
the current updated Vector2
-
divideSearch playground for divide
divide InPlaceSearch playground for divideInPlace
-
Divides the current Vector2 coordinates by the given ones
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
the current updated Vector2
-
divide ToRefSearch playground for divideToRef
-
Sets the "result" coordinates with the Vector2 divided by the given one coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
-
result: Vector2
defines the target vector
Returns Vector2
the unmodified current Vector2
-
equalsSearch playground for equals
-
Gets a boolean if two vectors are equals
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns boolean
true if the given vector coordinates strictly equal the current Vector2 ones
-
equals With EpsilonSearch playground for equalsWithEpsilon
-
Gets a boolean if two vectors are equals (using an epsilon value)
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
-
Optional epsilon: number
defines the minimal distance to consider equality
Returns boolean
true if the given vector coordinates are close to the current ones by a distance of epsilon.
-
floorSearch playground for floor
-
Gets a new Vector2 from current Vector2 floored values
Returns Vector2
a new Vector2
fractSearch playground for fract
-
Gets a new Vector2 from current Vector2 floored values
Returns Vector2
a new Vector2
from ArraySearch playground for fromArray
-
Update the current vector from an array
Parameters
-
array: FloatArray
defines the destination array
-
Optional index: number
defines the offset in the destination array
Returns Vector2
the current Vector3
-
get Class NameSearch playground for getClassName
-
Gets class name
Returns string
the string "Vector2"
get Hash CodeSearch playground for getHashCode
-
Gets current vector hash code
Returns number
the Vector2 hash code as a number
lengthSearch playground for length
-
Gets the length of the vector
Returns number
the vector length (float)
length SquaredSearch playground for lengthSquared
-
Gets the vector squared length
Returns number
the vector squared length (float)
multiplySearch playground for multiply
-
Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
a new Vector2
-
multiply ByFloatsSearch playground for multiplyByFloats
-
Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
Parameters
-
x: number
defines the first coordinate
-
y: number
defines the second coordinate
Returns Vector2
a new Vector2
-
multiply InPlaceSearch playground for multiplyInPlace
-
Multiplies in place the current Vector2 coordinates by the given ones
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
the current updated Vector2
-
multiply ToRefSearch playground for multiplyToRef
-
Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
-
result: Vector2
defines the target vector
Returns Vector2
the unmodified current Vector2
-
negateSearch playground for negate
-
Gets a new Vector2 with current Vector2 negated coordinates
Returns Vector2
a new Vector2
negate InPlaceSearch playground for negateInPlace
-
Negate this vector in place
Returns Vector2
this
negate ToRefSearch playground for negateToRef
normalizeSearch playground for normalize
-
Normalize the vector
Returns Vector2
the current updated Vector2
scaleSearch playground for scale
-
Returns a new Vector2 scaled by "scale" from the current Vector2
Parameters
-
scale: number
defines the scaling factor
Returns Vector2
a new Vector2
-
scale And Add ToRefSearch playground for scaleAndAddToRef
scale InPlaceSearch playground for scaleInPlace
-
Multiply the Vector2 coordinates by scale
Parameters
-
scale: number
defines the scaling factor
Returns Vector2
the current updated Vector2
-
scale ToRefSearch playground for scaleToRef
setSearch playground for set
-
Sets the Vector2 coordinates with the given floats
Parameters
-
x: number
defines the first coordinate
-
y: number
defines the second coordinate
Returns Vector2
the current updated Vector2
-
subtractSearch playground for subtract
subtract InPlaceSearch playground for subtractInPlace
-
Sets the current Vector2 coordinates by subtracting from it the given one coordinates
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
Returns Vector2
the current updated Vector2
-
subtract ToRefSearch playground for subtractToRef
-
Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
Parameters
-
otherVector: DeepImmutable<Vector2>
defines the other vector
-
result: Vector2
defines the target vector
Returns Vector2
the unmodified current Vector2
-
to ArraySearch playground for toArray
-
Sets the Vector2 coordinates in the given array or Float32Array from the given index.
Parameters
-
array: FloatArray
defines the source array
-
Optional index: number
defines the offset in source array
Returns Vector2
the current Vector2
-
to StringSearch playground for toString
-
Gets a string with the Vector2 coordinates
Returns string
a string with the Vector2 coordinates
Static Catmull RomSearch playground for CatmullRom
-
Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
Parameters
-
value1: DeepImmutable<Vector2>
defines 1st point of control
-
value2: DeepImmutable<Vector2>
defines 2nd point of control
-
value3: DeepImmutable<Vector2>
defines 3rd point of control
-
value4: DeepImmutable<Vector2>
defines 4th point of control
-
amount: number
defines the interpolation factor
Returns Vector2
a new Vector2
-
Static CenterSearch playground for Center
-
Gets a new Vector2 located at the center of the vectors "value1" and "value2"
Parameters
-
value1: DeepImmutable<Vector2>
defines first vector
-
value2: DeepImmutable<Vector2>
defines second vector
Returns Vector2
a new Vector2
-
Static Center ToRefSearch playground for CenterToRef
-
Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
Parameters
-
value1: DeepImmutable<Vector2>
defines first vector
-
value2: DeepImmutable<Vector2>
defines second vector
-
ref: DeepImmutable<Vector2>
defines third vector
Returns Vector2
ref
-
Static ClampSearch playground for Clamp
-
Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
Parameters
-
value: DeepImmutable<Vector2>
defines the value to clamp
-
min: DeepImmutable<Vector2>
defines the lower limit
-
max: DeepImmutable<Vector2>
defines the upper limit
Returns Vector2
a new Vector2
-
Static DistanceSearch playground for Distance
-
Gets the distance between the vectors "value1" and "value2"
Parameters
-
value1: DeepImmutable<Vector2>
defines first vector
-
value2: DeepImmutable<Vector2>
defines second vector
Returns number
the distance between vectors
-
Static Distance OfPoint From SegmentSearch playground for DistanceOfPointFromSegment
-
Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
Parameters
-
p: DeepImmutable<Vector2>
defines the middle point
-
segA: DeepImmutable<Vector2>
defines one point of the segment
-
segB: DeepImmutable<Vector2>
defines the other point of the segment
Returns number
the shortest distance
-
Static Distance SquaredSearch playground for DistanceSquared
-
Returns the squared distance between the vectors "value1" and "value2"
Parameters
-
value1: DeepImmutable<Vector2>
defines first vector
-
value2: DeepImmutable<Vector2>
defines second vector
Returns number
the squared distance between vectors
-
Static DotSearch playground for Dot
-
Gets the dot product of the vector "left" and the vector "right"
Parameters
-
left: DeepImmutable<Vector2>
defines first vector
-
right: DeepImmutable<Vector2>
defines second vector
Returns number
the dot product (float)
-
Static From ArraySearch playground for FromArray
-
Gets a new Vector2 set from the given index element of the given array
Parameters
-
array: DeepImmutable<ArrayLike<number>>
defines the data source
-
Optional offset: number
defines the offset in the data source
Returns Vector2
a new Vector2
-
Static From Array ToRefSearch playground for FromArrayToRef
-
Sets "result" from the given index element of the given array
Parameters
-
array: DeepImmutable<ArrayLike<number>>
defines the data source
-
offset: number
defines the offset in the data source
-
result: Vector2
defines the target vector
Returns void
-
Static HermiteSearch playground for Hermite
-
Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
Parameters
-
value1: DeepImmutable<Vector2>
defines the 1st control point
-
tangent1: DeepImmutable<Vector2>
defines the outgoing tangent
-
value2: DeepImmutable<Vector2>
defines the 2nd control point
-
tangent2: DeepImmutable<Vector2>
defines the incoming tangent
-
amount: number
defines the interpolation factor
Returns Vector2
a new Vector2
-
Static LerpSearch playground for Lerp
-
Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
Parameters
-
start: DeepImmutable<Vector2>
defines the start vector
-
end: DeepImmutable<Vector2>
defines the end vector
-
amount: number
defines the interpolation factor
Returns Vector2
a new Vector2
-
Static MaximizeSearch playground for Maximize
-
Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
Parameters
-
left: DeepImmutable<Vector2>
defines 1st vector
-
right: DeepImmutable<Vector2>
defines 2nd vector
Returns Vector2
a new Vector2
-
Static MinimizeSearch playground for Minimize
-
Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
Parameters
-
left: DeepImmutable<Vector2>
defines 1st vector
-
right: DeepImmutable<Vector2>
defines 2nd vector
Returns Vector2
a new Vector2
-
Static NormalizeSearch playground for Normalize
-
Returns a new Vector2 equal to the normalized given vector
Parameters
-
vector: DeepImmutable<Vector2>
defines the vector to normalize
Returns Vector2
a new Vector2
-
Static OneSearch playground for One
-
Gets a new Vector2(1, 1)
Returns Vector2
a new Vector2
Static Point InTriangleSearch playground for PointInTriangle
-
Determines if a given vector is included in a triangle
Parameters
-
p: DeepImmutable<Vector2>
defines the vector to test
-
p0: DeepImmutable<Vector2>
defines 1st triangle point
-
p1: DeepImmutable<Vector2>
defines 2nd triangle point
-
p2: DeepImmutable<Vector2>
defines 3rd triangle point
Returns boolean
true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
-
Static TransformSearch playground for Transform
-
Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
Parameters
-
vector: DeepImmutable<Vector2>
defines the vector to transform
-
transformation: DeepImmutable<Matrix>
defines the matrix to apply
Returns Vector2
a new Vector2
-
Static Transform ToRefSearch playground for TransformToRef
-
Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
Parameters
-
vector: DeepImmutable<Vector2>
defines the vector to transform
-
transformation: DeepImmutable<Matrix>
defines the matrix to apply
-
result: Vector2
defines the target vector
Returns void
-
Static ZeroSearch playground for Zero
-
Gets a new Vector2(0, 0)
Returns Vector2
a new Vector2
Class representing a vector containing 2 coordinates