Vector2¶
-
php\gdx\math\Vector2
Class Vector2
Methods
__construct
($x, $y)¶
Parameters:
- $x – float, php\gdx\math\Vector2 - (optional)
- $y – float - (optional)
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:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
Returns:
sub
($x, $y)¶Subtracts the given vector from this vector.
Parameters:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
Returns:
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:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
dot
($ox, $oy)¶
Parameters:
- $ox – float, php\gdx\math\Vector2
- $oy – float - (optional)
Returns: float The dot product between this and the other vector
scl
($x, $y)¶Scales this vector by a scalar
Parameters:
- $x – float
- $y – float - (optional)
Returns:
mulAdd
($vec, $scalar)¶First scale a supplied vector, then add it to this vector.
Parameters:
- $vec – php\gdx\math\Vector2
- $scalar – float
Returns:
dst
($x, $y)¶
Parameters:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
Returns: float the distance between this and the other vector
dst2
($x, $y)¶
Parameters:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
Returns: float the squared distance between this and the other vector
limit
($limit)¶
Parameters:
- $limit – float
Returns:
clamp
($min, $max)¶
Parameters:
- $min – float
- $max – float
Returns:
crs
($x, $y)¶
Parameters:
- $x – float, php\gdx\math\Vector2
- $y – float - (optional)
Returns: float
angle
()¶
Returns: float
getAngleRad
()¶
Returns: float
setAngle
($degrees)¶
Parameters:
- $degrees – float
Returns:
setAngleRad
($radians)¶
Parameters:
- $radians – float
Returns:
rotate
($degrees)¶
Parameters:
- $degrees – float
Returns:
rotateRad
($radians)¶
Parameters:
- $radians – float
Returns:
rotate90
($dir)¶
Parameters:
- $dir – int
Returns:
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:
- $target – php\gdx\math\Vector2
- $alpha – float
Returns:
epsilonEquals
($other, $epsilon)¶Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
Parameters:
- $other – php\gdx\math\Vector2
- $epsilon – float
Returns: bool
isUnit
($margin)¶Whether this vector is a unit length vector
Parameters:
- $margin – float - (optional)
Returns: bool
isZero
($margin)¶
Parameters:
- $margin – float - (optional)
isOnLine
($other, $epsilon)¶
Parameters:
- $other – php\gdx\math\Vector2
- $epsilon – float - (optional)
Returns: bool
isCollinear
($other, $epsilon)¶
Parameters:
- $other – php\gdx\math\Vector2
- $epsilon – float - (optional)
Returns: bool
isCollinearOpposite
($other, $epsilon)¶
Parameters:
- $other – php\gdx\math\Vector2
- $epsilon – float - (optional)
Returns: bool
isPerpendicular
($vector, $epsilon)¶
Parameters:
- $vector – php\gdx\math\Vector2
- $epsilon – float - (optional)
hasSameDirection
($vector)¶
Parameters:
- $vector – php\gdx\math\Vector2
Returns: bool
hasOppositeDirection
($vector)¶
Parameters:
- $vector – php\gdx\math\Vector2
Returns: bool