Vector2

php\gdx\math\Vector2

Class Vector2

Methods


__construct($x, $y)
Parameters:
x()
Returns:float
y()
Returns:float
len()
Returns:float The euclidean length
len2()
Returns:float The squared euclidean length
set($x, $y)

Sets this vector from the given vector or x, y

Parameters:
Returns:

php\gdx\math\Vector2

sub($x, $y)

Subtracts the given vector from this vector.

Parameters:
Returns:

php\gdx\math\Vector2

nor()

Normalizes this vector. Does nothing if it is zero.

Returns:php\gdx\math\Vector2
add($x, $y)

Adds the given vector to this vector

Parameters:
dot($ox, $oy)
Parameters:
Returns:

float The dot product between this and the other vector

scl($x, $y)

Scales this vector by a scalar

Parameters:
  • $xfloat
  • $yfloat - (optional)
Returns:

php\gdx\math\Vector2

mulAdd($vec, $scalar)

First scale a supplied vector, then add it to this vector.

Parameters:
Returns:

php\gdx\math\Vector2

dst($x, $y)
Parameters:
Returns:

float the distance between this and the other vector

dst2($x, $y)
Parameters:
Returns:

float the squared distance between this and the other vector

limit($limit)
Parameters:
  • $limitfloat
Returns:

php\gdx\math\Vector2

clamp($min, $max)
Parameters:
  • $minfloat
  • $maxfloat
Returns:

php\gdx\math\Vector2

crs($x, $y)
Parameters:
Returns:

float

angle()
Returns:float
getAngleRad()
Returns:float
setAngle($degrees)
Parameters:
  • $degreesfloat
Returns:

php\gdx\math\Vector2

setAngleRad($radians)
Parameters:
  • $radiansfloat
Returns:

php\gdx\math\Vector2

rotate($degrees)
Parameters:
  • $degreesfloat
Returns:

php\gdx\math\Vector2

rotateRad($radians)
Parameters:
  • $radiansfloat
Returns:

php\gdx\math\Vector2

rotate90($dir)
Parameters:
  • $dirint
Returns:

php\gdx\math\Vector2

lerp($target, $alpha)

Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.

Parameters:
Returns:

php\gdx\math\Vector2

epsilonEquals($other, $epsilon)

Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.

Parameters:
Returns:

bool

isUnit($margin)

Whether this vector is a unit length vector

Parameters:
  • $marginfloat - (optional)
Returns:

bool

isZero($margin)
Parameters:
  • $marginfloat - (optional)
isOnLine($other, $epsilon)
Parameters:
Returns:

bool

isCollinear($other, $epsilon)
Parameters:
Returns:

bool

isCollinearOpposite($other, $epsilon)
Parameters:
Returns:

bool

isPerpendicular($vector, $epsilon)
Parameters:
hasSameDirection($vector)
Parameters:
Returns:

bool

hasOppositeDirection($vector)
Parameters:
Returns:

bool