2-dimensional vector class
Static variables
Static methods
staticinlineadd(this:FlxPoint, x:Float = 0, y:Float = 0):FlxVector
Adds to the coordinates of this point.
Parameters:
x | Amount to add to x |
---|---|
y | Amount to add to y |
Returns:
This point.
staticinlineaddNew(this:FlxPoint, v:FlxVector):FlxVector
Return new vector which equals to sum of this vector and passed v vector.
Parameters:
v | vector to add |
---|
Returns:
addition result
staticinlineaddPoint(this:FlxPoint, point:FlxPoint):FlxVector
Adds the coordinates of another point to the coordinates of this point.
Parameters:
point | The point to add to this point |
---|
Returns:
This point.
staticinlinebounce(this:FlxPoint, normal:FlxVector, bounceCoeff:Float = 1):FlxVector
Reflect the vector with respect to the normal of the "wall".
Parameters:
normal | left normal of the "wall". It must be normalized (no checks) |
---|---|
bounceCoeff | bounce coefficient (0 <= bounceCoeff <= 1) |
Returns:
reflected vector (angle of incidence equals to angle of reflection)
staticinlinebounceWithFriction(this:FlxPoint, normal:FlxVector, bounceCoeff:Float = 1, friction:Float = 0):FlxVector
Reflect the vector with respect to the normal. This operation takes "friction" into account.
Parameters:
normal | left normal of the "wall". It must be normalized (no checks) |
---|---|
bounceCoeff | bounce coefficient (0 <= bounceCoeff <= 1) |
friction | friction coefficient |
Returns:
reflected vector
staticclone(this:FlxPoint, ?vec:FlxVector):FlxVector
Copies this vector.
Parameters:
vec | optional vector to copy this vector to |
---|
Returns:
copy of this vector
staticinlinecopyFrom(this:FlxPoint, point:FlxPoint):FlxVector
Helper function, just copies the values from the specified point.
Parameters:
point | Any FlxPoint. |
---|
Returns:
A reference to itself.
staticinlinecopyFromFlash(this:FlxPoint, flashPoint:Point):FlxVector
Helper function, just copies the values from the specified Flash point.
Parameters:
Point | Any Point. |
---|
Returns:
A reference to itself.
staticinlinecrossProductLength(this:FlxPoint, v:FlxVector):Float
Find the length of cross product between two vectors.
Parameters:
v | vector to multiply |
---|
Returns:
the length of cross product of two vectors
staticinlinedegreesBetween(this:FlxPoint, v:FlxVector):Float
The angle between vectors (in degrees).
Parameters:
v | second vector, which we find the angle |
---|
Returns:
the angle in radians
staticinlinedotProdWithNormalizing(this:FlxPoint, v:FlxVector):Float
Dot product of vectors with normalization of the second vector.
Parameters:
v | vector to multiply |
---|
Returns:
dot product of two vectors
staticinlinedotProduct(this:FlxPoint, v:FlxVector):Float
Dot product between two vectors.
Parameters:
v | vector to multiply |
---|
Returns:
dot product of two vectors
staticfindIntersection(this:FlxPoint, a:FlxVector, b:FlxVector, v:FlxVector, ?intersection:FlxVector):FlxVector
Finding the point of intersection of vectors.
Parameters:
a | start point of the vector |
---|---|
b | start point of the v vector |
v | the second vector |
Returns:
the point of intersection of vectors
staticfindIntersectionInBounds(this:FlxPoint, a:FlxVector, b:FlxVector, v:FlxVector, ?intersection:FlxVector):FlxVector
Finding the point of intersection of vectors if it is in the "bounds" of the vectors.
Parameters:
a | start point of the vector |
---|---|
b | start point of the v vector |
v | the second vector |
Returns:
the point of intersection of vectors if it is in the "bounds" of the vectors
staticinlineget(x:Float = 0, y:Float = 0):FlxVector
Recycle or create new FlxVector. Be sure to put() them back into the pool after you're done with them!
Parameters:
x | The X-coordinate of the point in space. |
---|---|
y | The Y-coordinate of the point in space. |
staticinlineisParallel(this:FlxPoint, v:FlxVector):Bool
Check for parallelism of two vectors.
Parameters:
v | vector to check |
---|
Returns:
true - if they are parallel
staticinlineisPerpendicular(this:FlxPoint, v:FlxVector):Bool
Check the perpendicularity of two vectors.
Parameters:
v | vector to check |
---|
Returns:
true - if they are perpendicular
staticinlineisValid(this:FlxPoint):Bool
Checking if this is a valid vector.
Returns:
true - if the vector is valid
staticinlineisZero(this:FlxPoint):Bool
Check if this vector has zero length.
Returns:
true - if the vector is zero
staticinlineperpProduct(this:FlxPoint, v:FlxVector):Float
Dot product of left the normal vector and vector v.
staticprojectTo(this:FlxPoint, v:FlxVector, ?proj:FlxVector):FlxVector
The projection of this vector to vector that is passed as an argument (without modifying the original Vector!).
Parameters:
v | vector to project |
---|---|
proj | optional argument - result vector |
Returns:
projection of the vector
staticprojectToNormalized(this:FlxPoint, v:FlxVector, ?proj:FlxVector):FlxVector
Projecting this vector on the normalized vector v.
Parameters:
v | this vector has to be normalized, ie have unit length |
---|---|
proj | optional argument - result vector |
Returns:
projection of the vector
staticinlineradiansBetween(this:FlxPoint, v:FlxVector):Float
Get the angle between vectors (in radians).
Parameters:
v | second vector, which we find the angle |
---|
Returns:
the angle in radians
staticinlineratio(this:FlxPoint, a:FlxVector, b:FlxVector, v:FlxVector):Float
Find the ratio between the perpProducts of this vector and v vector. This helps to find the intersection point.
Parameters:
a | start point of the vector |
---|---|
b | start point of the v vector |
v | the second vector |
Returns:
the ratio between the perpProducts of this vector and v vector
staticrotate(this:FlxPoint, pivot:FlxPoint, angle:Float):FlxVector
Rotates this point clockwise in 2D space around another point by the given angle.
Parameters:
Pivot | The pivot you want to rotate this point around |
---|---|
Angle | Rotate the point by this many degrees clockwise. |
Returns:
A FlxPoint containing the coordinates of the rotated point.
staticinlinerotateByDegrees(this:FlxPoint, degs:Float):FlxVector
Rotate the vector for a given angle.
Parameters:
degs | angle to rotate |
---|
Returns:
rotated vector
staticinlinerotateByRadians(this:FlxPoint, rads:Float):FlxVector
Rotate the vector for a given angle.
Parameters:
rads | angle to rotate |
---|
Returns:
rotated vector
staticinlinerotateWithTrig(this:FlxPoint, sin:Float, cos:Float):FlxVector
Rotate the vector with the values of sine and cosine of the angle of rotation.
Parameters:
sin | the value of sine of the angle of rotation |
---|---|
cos | the value of cosine of the angle of rotation |
Returns:
rotated vector
staticinlinescale(this:FlxPoint, k:Float):FlxVector
Scale this vector.
Parameters:
k |
|
---|
Returns:
scaled vector
staticinlinescaleNew(this:FlxPoint, k:Float):FlxVector
Returns scaled copy of this vector.
Parameters:
k |
|
---|
Returns:
scaled vector
staticinlineset(this:FlxPoint, x:Float = 0, y:Float = 0):FlxVector
Set the coordinates of this point object.
Parameters:
x | The X-coordinate of the point in space. |
---|---|
y | The Y-coordinate of the point in space. |
staticinlinesetPolarDegrees(this:FlxPoint, length:Float, degrees:Float):FlxVector
Sets the polar coordinates of the vector
Parameters:
length | The length to set the vector |
---|---|
degrees | The angle to set the vector, in degrees |
Returns:
The rotated vector
4.10.0
.staticsetPolarRadians(this:FlxPoint, length:Float, radians:Float):FlxVector
Sets the polar coordinates of the vector
Parameters:
length | The length to set the vector |
---|---|
radians | The angle to set the vector, in radians |
Returns:
The rotated vector
4.10.0
.staticsign(this:FlxPoint, a:FlxVector, b:FlxVector):Int
The sign of half-plane of point with respect to the vector through the a and b points.
Parameters:
a | start point of the wall-vector |
---|---|
b | end point of the wall-vector |
staticinlinesubtract(this:FlxPoint, x:Float = 0, y:Float = 0):FlxVector
Subtracts from the coordinates of this point.
Parameters:
x | Amount to subtract from x |
---|---|
y | Amount to subtract from y |
Returns:
This point.
staticinlinesubtractNew(this:FlxPoint, v:FlxVector):FlxVector
Returns new vector which is result of subtraction of v vector from this vector.
Parameters:
v | vector to subtract |
---|
Returns:
subtraction result
staticinlinesubtractPoint(this:FlxPoint, point:FlxPoint):FlxVector
Subtracts the coordinates of another point from the coordinates of this point.
Parameters:
point | The point to subtract from this point |
---|
Returns:
This point.
staticinlinetransform(this:FlxPoint, matrix:Matrix):FlxVector
Applies transformation matrix to this point
Parameters:
matrix | transformation matrix |
---|
Returns:
transformed point
staticinlinetruncate(this:FlxPoint, max:Float):FlxVector
Limit the length of this vector.
Parameters:
max | maximum length of this vector |
---|