module Vectors

This is the documentation for Enlighten.

module Vectors

Functions

Name

Description

Name

Description

Abs(v128Param)

Returns a vector with the Abs function applied to all 4 elements.

EqualWithinEpsilon(v128Param, v128Param, v128Param)

Returns true if all elements of a and b are within g_VecEpsilon of each other.

GetV128FromString(const C *)

Parses a v128 from the given string.

GetV128FromStringXYZ(const C *, float)

Parses a v128 from the given string, ignoring the W-component and instead setting it to the given value.

IsFinite(v128Param)

Returns true if all of the 4 elements of v are finite.

IsNan(v128Param)

Returns true if any of the 4 elements of v are NANs.

Lerp(v128Param, v128Param, v128Param)

Linearly interpolated between the corresponding components of a and b.

Max(const v128 &, const v128 &)

Returns a vector where each element has the maximum value of the corresponding values in a and b NOTE - the Min3 template function will work with the v128 type as well.

Min(const v128 &, const v128 &)

Returns a vector where each element has the minimum value of the corresponding values in a and b NOTE - the Min3 template function will work with the v128 type as well.

operator-(Geo::v128Param, Geo::v128Param)

Operator - (component-wise subtraction)

operator-(Geo::v128Param)

The unary - operator. Equivalent to (VZero() - v);.

operator*(Geo::v128Param, Geo::v128Param)

Operator * (component-wise multiplication)

operator*=(Geo::v128 &, Geo::v128Param)

Inplace *.

operator/(Geo::v128Param, Geo::v128Param)

Operator / (component-wise division)

operator/=(Geo::v128 &, Geo::v128Param)

Inplace /.

operator+(Geo::v128Param, Geo::v128Param)

Operator + (component-wise addition)

operator+(Geo::v128Param)

The unary + operator (effectively a no-op)

operator+=(Geo::v128 &, Geo::v128Param)

Inplace +.

operator-=(Geo::v128 &, Geo::v128Param)

Inplace -.

V128ToUtf8String(const Geo::v128 &)

Creates a GeoString representation of the vector (space-separated).

V128ToUtf8StringXYZ(const Geo::v128 &)

Creates a GeoString representation of the vector (space-separated).

VBroadcast(float)

Construct a v128 by broadcasting a float into all elements.

VBroadcastInt(s32)

Construct a v128 by converting an integer to a float and broadcasting it into all elements.

VCeil(v128Param)

Return ceil(v).

VCompareEquals(v128Param, v128Param)

Compares all corresponding elements to see if a == b (exact equals).

VCompareGE(v128Param, v128Param)

Compares all corresponding elements to see if a >= b.

VCompareGT(v128Param, v128Param)

Compares all corresponding elements to see if a > b.

VCompareIsFinite(v128Param)

Tests all elements of v to see if they are finite or not.

VCompareIsNan(v128Param)

Tests all elements of v to see if any of them are NANs.

VCompareLE(v128Param, v128Param)

Compares all corresponding elements to see if a <= b.

VCompareLT(v128Param, v128Param)

Compares all corresponding elements to see if a < b.

VCompareWithFlagsEquals(v128Param, v128Param, u32 &)

Compares all corresponding elements to see if a == b (exact equals).

VCompareWithFlagsGE(v128Param, v128Param, u32 &)

Compares all corresponding elements to see if a >= b.

VCompareWithFlagsGT(v128Param, v128Param, u32 &)

Compares all corresponding elements to see if a > b.

VCompareWithFlagsLE(v128Param, v128Param, u32 &)

Compares all corresponding elements to see if a <= b.

VCompareWithFlagsLT(v128Param, v128Param, u32 &)

Compares all corresponding elements to see if a < b.

VConstruct(float, float, float, float)

Construct a v128 from 4 floats. Fairly slow.

VConstructBitwise(u32, u32, u32, u32)

Re-intreprets 4 ints as floats and construct a vector from them.

VCross3(v128Param, v128Param)

Cross the first 3 elements of each.

VCross3ZeroW(v128Param, v128Param)

Cross the first 3 elements of each.

VFrac(Geo::v128Param)

Returns the fractional part of each element of v.

VGetMaskNotSignBit()

Returns a mask with everything but the 4 sign bits set.

VGetMaskSignBit()

Returns a mask with just the 4 sign bits set.

VLoadAligned(const float *)

Load a 4-float array from 16-byte aligned memory.

VLoadUnaligned(const float *)

Load a 4-float array from arbitrarily aligned memory. Cannot be null.

VMadd(Geo::v128Param, Geo::v128Param, Geo::v128Param)

This is a vector multiply accumulate operation returning (a * b) + c.

VNegate(v128Param)

Return -v. You can use the operator overload instead if you prefer.

VOpAnd(Geo::v128Param, Geo::v128Param)

This is a bitwise & operation.

VOpOnesCompl(Geo::v128Param)

This is a bitwise ~ operation.

VOpOr(Geo::v128Param, Geo::v128Param)

This is a bitwise | operation.

VOpXor(Geo::v128Param, Geo::v128Param)

This is a bitwise ^ operation.

VPackX4(const Geo::v128 &, const Geo::v128 &, const Geo::v128 &, const Geo::v128 &)

Packs the X component from each of the four vectors into a single vector.

VPerpendicular(v128Param, float)

Returns a vector perpendicular to v (with one of its components being zero).

VRecip(v128Param)

Return 1.f / v. (inaccurate)

VRecipFast(v128Param)

Return 1.f / v. (fast approximate where available. If not, implemented as VRecip)

VRecipSqrt(v128Param)

Return 1.f / sqrt(v). (inaccurate)

VRecipSqrtFast(v128Param)

Return 1.f / sqrt(v). (inaccurate)

VReverse(v128Param)

Reverses the order of the components from xyzw to wzyx.

VShuffle(v128Param, int, int, int, int)

Returns the specified permutation of the parameter vector. Any permutation is valid.

VSqrt(v128Param)

Return sqrt(v). (more inaccurate than the reciprocal version on non-sse hardware)

VTestFlagsAllFalse(u32)

Tests the flags produced by the VCompareWithFlags* operations.

VTestFlagsAllTrue(u32)

Tests the flags produced by the VCompareWithFlags* operations.

VTestFlagsSomeFalse(u32)

Tests the flags produced by the VCompareWithFlags* operations.

VTestFlagsSomeTrue(u32)

Tests the flags produced by the VCompareWithFlags* operations.

VZero()

A fully-zeroed out vector.

Variables

Name

Description

Name

Description

const v128 g_VecEpsilon = VBroadcast(0.001f)

This has the value of g_VecEpsilonF broadcast into all elements.

const float g_VecEpsilonF = 0.001f

A general epsilon for use with the IsUnitLength function.

const u32 g_VecMaskFalse = 0x00000000

A mask value of 'false' = 0x00000000.

const u32 g_VecMaskTrue = 0xffffffff

A mask value of 'true' = 0xffffffff.

const v128 g_VecNormaliseEpsilon = VBroadcast(1e-35f)

An internal epsilon used inside the vector normalisation functions.

const Geo::v128 g_VFours

Some common useful constants.

const Geo::v128 g_VHalves

Some common useful constants.

const Geo::v128 g_VMinusOnes

Some common useful constants.

const Geo::v128 g_VMinusOneTwoEights

Some common useful constants.

const Geo::v128 g_VOneOverOneTwoSevens

Some common useful constants.

const Geo::v128 g_VOneOverPi

Some common useful constants.

const Geo::v128 g_VOneOverTwoFives

Some common useful constants.

const Geo::v128 g_VOneOverTwoPi

Some common useful constants.

const Geo::v128 g_VOnes

Some common useful constants.

const Geo::v128 g_VOneTwoSevens

Some common useful constants.

const Geo::v128 g_VPi

Some common useful constants.

const Geo::v128 g_VQuarters

Some common useful constants.

const Geo::v128 g_VThirds

Some common useful constants.

const Geo::v128 g_VThrees

Some common useful constants.

const Geo::v128 g_VTwoFiveFives

Some common useful constants.

const Geo::v128 g_VTwos

Some common useful constants.

const Geo::v128 g_VZero

Some common useful constants.

Enums

Name

Description

Name

Description

eVShufflePosition

Shuffle constants for the GEO_VSHUFFLE macro.

Defines

Name

Description

Name

Description

GEO_VSHUFFLE VShuffle(v, x, y, z, w)

Returns the specified permutation of the parameter vector.



GEO_FORCE_INLINE v128 Geo::Abs


public: v128 Abs
(
    v128Param a
)


Returns a vector with the Abs function applied to all 4 elements.



bool Geo::EqualWithinEpsilon


public: bool EqualWithinEpsilon
(
    v128Param a,
    v128Param b,
    v128Param epsilon
)


Returns true if all elements of a and b are within g_VecEpsilon of each other.

You may specify an epsilon vector that contains different epsilon values in each element if you wish.



Geo::v128 GEO_CALL Geo::GetV128FromString


public: Geo::v128GEO_CALL GetV128FromString
(
    const C * str
)


Parses a v128 from the given string.



Geo::v128 GEO_CALL Geo::GetV128FromStringXYZ


public: Geo::v128GEO_CALL GetV128FromStringXYZ
(
    const C * str,
    float w
)


Parses a v128 from the given string, ignoring the W-component and instead setting it to the given value.



bool Geo::IsFinite


public: bool IsFinite
(
    v128Param v
)


Returns true if all of the 4 elements of v are finite.

TODO - this function doesn't detect INFs yet!



bool Geo::IsNan


public: bool IsNan
(
    v128Param v
)


Returns true if any of the 4 elements of v are NANs.



v128 Geo::Lerp


public: v128 Lerp
(
    v128Param a,
    v128Param b,
    v128Param s
)


Linearly interpolated between the corresponding components of a and b.

s is the interpolation factor, typically having values between 0 -> 1.



GEO_FORCE_INLINE v128 Geo::Max


public: v128 Max
(
    const v128 & a,
    const v128 & b
)


Returns a vector where each element has the maximum value of the corresponding values in a and b NOTE - the Min3 template function will work with the v128 type as well.



GEO_FORCE_INLINE v128 Geo::Min


public: v128 Min
(
    const v128 & a,
    const v128 & b
)


Returns a vector where each element has the minimum value of the corresponding values in a and b NOTE - the Min3 template function will work with the v128 type as well.



GEO_FORCE_INLINE Geo::v128 Geo::operator-


public: Geo::v128 operator-
(
    Geo::v128Param lhs,
    Geo::v128Param rhs
)


Operator - (component-wise subtraction)



GEO_FORCE_INLINE Geo::v128 Geo::operator-


public: Geo::v128 operator-
(
    Geo::v128Param v
)


The unary - operator. Equivalent to (VZero() - v);.



GEO_FORCE_INLINE Geo::v128 Geo::operator*


public: Geo::v128 operator*
(
    Geo::v128Param lhs,
    Geo::v128Param rhs
)


Operator * (component-wise multiplication)



GEO_FORCE_INLINE Geo::v128 & Geo::operator*=


public: Geo::v128 & operator*=
(
    Geo::v128 & lhs,
    Geo::v128Param rhs)