Vector2

php\gdx\math\Vector2

Class Vector2

Methods


__construct($x, $y)
Параметры:
x()
Результат:float
y()
Результат:float
len()
Результат:float The euclidean length
len2()
Результат:float The squared euclidean length
set($x, $y)

Sets this vector from the given vector or x, y

Параметры:
Результат:

php\gdx\math\Vector2

sub($x, $y)

Subtracts the given vector from this vector.

Параметры:
Результат:

php\gdx\math\Vector2

nor()

Normalizes this vector. Does nothing if it is zero.

Результат:php\gdx\math\Vector2
add($x, $y)

Adds the given vector to this vector

Параметры:
dot($ox, $oy)
Параметры:
Результат:

float The dot product between this and the other vector

scl($x, $y)

Scales this vector by a scalar

Параметры:
  • $xfloat
  • $yfloat - (optional)
Результат:

php\gdx\math\Vector2

mulAdd($vec, $scalar)

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

Параметры:
Результат:

php\gdx\math\Vector2

dst($x, $y)
Параметры:
Результат:

float the distance between this and the other vector

dst2($x, $y)
Параметры:
Результат:

float the squared distance between this and the other vector

limit($limit)
Параметры:
  • $limitfloat
Результат:

php\gdx\math\Vector2

clamp($min, $max)
Параметры:
  • $minfloat
  • $maxfloat
Результат:

php\gdx\math\Vector2

crs($x, $y)
Параметры:
Результат:

float

angle()
Результат:float
getAngleRad()
Результат:float
setAngle($degrees)
Параметры:
  • $degreesfloat
Результат:

php\gdx\math\Vector2

setAngleRad($radians)
Параметры:
  • $radiansfloat
Результат:

php\gdx\math\Vector2

rotate($degrees)
Параметры:
  • $degreesfloat
Результат:

php\gdx\math\Vector2

rotateRad($radians)
Параметры:
  • $radiansfloat
Результат:

php\gdx\math\Vector2

rotate90($dir)
Параметры:
  • $dirint
Результат:

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.

Параметры:
Результат:

php\gdx\math\Vector2

epsilonEquals($other, $epsilon)

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

Параметры:
Результат:

bool

isUnit($margin)

Whether this vector is a unit length vector

Параметры:
  • $marginfloat - (optional)
Результат:

bool

isZero($margin)
Параметры:
  • $marginfloat - (optional)
isOnLine($other, $epsilon)
Параметры:
Результат:

bool

isCollinear($other, $epsilon)
Параметры:
Результат:

bool

isCollinearOpposite($other, $epsilon)
Параметры:
Результат:

bool

isPerpendicular($vector, $epsilon)
Параметры:
hasSameDirection($vector)
Параметры:
Результат:

bool

hasOppositeDirection($vector)
Параметры:
Результат:

bool