Vec2

class cee.Vec2()

An immutable 2d vector with x, y values.

Used e.g. for texture coordinates

Constructors

cee.Vec2.constructor()
Vec2(x: number, y: number): Vec2

Constructor

Parameters

x: number

y: number

Returns: Vec2

Properties

cee.Vec2.x

readonly

x: number

The x coordinate of the vector

cee.Vec2.y

readonly

y: number

The y coordinate of the vector

Methods

cee.Vec2.equals()
equals(other: Vec2Like): boolean

Returns true if the vectors are equal

Parameters

other: Vec2Like

Returns: boolean

cee.Vec2.getLength()
getLength(): number

Returns the length of the vector (sqrt(x^2 + y^2)).

Returns: number

cee.Vec2.getLengthSquared()
getLengthSquared(): number

Returns the squared length of the vector

Returns: number

cee.Vec2.getNegated()
getNegated(): Vec2

Returns a negated version of the vector.

Returns: Vec2

cee.Vec2.getNormalized()
getNormalized(): Vec2

Returns a normalized version of the vector.

Returns: Vec2

static cee.Vec2.add()

static

add(a: Vec2Like, b: Vec2Like): Vec2

Returns the result of adding the two vectors

Parameters

Returns: Vec2

static cee.Vec2.dot()

static

dot(a: Vec2Like, b: Vec2Like): number

Returns the dot product of the 2 vectors

Parameters

Returns: number

static cee.Vec2.from()

static

from(vec: Vec2Like): Vec2

Creates a new Vec2 instance from any object with x and y properties.

Parameters

Returns: Vec2

static cee.Vec2.fromArray()

static

fromArray(arr: ArrayLike): Vec2

Creates a new Vec2 instance from the first 2 elements of the given array.

Parameters

arr: ArrayLike

Returns: Vec2

static cee.Vec2.negate()

static

negate(vec: Vec2Like): Vec2

Returns the negation of the given vector

Parameters

Returns: Vec2

static cee.Vec2.scale()

static

scale(vec: Vec2Like, factor: number): Vec2

Returns the result of scaling the given vector by the given factor

Parameters

vec: Vec2Like

factor: number

Returns: Vec2

static cee.Vec2.sub()

static

sub(a: Vec2Like, b: Vec2Like): Vec2

Returns the result of subtracting vector b from vector a

Parameters

Returns: Vec2