Vector2DKt

public final class Vector2DKt

Functions

add
Link copied to clipboard
final static Vector2D add(Vector2D $self, Vector2D other)
addWithScalarMultiply
Link copied to clipboard
final static Vector2D addWithScalarMultiply(Vector2D $self, Vector2D other, Float scalar)

To add a vector to this vector and multiplies the other vector with scalar

angleBetween
Link copied to clipboard
final static Float angleBetween(Vector2D $self, Vector2D other)

Returns angle between this vector and other vector

dec
Link copied to clipboard
final static Vector2D dec(Vector2D $self, Float factor)

Decrements this vector by factor

distance
Link copied to clipboard
final static Float distance(Vector2D $self, Vector2D other)

Calculates Euclidean distance between two vectors

div
Link copied to clipboard
final static Vector2D div(Vector2D $self, Float x, Float y)

To divide this vector by x and y values

divAssign
Link copied to clipboard
final static Unit divAssign(Vector2D $self, Float factor)
divide
Link copied to clipboard
final static Vector2D divide(Vector2D $self, Float factor)

To divide this vector by single factor

dot
Link copied to clipboard
final static Float dot(Vector2D $self, Vector2D other)

Calculates the dot product of two vectors

heading
Link copied to clipboard
final static Float heading(Vector2D $self)

Calculate the angle of rotation for this vector(only 2D vectors).

inc
Link copied to clipboard
final static Vector2D inc(Vector2D $self, Float factor)

Increments this vector by factor

lerp
Link copied to clipboard
final static Vector2D lerp(Vector2D $self, Float x, Float y, Float amt)

Linear interpolate the vector to another vector

limit
Link copied to clipboard
final static Vector2D limit(Vector2D $self, Float max)

Limit the magnitude of this vector to the value used for the max parameter. val v = Vector2D(10, 20); // v has components 10.0, 20.0 v.limit(5); // v's components are set to // 2.2271771, 4.4543543

mag
Link copied to clipboard
final static Float mag(Vector2D $self)

Calculates the magnitude (length) of the vector and returns the result asa float

magSq
Link copied to clipboard
final static Float magSq(Vector2D $self)

Calculates the squared magnitude of this vector and returns the result as a float

minusAssign
Link copied to clipboard
final static Unit minusAssign(Vector2D $self, Vector2D other)
multiply
Link copied to clipboard
final static Vector2D multiply(Vector2D $self, Float factor)

To multiply this vector with single factor See also scalarMultiply

final static Vector2D multiply(Vector2D $self, Float x, Float y)

To multiply this vector with x factor and y factor

normalize
Link copied to clipboard
final static Vector2D normalize(Vector2D $self)

Normalizes the vector to length 1 - making unit vector

plusAssign
Link copied to clipboard
final static Unit plusAssign(Vector2D $self, Vector2D other)
reflect
Link copied to clipboard
final static Vector2D reflect(Vector2D $self, Vector2D surfaceNormal)

Reflect the incoming vector about a normal to a line in 2D, or about a normal to a plane in 3D This method acts on the vector directly

rotate
Link copied to clipboard
final static Vector2D rotate(Vector2D $self, Float angle)

Rotates this vector by given angle

scalarMultiply
Link copied to clipboard
final static Vector2D scalarMultiply(Vector2D $self, Float scalar)
set
Link copied to clipboard
final static Vector2D set(Vector2D $self, Vector2D other)

Sets this vector as other vector

setHeading
Link copied to clipboard
final static Vector2D setHeading(Vector2D $self, Float angle)

Rotate the vector to a specific angle, magnitude remains the same

setMag
Link copied to clipboard
final static Vector2D setMag(Vector2D $self, Float n)

Set the magnitude of this vector to the value used for the n parameter.

sub
Link copied to clipboard
final static Vector2D sub(Vector2D $self, Vector2D other)

To subtract a vector from this vector

timesAssign
Link copied to clipboard
final static Unit timesAssign(Vector2D $self, Float factor)
toOffSet
Link copied to clipboard
final static Offset toOffSet(Vector2D $self)

Converts a this into Offset value