class flixel.util.FlxVector extends FlxPoint
Available on all platforms
2-dimensional vector class
Class Fields
static function get(?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! * *
X | The X-coordinate of the point in space. * |
Y | The Y-coordinate of the point in space. |
Instance Fields
function addNew(v:FlxVector):FlxVector
Return new vector which equals to sum of this vector and passed v vector. * *
v | vector to add * |
returns | addition result |
function bounce(normal:FlxVector, ?bounceCoeff:Float = 1):FlxVector
Reflect the vector with respect to the normal of the "wall". * *
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) |
function bounceWithFriction(normal:FlxVector, ?bounceCoeff:Float = 1, ?friction:Float = 0):FlxVector
Reflect the vector with respect to the normal. This operation takes "friction" into account. * *
normal | left normal of the "wall". It must be normalized (no checks) * |
bounceCoeff | bounce coefficient (0 <= bounceCoeff <= 1) * |
friction | friction coefficient * |
returns | reflected vector |
function clone(?vec:FlxVector = null):FlxVector
Copies this vector. * *
vec | optional vector to copy this vector to * |
returns | copy of this vector |
function crossProductLength(v:FlxVector):Float
Find the length of cross product between two vectors. * *
v | vector to multiply * |
returns | the length of cross product of two vectors |
function degreesBetween(v:FlxVector):Float
The angle between vectors (in degrees). * *
v | second vector, which we find the angle * |
returns | the angle in radians |
function dotProdWithNormalizing(v:FlxVector):Float
Dot product of vectors with normalization of the second vector. * *
v | vector to multiply * |
returns | dot product of two vectors |
function dotProduct(v:FlxVector):Float
Dot product between two vectors. * *
v | vector to multiply * |
returns | dot product of two vectors |
function equals(v:FlxVector):Bool
Checking for equality of vectors. * *
returns | true - if the vectors are equal |
function findIntersection(a:FlxVector, b:FlxVector, v:FlxVector, ?intersection:FlxVector = null):FlxVector
Finding the point of intersection of vectors. * *
a | start point of the vector * |
b | start point of the v vector * |
v | the second vector * |
returns | the point of intersection of vectors |
function findIntersectionInBounds(a:FlxVector, b:FlxVector, v:FlxVector, ?intersection:FlxVector = null):FlxVector
Finding the point of intersection of vectors if it is in the "bounds" of the vectors. * *
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 |
function isParallel(v:FlxVector):Bool
Check for parallelism of two vectors. * *
v | vector to check * |
returns | true - if they are parallel |
function isPerpendicular(v:FlxVector):Bool
Check the perpendicularity of two vectors. * *
v | vector to check * |
returns | true - if they are perpendicular |
function projectTo(v:FlxVector, ?proj:FlxVector = null):FlxVector
The projection of this vector to vector that is passed as an argument * (without modifying the original Vector!). * *
v | vector to project * |
proj | optional argument - result vector * |
returns | projection of the vector |
function projectToNormalized(v:FlxVector, ?proj:FlxVector = null):FlxVector
Projecting this vector on the normalized vector v. * *
v | this vector has to be normalized, ie have unit length * |
proj | optional argument - result vector * |
returns | projection of the vector |
function radiansBetween(v:FlxVector):Float
Get the angle between vectors (in radians). * *
v | second vector, which we find the angle * |
returns | the angle in radians |
function ratio(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. * *
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 |
function rotateByDegrees(degs:Float):FlxVector
Rotate the vector for a given angle. * *
rads | angle to rotate * |
returns | rotated vector |
function rotateByRadians(rads:Float):FlxVector
Rotate the vector for a given angle. * *
rads | angle to rotate * |
returns | rotated vector |
function rotateWithTrig(sin:Float, cos:Float):FlxVector
Rotate the vector vector with the values of sine and cosine of the angle of rotation. * *
sin | the value of sine of the angle of rotation * |
cos | the value of cosine of the angle of rotation * |
returns | rotated vector |
function scaleNew(k:Float):FlxVector
Returns scaled copy of this vector. * *
k | - scale coefficient * |
returns | scaled vector |
function set(?X:Float = 0, ?Y:Float = 0):FlxVector
Set the coordinates of this point object. * *
X | The X-coordinate of the point in space. * |
Y | The Y-coordinate of the point in space. |
function sign(a:FlxVector, b:FlxVector):Int
The sign of half-plane of point with respect to the vector through the a and b points. * *
a | start point of the wall-vector * |
b | end point of the wall-vector |
function subtractNew(v:FlxVector):FlxVector
Returns new vector which is result of subtraction of v vector from this vector. * *
v | vector to subtract * |
returns | subtraction result |