Header menu logo Euclid

Vec Type

An immutable 3D vector of any length. Made up from 3 floats: X, Y, and Z. 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. (3D unit-vectors of length 1.0 are called 'UnitVec' ) (2D vectors are called 'Vc' )

Record fields

Record Field Description

X

Full Usage: X

Field type: float

Gets the X part of this 3D vector.

Field type: float

Y

Full Usage: Y

Field type: float

Gets the Y part of this 3D vector.

Field type: float

Z

Full Usage: Z

Field type: float

Gets the Z part of this 3D vector.

Field type: float

Constructors

Constructor Description

Vec(x, y, z)

Full Usage: Vec(x, y, z)

Parameters:
    x : float
    y : float
    z : float

Returns: Vec

Create a new 3D vector with any length. Made up from 3 floats: X, Y, and Z.

x : float
y : float
z : float
Returns: Vec

Instance members

Instance member Description

this.AsString

Full Usage: this.AsString

Returns: string

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

Returns: string

this.Length

Full Usage: this.Length

Returns: float
Modifiers: inline

Returns the length of the 3D vector.

Returns: float

this.LengthSq

Full Usage: this.LengthSq

Returns: float
Modifiers: inline

Returns the squared length of the 3D vector. The square length is faster to calculate and often good enough for use cases such as sorting vectors by length.

Returns: float

Static members

Static member Description

a *** b

Full Usage: a *** b

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of two 3D vectors. Returns a float.

a : Vec
b : Vec
Returns: float

f * a

Full Usage: f * a

Parameters:
    f : float
    a : Vec

Returns: Vec
Modifiers: inline

Multiplies a scalar with a 3D vector, also called scaling a vector. Returns a new 3D vector.

f : float
a : Vec
Returns: Vec

a * f

Full Usage: a * f

Parameters:
    a : Vec
    f : float

Returns: Vec
Modifiers: inline

Multiplies a 3D vector with a scalar, also called scaling a vector. Returns a new 3D vector.

a : Vec
f : float
Returns: Vec

a + b

Full Usage: a + b

Parameters:
Returns: Vec
Modifiers: inline

Add two 3D vectors together. Returns a new 3D vector.

a : Vec
b : Vec
Returns: Vec

a - b

Full Usage: a - b

Parameters:
Returns: Vec
Modifiers: inline

Subtract one 3D vectors from another. Returns a new 3D vector.

a : Vec
b : Vec
Returns: Vec

v / f

Full Usage: v / f

Parameters:
    v : Vec
    f : float

Returns: Vec
Modifiers: inline

Divides a 3D vector by a scalar, also be called dividing/scaling a vector. Returns a new 3D vector.

v : Vec
f : float
Returns: Vec

~-v

Full Usage: ~-v

Parameters:
Returns: Vec
Modifiers: inline

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

v : Vec
Returns: Vec

Vec.DivideByInt(v, i)

Full Usage: Vec.DivideByInt(v, i)

Parameters:
    v : Vec
    i : int

Returns: Vec

Divides the vector by an integer. (This member is needed by Array.average and similar functions)

v : Vec
i : int
Returns: Vec

Vec.Zero

Full Usage: Vec.Zero

Returns: Vec
Modifiers: inline

Returns a zero length vector: Vec(0, 0, 0)

Returns: Vec

Vec.cross (a, b)

Full Usage: Vec.cross (a, b)

Parameters:
Returns: Vec
Modifiers: inline

The Cross product, of two 3D vectors. 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 : Vec
b : Vec
Returns: Vec

Vec.dot (a, b)

Full Usage: Vec.dot (a, b)

Parameters:
Returns: float
Modifiers: inline

Dot product, or scalar product of two 3D vectors. Returns a float.

a : Vec
b : Vec
Returns: float

Type something to start searching.