abstract hxmath.math.Vector4(Vector4Shape) from Vector4Shape to Vector4Shape

Available on all platforms

A 4D vector (used with homogenous/projection matrices in 3D).

Class Fields

function add(a:Vector4, b:Vector4):Vector4

Add two vectors.

a
b
returns

a + b

function dot(a:Vector4, b:Vector4):Float

Dot product.

a
b
returns

sumi (ai * b_i)

function equals(a:Vector4, b:Vector4):Bool

Test element-wise equality between two vectors. False if one of the inputs is null and the other is not.

a
b
returns

ai == bi

function fromArray(rawData:Array<Float>):Vector4

Construct a Vector4 from an array.

rawData

The input array.

returns

The constructed structure.

function lerp(a:Vector4, b:Vector4, t:Float):Vector4

Linear interpolation between two vectors.

a

The value at t = 0

b

The value at t = 1

t

A number in the range [0, 1]

returns

The interpolated value

function negate(a:Vector4):Vector4

Create a negated copy of a vector.

a
returns

-a

function notEquals(a:Vector4, b:Vector4):Bool

Test inequality between two vectors.

a
b
returns

!(ai == bi)

function scalarMultiply(s:Float, a:Vector4):Vector4

Multiply a scalar with a vector.

s
a
returns

s * a

function subtract(a:Vector4, b:Vector4):Vector4

Subtract one vector from another.

a
b
returns

a - b

Instance Fields

function new(?x:Float = 0.0f, ?y:Float = 0.0f, ?z:Float = 0.0f, ?w:Float = 0.0f):Vector4Shape

Constructor.

x
y
z
null

w

function addWith(a:Vector4):Vector4

Add a vector in place. Note: += operator on Haxe abstracts does not behave this way (a new object is returned).

a
returns

selfi += ai

function applyScalarFunc(func:Float ->Float):Vector4

Apply a scalar function to each element.

func

The function to apply.

returns

The modified object.

function clone():Vector4

Clone.

returns

The cloned object.

function copyTo(other:Vector4):Void

Copy the contents of this structure to another.

other

The target structure.

function getArrayElement(i:Int):Float

Get an element by position.

i

The element index.

returns

The element.

function setArrayElement(i:Int, value:Float):Float

Set an element by position.

i

The element index.

value

The new value.

returns

The updated element.

function subtractWith(a:Vector4):Vector4

Subtract a vector in place. Note: -= operator on Haxe abstracts does not behave this way (a new object is returned).

a
returns

selfi -= ai