Header menu logo Euclid

UnitVec Type

An immutable 3D vector guaranteed to be always unitized. A 3D vector represents a direction or an offset in space, but not a location. A 4x4 transformation matrix applied to a vector will only rotate and scale the vector but not translate it. (2D unit-vectors are called 'UnitVc' ) Use UnitVec.create or UnitVec.createUnchecked to created instances. Note: Never use the struct default constructor UnitVec() as it will create an invalid zero length vector. Use UnitVec.create or UnitVec.createUnchecked instead.

Record fields

Record Field Description

X

Full Usage: X

Field type: float

Gets the X part of this 3D unit-vector.

Field type: float

Y

Full Usage: Y

Field type: float

Gets the Y part of this 3D unit-vector.

Field type: float

Z

Full Usage: Z

Field type: float

Gets the Z part of this 3D unit-vector.

Field type: float

Instance members

Instance member Description

this.AsString

Full Usage: this.AsString

Returns: string

Format 3D unit-vector into string with nice floating point number formatting of X, Y and Z But without full type name as in v.ToString()

Returns: string

Static members

Static member Description

a *** b

Full Usage: a *** b

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of a 3D unit-vectors with a 3D vector. Returns a float. This float is the projected length of the 3D vector on the direction of the unit-vector.

a : Vec
b : UnitVec
Returns: float

a *** b

Full Usage: a *** b

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of a 3D unit-vectors with a 3D vector. Returns a float. This float is the projected length of the 3D vector on the direction of the unit-vector.

a : UnitVec
b : Vec
Returns: float

a *** b

Full Usage: a *** b

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of two 3D unit-vectors. Returns a float. This float is the Cosine of the angle between the two 3D vectors.

a : UnitVec
b : UnitVec
Returns: float

f * a

Full Usage: f * a

Parameters:
Returns: Vec
Modifiers: inline

Multiplies a scalar with a 3D unit-vector, also called scaling a vector. Returns a new (non-unitized) 3D vector.

f : float
a : UnitVec
Returns: Vec

a * f

Full Usage: a * f

Parameters:
Returns: Vec
Modifiers: inline

Multiplies a 3D unit-vector with a scalar, also called scaling a vector. Returns a new (non-unitized) 3D vector.

a : UnitVec
f : float
Returns: Vec

a + b

Full Usage: a + b

Parameters:
Returns: Vec
Modifiers: inline

Add a 3D unit-vectors and a 3D vector together. Returns a new (non-unitized) 3D vector.

a : UnitVec
b : Vec
Returns: Vec

a + b

Full Usage: a + b

Parameters:
Returns: Vec
Modifiers: inline

Add a 3D vectors and a 3D unit-vector together. Returns a new (non-unitized) 3D vector.

a : Vec
b : UnitVec
Returns: Vec

a + b

Full Usage: a + b

Parameters:
Returns: Vec
Modifiers: inline

Add two 3D unit-vectors together. Returns a new (non-unitized) 3D vector.

a : UnitVec
b : UnitVec
Returns: Vec

a - b

Full Usage: a - b

Parameters:
Returns: Vec
Modifiers: inline

Subtract a 3D unit-vectors from a 3D vector. Returns a new (non-unitized) 3D vector.

a : Vec
b : UnitVec
Returns: Vec

a - b

Full Usage: a - b

Parameters:
Returns: Vec
Modifiers: inline

Subtract a 3D vectors from a 3D unit-vector. Returns a new (non-unitized) 3D vector.

a : UnitVec
b : Vec
Returns: Vec

a - b

Full Usage: a - b

Parameters:
Returns: Vec
Modifiers: inline

Subtract one 3D unit-vectors from another. Returns a new (non-unitized) 3D vector.

a : UnitVec
b : UnitVec
Returns: Vec

v / f

Full Usage: v / f

Parameters:
Returns: Vec
Modifiers: inline

Divides a 3D unit-vector by a scalar, also be called dividing/scaling a vector. Returns a new (non-unitized) 3D vector.

v : UnitVec
f : float
Returns: Vec

~-v

Full Usage: ~-v

Parameters:
Returns: UnitVec
Modifiers: inline

Negate or inverse a 3D unit-vectors. Returns a new 3D unit-vector.

v : UnitVec
Returns: UnitVec

UnitVec.create (x, y, z)

Full Usage: UnitVec.create (x, y, z)

Parameters:
    x : float
    y : float
    z : float

Returns: UnitVec
Modifiers: inline

Create 3D unit-vector. Does the unitizing too.

x : float
y : float
z : float
Returns: UnitVec

UnitVec.createUnchecked v

Full Usage: UnitVec.createUnchecked v

Parameters:
Returns: UnitVec
Modifiers: inline

For use as a faster internal constructor. Requires correct input of unitized values.

v : Vec
Returns: UnitVec

UnitVec.createUnchecked (x, y, z)

Full Usage: UnitVec.createUnchecked (x, y, z)

Parameters:
    x : float
    y : float
    z : float

Returns: UnitVec
Modifiers: inline

For use as a faster internal constructor. Requires correct input of unitized values.

x : float
y : float
z : float
Returns: UnitVec

UnitVec.cross (a, b)

Full Usage: UnitVec.cross (a, b)

Parameters:
Returns: Vec
Modifiers: inline

The Cross Product. It is also known as the Determinant, Wedge Product or Outer Product. The resulting vector is perpendicular to both input vectors. The length of this resulting vector is the squared area of the parallelogram spanned by the input vectors. Its direction follows the right-hand rule. A x B = |A| * |B| * sin(angle)

a : UnitVec
b : UnitVec
Returns: Vec

UnitVec.dot (a, b)

Full Usage: UnitVec.dot (a, b)

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of two 3D unit-vectors. Returns a float. This float of unit-vectors is the Cosine of the angle between the two vectors.

a : UnitVec
b : UnitVec
Returns: float

UnitVec.failedCreate (x, y, z)

Full Usage: UnitVec.failedCreate (x, y, z)

Parameters:
    x : float
    y : float
    z : float

Returns: 'a
x : float
y : float
z : float
Returns: 'a

Type something to start searching.