class flixel.util.FlxVector extends FlxPoint

Available on all platforms

2-dimensional vector class

Class Fields

static var EPSILON:Float

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

var degrees:Float

The angle formed by the vector with the horizontal axis (in degrees)

var dx:Float

The horizontal component of the unit vector

var dy:Float

The vertical component of the unit vector

var length:Float

Length of the vector

var lengthSquared:Float

length of the vector squared

var lx:Float

The horizontal component of the left normal of the vector

var ly:Float

The vertical component of the left normal of the vector

var radians:Float

The angle formed by the vector with the horizontal axis (in radians)

var rx:Float

The horizontal component of the right normal of the vector

var ry:Float

The vertical component of the right normal of the vector

function new(?X:Float, ?Y:Float):Void

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 dist(v:FlxVector):Float

The distance between points

function distSquared(v:FlxVector):Float

The squared distance between points

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 isNormalized():Bool

Check the vector for unit length

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 isValid():Bool

Checking if this is a valid vector. * *

returns

true - if the vector is valid

function isZero():Bool

Check if this vector has zero length. * *

returns

true - if the vector is zero

function leftNormal(?vec:FlxVector = null):FlxVector

Left normal of the vector

function negate():FlxVector

Change direction of the vector to opposite

function negateNew():FlxVector

function normalize():FlxVector

Normalization of the vector (reduction to unit length)

function perpProduct(v:FlxVector):Float

Dot product of left the normal vector and vector v

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 put():Void

Add this FlxVector to the recycling pool.

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 rightNormal(?vec:FlxVector = null):FlxVector

Right normal of the 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 scale(k:Float):FlxVector

Scale this vector. * *

k- scale coefficient *
returns

scaled 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

function truncate(max:Float):FlxVector

Limit the length of this vector. * *

max

maximum length of this vector

function zero():FlxVector

Vector reset