3D vector class.

Static variables

@:value(0)staticnumCreations:Int = 0

The number of instance creation.

Constructor

@:value({ z : 0, y : 0, x : 0 })inlinenew(x:Float = 0, y:Float = 0, z:Float = 0)

Creates a new vector. The vector is zero vector by default.

Variables

x:Float

The x-value of the vector.

y:Float

The y-value of the vector.

z:Float

The z-value of the vector.

Methods

inlineadd(v:Vec3):Vec3

Returns this + v.

inlineadd3(vx:Float, vy:Float, vz:Float):Vec3

Returns (this.x + vx, this.y + vy, this.z + vz).

inlineadd3Eq(vx:Float, vy:Float, vz:Float):Vec3

Sets this vector to (this.x + vx, this.y + vy, this.z + vz) and returns this.

inlineaddEq(v:Vec3):Vec3

Sets this vector to this + v and returns this.

inlineaddScaled(v:Vec3, s:Float):Vec3

Returns this + v * s.

inlineaddScaledEq(v:Vec3, s:Float):Vec3

Sets this vector to this + v * s and returns this.

inlineclone():Vec3

Returns a clone of the vector.

inlinecopyFrom(v:Vec3):Vec3

Copies values from v and returns this.

inlinecross(v:Vec3):Vec3

Returns the cross product of this and v.

inlinecrossEq(v:Vec3):Vec3

Sets this vector to the cross product of this and s, and returns this.

inlinedot(v:Vec3):Float

Returns the dot product of this and v.

init(x:Float, y:Float, z:Float):Vec3

Sets all values at once and returns this.

inlinelength():Float

Returns the length of the vector.

inlinelengthSq():Float

Returns the squared length of the vector.

inlinemulMat3(m:Mat3):Vec3

Returns the transformed vector by m.

inlinemulMat3Eq(m:Mat3):Vec3

Sets this vector to the transformed vector by m and returns this.

inlinemulMat4(m:Mat4):Vec3

Returns the transformed vector by m.

inlinemulMat4Eq(m:Mat4):Vec3

Sets this vector to the transformed vector by m and returns this.

inlinemulTransform(tf:Transform):Vec3

Returns the transformed vector by tf.

inlinemulTransformEq(tf:Transform):Vec3

Sets this vector to the transformed vector by tf and returns this.

inlinenegate():Vec3

Returns the nagated vector.

inlinenegateEq():Vec3

Negate the vector and returns this.

inlinenormalize():Vec3

Normalize this vector and returns this.

If the length is zero, this vector is set to zero vector.

inlinenormalized():Vec3

Returns the normalized vector.

If the length is zero, zero vector is returned.

inlinescale(s:Float):Vec3

Returns this * s.

inlinescale3(sx:Float, sy:Float, sz:Float):Vec3

Returns (this.x * sx, this.y * sy, this.z * sz).

inlinescale3Eq(sx:Float, sy:Float, sz:Float):Vec3

Sets this vector to (this.x * sx, this.y * sy, this.z * sz) and returns this.

inlinescaleEq(s:Float):Vec3

Sets this vector to this * s and returns this.

inlinesub(v:Vec3):Vec3

Returns this - v.

inlinesub3(vx:Float, vy:Float, vz:Float):Vec3

Returns (this.x - vx, this.y - vy, this.z - vz).

inlinesub3Eq(vx:Float, vy:Float, vz:Float):Vec3

Sets this vector to (this.x - vx, this.y - vy, this.z - vz) and returns this.

inlinesubEq(v:Vec3):Vec3

Sets this vector to this - v and returns this.

toString():String

Returns the string representation of the vector.

zero():Vec3

Sets this vector to zero vector and returns this.