new AxVector2(v1, v2non-null)
Creates a vector object and initializes its components
Sets the components of the vector to the given values. Supports multiple input formats
Valid input formats are
() - Initializes all components to zero
(Number) - Sets all components to the value of the given number
(Number, Number) - Sets the x and components to the values of the given numbers in the respective order
(AxVector2) - Copies the components from the given vector
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Number | AxVector2 | For (number) input - the value to set to all components. For (x, y) input - the value for the X component of the vector. For (AxVector2) input - the vector to copy from. |
v2 |
Number | For (x, y) input - the value for the Y component. |
- Source:
Methods
Add(v) → {AxVector2}
Returns a vetor which is the sum of the original vector and the given one
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector, which is to be added to the original one |
- Source:
Returns:
The sum of the original vector and the given one
- Type
- AxVector2
Cross() → {AxVector2}
Returns the cross product of the original vector and the given one
- Source:
Returns:
The cross product of the original vector and the given one
- Type
- AxVector2
DistanceTo(v) → {Number}
Returns the distance between the point represented by the vector and a point represented by the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | A vector representing the point to which distance will be calculated |
- Source:
Returns:
The distance to the given point
- Type
- Number
Dot(v) → {Number}
Returns the dot product of the original vector and the given one
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector to calculate dot product against |
- Source:
Returns:
The dot product of the original vector and the given one
- Type
- Number
Equals(vector) → {Boolean}
Compares the vector with another one and returns true if both are identical
Parameters:
Name | Type | Description |
---|---|---|
vector |
AxVector2 | The vector to compare with |
- Source:
Returns:
True if identical to the given vector
- Type
- Boolean
GetLength() → {Number}
Calculates the length of the vector
- Source:
Returns:
Returns the length of the vector
- Type
- Number
Invert() → {AxVector2}
Returns the vector inverted
- Source:
Returns:
An inverted version of the original vector
- Type
- AxVector2
Lerp(v, factor) → {Number}
Returns a linearly vector interpolated between (or extrapolated outside of) the original and the given one
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector towards which to interpolate (or extrapolate) |
factor |
Number | The interpolation (or extrapolation) value. Values between 0 and 1 result in interpolation, while values outside of this range result in extrapolation. |
- Source:
Returns:
A linearly interpolated (or extrapolated) vector
- Type
- Number
Max(v) → {AxVector2}
Returns a vector with each of its components being the greater between their original value and the value of the corresponding component of the given vector.
In effect, the result is a component-wise maximum vector
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector, whose components to compare against |
- Source:
Returns:
A component-wise maximum vector
- Type
- AxVector2
Min(v) → {AxVector2}
Returns a vector with each of its components being the lesser between their original value and the value of the corresponding component of the given vector.
In effect, the result is a component-wise minimum vector
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector, whose components to compare against |
- Source:
Returns:
A component-wise minimum vector
- Type
- AxVector2
Normalize() → {AxVector2}
Returns the vector normalized
- Source:
Returns:
A normalized version of the original vector
- Type
- AxVector2
OfLength(length) → {AxVector2}
Return a vector with the same orientation, but of the given length
Parameters:
Name | Type | Description |
---|---|---|
length |
Number | Length of the returned vector |
- Source:
Returns:
A vector with the same orientation as the original, but of the given length
- Type
- AxVector2
Scale(arg) → {AxVector2}
Returns the vector with each of its components multiplied by the components of the given vector
Parameters:
Name | Type | Description |
---|---|---|
arg |
AxVector2 | Number | The AxVector2 vector for component-wise scaling or a scalar number by which to multiply the components of the original vector |
- Source:
Returns:
The component-wise scaled vector
- Type
- AxVector2
Set(v1, v2non-null)
Sets the components of the vector to the given values. Supports multiple input formats
Valid input formats are
(Number) - Sets all components to the value of the given number
(Number, Number) - Sets the x and components to the values of the given numbers in the respective order
(AxVector2) - Copies the components from the given vector
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Number | AxVector2 | For (number) input - the value to set to all components. For (x, y) input - the value for the X component of the vector. For (AxVector2) input - the vector to copy from. |
v2 |
Number | For (x, y) input - the value for the Y component. |
- Source:
Set_1(value)
Sets the components of the vectors to the given value
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | The value to set to both component of the vector |
- Source:
Set_2(x, y)
Sets the components of the vectors to the given values
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | The value for the X component of the vector |
y |
Number | The value for the Y component of the vector |
- Source:
Set_3(source)
Copies the source vector
Parameters:
Name | Type | Description |
---|---|---|
source |
AxVector2 | A vector to copy from |
- Source:
Subtract(v) → {AxVector2}
Returns a vetor which is the difference between the original vector and the given one
Parameters:
Name | Type | Description |
---|---|---|
v |
AxVector2 | The vector, which is to be subtracted from the original one |
- Source:
Returns:
The difference between the original vector and the given one
- Type
- AxVector2
Transform(transformation) → {AxVector2}
Returns a vector which is the original one, transformed by the given transformation matrix
Parameters:
Name | Type | Description |
---|---|---|
transformation |
AxMatrix | The transformation matrix to apply |
- Source:
Returns:
The transformed vector
- Type
- AxVector2
(static) Add(result, v1, v2)
Adds two vectors
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by adding the two vectors |
v1 |
AxVector2 | First vector |
v2 |
AxVector2 | Second vector |
- Source:
(static) Copy(result, source)
Copies the source vector into the result
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The vector to copy to |
source |
AxVector2 | The vector to copy from |
- Source:
(static) Cross(result, v1)
Calculates the cross product (a.k.a. vector product) of a vector
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector3 | The resulting vector produced by adding the two vectors |
v1 |
AxVector3 | Vector to calculate cross product for |
- Source:
(static) Distance(v1, v2) → {Number}
Calculates the distance between two points in 3D space
Parameters:
Name | Type | Description |
---|---|---|
v1 |
AxVector2 | First point |
v2 |
AxVector2 | Second point |
- Source:
Returns:
The distance between the two points
- Type
- Number
(static) Dot(v1, v2) → {Number}
Calculates the dot product (a.k.a. scalar product) of two vectors.
Parameters:
Name | Type | Description |
---|---|---|
v1 |
AxVector2 | First vector |
v2 |
AxVector2 | Second vector |
- Source:
Returns:
The dot product of the two vectors
- Type
- Number
(static) Invert(result, v)
Inverts a vector
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting inverted vector |
v |
AxVector2 | The vector to be inverted |
- Source:
(static) Lerp(result, v1, v2, factor)
Performs linear interpolation or extrapolation between two vectors
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by interpolating between the given two vectors |
v1 |
AxVector2 | First vector |
v2 |
AxVector2 | Second vector |
factor |
Number | Interpolation factor. Having this factor outside of [0, 1] results in extrapolation |
- Source:
(static) Max(result, v1, v2)
Produces a vector whose components are each the greater corresponding component from two other vectors
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector, having the greater components taken from the two original ones |
v1 |
AxVector2 | Original vector to compare against |
v2 |
AxVector2 | Original vector to compare against |
- Source:
(static) Min(result, v1, v2)
Produces a vector whose components are each the lesser corresponding component from two other vectors
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector, having the lesser components taken from the two original ones |
v1 |
AxVector2 | Original vector to compare against |
v2 |
AxVector2 | Original vector to compare against |
- Source:
(static) Normalize(result, v)
Normalizes a vector
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting normalized vector |
v |
AxVector2 | The vector to be normalized |
- Source:
(static) Scale(result, v1, factor)
Scales a vector by a scalar value
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by scaling the given vector |
v1 |
AxVector2 | Original vector for scaling |
factor |
AxVector2 | Number | An AxVector2 vector for component-wise scaling or a scalar number by which to multiply the components of the original vector |
- Source:
(static) Scale_1(result, v1, factor)
Scales a vector by a scalar value
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by scaling the given vector |
v1 |
AxVector2 | Original vector for scaling |
factor |
Number | Scaling factor |
- Source:
(static) Scale_2(result, v1, v2)
Scales a vector's components by the components of another vector
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by scaling the given vector |
v1 |
AxVector2 | Original vector for scaling |
v2 |
AxVector2 | Vector containing the per-component scaling factors |
- Source:
(static) SetLength(result, v, length)
Produces a vector with an orientation given by another vector and a given length
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector |
v |
AxVector2 | The vector which holds the orientation |
length |
Number | The length value for the new vector |
- Source:
(static) Subtract(result, v1, v2)
Subtracts two vectors
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting vector produced by subtracting the second vector from the first |
v1 |
AxVector2 | Vector to subtract from |
v2 |
AxVector2 | Vector to be subtracted |
- Source:
(static) Transform(result, v, transformation)
Transforms a vector by a given tranformation matrix.
This transformation takes into account the translation of the transformation
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting transformed vector |
v |
AxVector2 | The original vector to be transformed |
transformation |
AxMatrix | The transformation matrix to use |
- Source:
(static) TransformNormal(result, v, transformation)
Transforms a vector by a given tranformation matrix.
This transformation does not take into account the translation of the transformation
Parameters:
Name | Type | Description |
---|---|---|
result |
AxVector2 | The resulting transformed vector |
v |
AxVector2 | The original vector to be transformed |
transformation |
AxMatrix | The transformation matrix to use |
- Source: