Vec2
- class cee.Vec2()
An immutable 2d vector with x, y values.
Used e.g. for texture coordinates
Constructors
Methods
Constructors
constructor
- cee.Vec2.constructor(x, y)
Constructor
- Arguments
x (
number
) –y (
number
) –
- Return type
cee.Vec2
Properties
- cee.Vec2.x
The x coordinate of the vector
- cee.Vec2.y
The y coordinate of the vector
Methods
equals
- cee.Vec2.equals(other)
Returns true if the vectors are equal
- Arguments
other (
cee.Vec2Like
) –
- Return type
boolean
getLength
- cee.Vec2.getLength()
Returns the length of the vector (sqrt(x^2 + y^2)).
- Return type
number
getLengthSquared
- cee.Vec2.getLengthSquared()
Returns the squared length of the vector
- Return type
number
getNegated
- cee.Vec2.getNegated()
Returns a negated version of the vector.
- Return type
cee.Vec2
getNormalized
- cee.Vec2.getNormalized()
Returns a normalized version of the vector.
- Return type
cee.Vec2
add
- cee.Vec2.add(a, b)
Returns the result of adding the two vectors
- Arguments
a (
cee.Vec2Like
) –b (
cee.Vec2Like
) –
- Return type
cee.Vec2
dot
- cee.Vec2.dot(a, b)
Returns the dot product of the 2 vectors
- Arguments
a (
cee.Vec2Like
) –b (
cee.Vec2Like
) –
- Return type
number
from
- cee.Vec2.from(vec)
Creates a new Vec2 instance from any object with x and y properties.
- Arguments
vec (
cee.Vec2Like
) –
- Return type
cee.Vec2
fromArray
- cee.Vec2.fromArray(arr)
Creates a new Vec2 instance from the first 2 elements of the given array.
- Arguments
arr (
ArrayLike[number]
) –
- Return type
cee.Vec2
negate
- cee.Vec2.negate(vec)
Returns the negation of the given vector
- Arguments
vec (
cee.Vec2Like
) –
- Return type
cee.Vec2
scale
- cee.Vec2.scale(vec, factor)
Returns the result of scaling the given vector by the given factor
- Arguments
vec (
cee.Vec2Like
) –factor (
number
) –
- Return type
cee.Vec2
sub
- cee.Vec2.sub(a, b)
Returns the result of subtracting vector b from vector a
- Arguments
a (
cee.Vec2Like
) –b (
cee.Vec2Like
) –
- Return type
cee.Vec2