The function checks if the x and y values of a point are both zero.
A boolean value indicating whether both the x and y properties of the object are equal to 0.
The above function calculates the length of a vector using the Pythagorean theorem.
The length of a vector, calculated using the Pythagorean theorem.
The function calculates the square of the length of a vector.
The method is returning the sum of the squares of the x and y values.
Static
absThe function takes a Vector2D object as input and returns a new Vector2D object with the absolute values of its x and y components.
The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector. It has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
The method is returning a new Vector2D object with the absolute values of the x and y components of the input vector.
Static
addThe function "add" takes two Vector2D objects as parameters and returns a new Vector2D object with the sum of their x and y components.
The method is returning a new instance of the Vector2D class with the x and y components of the two input vectors added together.
Static
angleThe function calculates the angle between a given vector and the negative y-axis.
The "vector" parameter is an instance of the Vector2D class, which represents a 2-dimensional vector. It has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
the angle between the given vector and the vector (0, -1) in radians.Returns the angle between origin and the given vector in radians
Static
distanceThe function calculates the distance between two points in a two-dimensional space.
The parameter vector1
represents the first vector in 2D space, while vector2
represents the second vector. Each vector has an x
and y
component, which represent their respective coordinates
in the 2D space.
The vector2
parameter represents the second vector in the calculation of distance. It
is an instance of the Vector2D
class, which typically has properties x
and y
representing the coordinates of
the vector in a 2D space.
The distance between vector1 and vector2.
Static
distanceThe function calculates the squared distance between two 2D vectors.
The parameter vector1
represents the first vector, which is an instance of the
Vector2D
class. It contains the x and y coordinates of the vector.
The vector2
parameter represents the second vector in a two-dimensional space. It has
properties x
and y
which represent the coordinates of the vector.
the square of the distance between the two input vectors.
Static
divideThe function divides the x and y components of a Vector2D by a given value and returns a new Vector2D.
The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with x and y components.
The value parameter is a number that will be used to divide the x and y components of the vector.
A new instance of the Vector2D class with the x and y values divided by the given value.
Static
dotStatic
equalsStatic
equalsThe function checks if two Vector2D objects are equal within a specified rounding factor.
The first vector to compare.
The parameter "vector2" is a Vector2D object, which represents a 2-dimensional vector. It is used as one of the inputs for the "equalsRounded" function.
Optional
roundingFactor: number = 12The roundingFactor parameter is used to determine the threshold for considering two vectors as equal. If the absolute difference in the x and y components of the vectors is less than the roundingFactor, the vectors are considered equal.
a boolean value.
Static
multiplyThe function multiplies a Vector2D object by a given value.
The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with x and y components.
The "value" parameter is a number that represents the value by which the x and y components of the vector will be multiplied.
A new Vector2D object with the x and y values multiplied by the given value.
Static
normalizeThe normalize function takes a vector as input and returns a normalized version of the vector.Normalizes the vector if it matches a certain condition
The parameter "vector" is of type Vector2D.
the normalized vector if its length is greater than a very small value (epsilon), otherwise it returns the original vector.
Static
perpStatic
randomThe function "random" generates a random Vector2D object with x and y values within the specified range.
The maxX parameter represents the maximum value for the x-coordinate of the random vector.
The maxY
parameter represents the maximum value for the y-coordinate of the generated
random vector.
a new instance of the Vector2D class with random x and y values.
Static
reverseThe reverse function takes a Vector2D object and returns a new Vector2D object with the negated x and y values.
The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector. It has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
A new Vector2D object with the negated x and y values of the input vector. Returns the vector that is the reverse of this vector
Static
signThe sign function determines the sign of the cross product between two 2D vectors. (assuming the Y axis is pointing down, X axis to right like a Window app)
The parameter vector1
is of type Vector2D
, which represents a 2-dimensional vector.
It likely has properties x
and y
representing the x and y components of the vector, respectively.
The above code defines a function called "sign" that takes two parameters: vector1 and vector2. Both vector1 and vector2 are of type Vector2D.
either -1 or 1. Returns positive if v2 is clockwise of this vector, negative if counterclockwise
Static
subtractThe subtract function takes two Vector2D objects as parameters and returns a new Vector2D object with the x and y components subtracted.
The parameter vector1
is an instance of the Vector2D
class, representing a
2-dimensional vector. It has properties x
and y
which represent the x and y components of the vector
respectively.
The parameter "vector2" is a Vector2D object. It represents the second vector that you want to subtract from the first vector.
The method is returning a new Vector2D object with the x and y components subtracted from vector1 and vector2.
Static
subtractThe function subtracts a given value from the x and y components of a Vector2D object and returns a new Vector2D object.
The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with x and y components.
The "value" parameter is a number that will be subtracted from both the x and y components of the "vector" parameter.
A new Vector2D object with the x and y values subtracted by the given value.
Static
truncateThe function truncates a vector to a maximum length if it exceeds that length.Adjusts x and y so that the length of the vector does not exceed max
A 2D vector represented by the Vector2D class.
The max
parameter is a number that represents the maximum length that the vector
should
have.
either the original vector or a truncated version of the vector, depending on whether the length of the vector is greater than the maximum value specified.
Generated using TypeDoc
data-structure-typed
Author
Tyler Zeng
Copyright
Copyright (c) 2022 Tyler Zeng zrwusa@gmail.com
License
MIT License