openTRI 0.1
Data Structures | Typedefs | Functions
4D Vectors

Data Structures

struct  triVec4
 4D float Vector (quaternion) More...
 
struct  triVec4S32
 4D signed int Vector (quaternion) More...
 
struct  triVec4U32
 4D unsigned int Vector More...
 
struct  triVec4S16
 4D signed short Vector More...
 
struct  triVec4U16
 4D unsigned short Vector More...
 
struct  triVec4S8
 4D signed char Vector More...
 
struct  triVec4U8
 4D unsigned char Vector More...
 

Typedefs

typedef struct triVec4 triVec4
 4D float Vector (quaternion)
 
typedef struct triVec4 triVec4f
 
typedef struct triVec4 triQuat
 
typedef struct triVec4S32 triVec4S32
 4D signed int Vector (quaternion)
 
typedef struct triVec4S32 triVec4i
 
typedef struct triVec4S32 triQuati
 
typedef struct triVec4U32 triVec4U32
 4D unsigned int Vector
 
typedef struct triVec4S16 triVec4S16
 4D signed short Vector
 
typedef struct triVec4U16 triVec4U16
 4D unsigned short Vector
 
typedef struct triVec4S8 triVec4S8
 4D signed char Vector
 
typedef struct triVec4U8 triVec4U8
 4D unsigned char Vector
 

Functions

triVec4ftriVec4Set (triVec4f *a, const triFloat x, const triFloat y, const triFloat z, const triFloat w)
 
triVec4ftriVec4Set3 (triVec4f *a, const triFloat x, const triFloat y, const triFloat z)
 
triVec4itriVec4Ceil (triVec4i *a, const triVec4f *b)
 
triVec4itriVec4Trunc (triVec4i *a, const triVec4f *b)
 
triVec4itriVec4Round (triVec4i *a, const triVec4f *b)
 
triVec4itriVec4Floor (triVec4i *a, const triVec4f *b)
 
triVec4ftriVec4i2f (triVec4f *a, const triVec4i *b)
 
triVec4ftriVec4Rndn3 (triVec4f *a)
 Random normal vector. More...
 
triVec4ftriVec4Rndn (triVec4f *a)
 Random normal vector. More...
 
triVec4ftriVec4Rnd (triVec4f *a)
 Random vector. More...
 
triVec4ftriVec4Rnd2 (triVec4f *a)
 Random vector. More...
 
triVec4ftriVec4Add (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Add Vectors. More...
 
triVec4ftriVec4Add3 (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Add Vectors. More...
 
triVec4ftriVec4Sub (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Subtract Vectors. More...
 
triVec4ftriVec4Sub3 (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Subtract Vectors. More...
 
triVec4ftriVec4Mul (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Multiply Vectors. More...
 
triVec4ftriVec4Mul3 (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Multiply Vectors. More...
 
triVec4ftriVec4Div (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Divide Vectors. More...
 
triVec4ftriVec4Div3 (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Divide Vectors. More...
 
triVec4ftriVec4Neg (triVec4f *a, const triVec4f *b)
 Negate Vector. More...
 
triVec4ftriVec4Neg3 (triVec4f *a, const triVec4f *b)
 Negate Vector. More...
 
triVec4ftriVec4Abs (triVec4f *a, const triVec4f *b)
 Absolute of Vector. More...
 
triVec4ftriVec4Clamp (triVec4f *a, const triVec4f *b, triFloat min, triFloat max)
 Clamp Vector. More...
 
triVec4ftriVec4Clamp3 (triVec4f *a, const triVec4f *b, triFloat min, triFloat max)
 Clamp Vector. More...
 
triVec4ftriVec4Min (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Minimum of Vectors. More...
 
triVec4ftriVec4Max (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Maximum of Vectors. More...
 
triFloat triVec4Sum (const triVec4f *a)
 Sum of components. More...
 
triFloat triVec4Sum3 (const triVec4f *a)
 Sum of components. More...
 
triFloat triVec4Avg (const triVec4f *a)
 Average of components. More...
 
triFloat triVec4Avg3 (const triVec4f *a)
 Average of components. More...
 
triVec4ftriVec4Sgn (triVec4f *a, const triVec4f *b)
 Vector sign. More...
 
triVec4ftriVec4Normalize (triVec4f *a, const triVec4f *b)
 Normalize Vector. More...
 
triVec4ftriVec4Normalize3 (triVec4f *a, const triVec4f *b)
 Normalize Vector. More...
 
triFloat triVec4Length (const triVec4f *a)
 Length of Vector. More...
 
triFloat triVec4Length3 (const triVec4f *a)
 Length of Vector. More...
 
triFloat triVec4SquareLength (const triVec4f *a)
 Square length of Vector. More...
 
triFloat triVec4SquareLength3 (const triVec4f *a)
 Square length of Vector. More...
 
triFloat triVec4Dist (const triVec4f *a, const triVec4f *b)
 Distance between Vectors. More...
 
triFloat triVec4Dist3 (const triVec4f *a, const triVec4f *b)
 Distance between Vectors. More...
 
triFloat triVec4SquareDist (const triVec4f *a, const triVec4f *b)
 Square distance between Vectors. More...
 
triFloat triVec4SquareDist3 (const triVec4f *a, const triVec4f *b)
 Square distance between Vectors. More...
 
triVec4ftriVec4Lerp (triVec4f *a, const triVec4f *b, const triVec4f *c, triFloat t)
 Linear interpolate between Vectors. More...
 
triVec4ftriVec4Lerp3 (triVec4f *a, const triVec4f *b, const triVec4f *c, triFloat t)
 Linear interpolate between Vectors. More...
 
triVec4ftriVec4Scale (triVec4f *a, const triVec4f *b, triFloat t)
 Scale Vector. More...
 
triVec4ftriVec4Scale3 (triVec4f *a, const triVec4f *b, triFloat t)
 Scale Vector. More...
 
triFloat triVec4Dot (const triVec4f *a, const triVec4f *b)
 Calculate Vector dotproduct. More...
 
triFloat triVec4Dot3 (const triVec4f *a, const triVec4f *b)
 Calculate Vector dotproduct. More...
 
triVec4ftriVec4Cross (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Calculate Vector crossproduct. More...
 
triVec4ftriVec4Reflect (triVec4f *a, const triVec4f *b, const triVec4f *c)
 Reflect Vector. More...
 
triVec4ftriVec4Refract (triVec4f *a, const triVec4f *b, const triVec4f *c, const triFloat eta)
 Refract Vector. More...
 

Detailed Description

Function Documentation

◆ triVec4Rndn3()

triVec4f * triVec4Rndn3 ( triVec4f a)

Random normal vector.

Creates a random unit vector lying on the 3D unit sphere. The fourth component lies in range [-1.0, 1.0[

Parameters
a- Pointer to destination vector
Returns
Pointer to a

◆ triVec4Rndn()

triVec4f * triVec4Rndn ( triVec4f a)

Random normal vector.

Creates a random unit vector lying on the unit sphere.

Parameters
a- Pointer to destination vector
Returns
Pointer to a

◆ triVec4Rnd()

triVec4f * triVec4Rnd ( triVec4f a)

Random vector.

Creates random components in range [0.0, 1.0[

Parameters
a- Pointer to destination vector
Returns
Pointer to a

◆ triVec4Rnd2()

triVec4f * triVec4Rnd2 ( triVec4f a)

Random vector.

Creates random components in range [-1.0, 1.0[

Parameters
a- Pointer to destination vector
Returns
Pointer to a

◆ triVec4Add()

triVec4f * triVec4Add ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Add Vectors.

a = b.x+c.x | b.y+c.y | b.z+c.z | b.w+c.w

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Add3()

triVec4f * triVec4Add3 ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Add Vectors.

a = b.x+c.x | b.y+c.y | b.z+c.z | b.w
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Sub()

triVec4f * triVec4Sub ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Subtract Vectors.

a = b.x-c.x | b.y-c.y | b.z-c.z | b.w-c.w

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Sub3()

triVec4f * triVec4Sub3 ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Subtract Vectors.

a = b.x-c.x | b.y-c.y | b.z-c.z | b.w
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Mul()

triVec4f * triVec4Mul ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Multiply Vectors.

a = b.x*c.x | b.y*c.y | b.z*c.z | b.w*c.w

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Mul3()

triVec4f * triVec4Mul3 ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Multiply Vectors.

a = b.x*c.x | b.y*c.y | b.z*c.z | b.w
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Div()

triVec4f * triVec4Div ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Divide Vectors.

a = b.x/c.x | b.y/c.y | b.z/c.z | b.w/c.w

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Div3()

triVec4f * triVec4Div3 ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Divide Vectors.

a = b.x/c.x | b.y/c.y | b.z/c.z | b.w
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Neg()

triVec4f * triVec4Neg ( triVec4f a,
const triVec4f b 
)

Negate Vector.

a = -b

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Neg3()

triVec4f * triVec4Neg3 ( triVec4f a,
const triVec4f b 
)

Negate Vector.

a = -b
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Abs()

triVec4f * triVec4Abs ( triVec4f a,
const triVec4f b 
)

Absolute of Vector.

a = abs(b.x) | abs(b.y) | abs(b.z) | abs(b.w)

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Clamp()

triVec4f * triVec4Clamp ( triVec4f a,
const triVec4f b,
triFloat  min,
triFloat  max 
)

Clamp Vector.

a = clamp(b.x,min,max) | clamp(b.y,min,max) | clamp(b.z,min,max) | clamp(b.w,min,max)

Parameters
a- Pointer to destination vector
b- Pointer to source vector
min- Minimum to clamp to
max- Maximum to clamp to
Returns
Pointer to a

◆ triVec4Clamp3()

triVec4f * triVec4Clamp3 ( triVec4f a,
const triVec4f b,
triFloat  min,
triFloat  max 
)

Clamp Vector.

a = clamp(b.x,min,max) | clamp(b.y,min,max) | clamp(b.z,min,max) | b.w

Parameters
a- Pointer to destination vector
b- Pointer to source vector
min- Minimum to clamp to
max- Maximum to clamp to
Returns
Pointer to a

◆ triVec4Min()

triVec4f * triVec4Min ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Minimum of Vectors.

a = min(b.x,c.x) | min(b.y,c.y) | min(b.z,c.z) | min(b.w,c.w)

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Max()

triVec4f * triVec4Max ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Maximum of Vectors.

a = max(b.x,c.x) | max(b.y,c.y) | max(b.z,c.z) | max(b.w,c.w)

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Sum()

triFloat triVec4Sum ( const triVec4f a)

Sum of components.

return (a.x + a.y + a.z + a.w)

Parameters
a- Pointer to source vector
Returns
Sum

◆ triVec4Sum3()

triFloat triVec4Sum3 ( const triVec4f a)

Sum of components.

return (a.x + a.y + a.z)
Vectors are treated as 3D vectors.

Parameters
a- Pointer to source vector
Returns
Sum

◆ triVec4Avg()

triFloat triVec4Avg ( const triVec4f a)

Average of components.

return (a.x + a.y + a.z + a.w)/4

Parameters
a- Pointer to source vector
Returns
Average

◆ triVec4Avg3()

triFloat triVec4Avg3 ( const triVec4f a)

Average of components.

return (a.x + a.y + a.z)/3
Vectors are treated as 3D vectors.

Parameters
a- Pointer to source vector
Returns
Average

◆ triVec4Sgn()

triVec4f * triVec4Sgn ( triVec4f a,
const triVec4f b 
)

Vector sign.

a = sgn(b.x) | sgn(b.y) | sgn(b.z) | sgn(b.w)

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Normalize()

triVec4f * triVec4Normalize ( triVec4f a,
const triVec4f b 
)

Normalize Vector.

a = b / sqrt(b.b)

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Normalize3()

triVec4f * triVec4Normalize3 ( triVec4f a,
const triVec4f b 
)

Normalize Vector.

a = b / sqrt(b.b)
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to source vector
Returns
Pointer to a

◆ triVec4Length()

triFloat triVec4Length ( const triVec4f a)

Length of Vector.

return sqrt( a.a )

Parameters
a- Pointer to source vector
Returns
Lenght

◆ triVec4Length3()

triFloat triVec4Length3 ( const triVec4f a)

Length of Vector.

return sqrt( a.a )
Vectors are treated as 3D vectors.

Parameters
a- Pointer to source vector
Returns
Lenght

◆ triVec4SquareLength()

triFloat triVec4SquareLength ( const triVec4f a)

Square length of Vector.

return a.a

Parameters
a- Pointer to source vector
Returns
Square lenght

◆ triVec4SquareLength3()

triFloat triVec4SquareLength3 ( const triVec4f a)

Square length of Vector.

return a.a
Vectors are treated as 3D vectors.

Parameters
a- Pointer to source vector
Returns
Square lenght

◆ triVec4Dist()

triFloat triVec4Dist ( const triVec4f a,
const triVec4f b 
)

Distance between Vectors.

return sqrt( (b-a).(b-a) )

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Distance

◆ triVec4Dist3()

triFloat triVec4Dist3 ( const triVec4f a,
const triVec4f b 
)

Distance between Vectors.

return sqrt( (b-a).(b-a) )
Vectors are treated as 3D vectors.

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Distance

◆ triVec4SquareDist()

triFloat triVec4SquareDist ( const triVec4f a,
const triVec4f b 
)

Square distance between Vectors.

return (b-a).(b-a)

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Square distance

◆ triVec4SquareDist3()

triFloat triVec4SquareDist3 ( const triVec4f a,
const triVec4f b 
)

Square distance between Vectors.

return (b-a).(b-a)
Vectors are treated as 3D vectors.

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Square distance

◆ triVec4Lerp()

triVec4f * triVec4Lerp ( triVec4f a,
const triVec4f b,
const triVec4f c,
triFloat  t 
)

Linear interpolate between Vectors.

a = b * (1 - t) + c * t

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
t- Scalar to interpolate with
Returns
Pointer to a

◆ triVec4Lerp3()

triVec4f * triVec4Lerp3 ( triVec4f a,
const triVec4f b,
const triVec4f c,
triFloat  t 
)

Linear interpolate between Vectors.

a = b * (1 - t) + c * t
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
t- Scalar to interpolate with
Returns
Pointer to a

◆ triVec4Scale()

triVec4f * triVec4Scale ( triVec4f a,
const triVec4f b,
triFloat  t 
)

Scale Vector.

a = b * t

Parameters
a- Pointer to destination vector
b- Pointer to source vector
t- Scalar to scale b with
Returns
Pointer to a

◆ triVec4Scale3()

triVec4f * triVec4Scale3 ( triVec4f a,
const triVec4f b,
triFloat  t 
)

Scale Vector.

a = b * t
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to source vector
t- Scalar to scale b with
Returns
Pointer to a

◆ triVec4Dot()

triFloat triVec4Dot ( const triVec4f a,
const triVec4f b 
)

Calculate Vector dotproduct.

return a.b

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Dotproduct of a and b

◆ triVec4Dot3()

triFloat triVec4Dot3 ( const triVec4f a,
const triVec4f b 
)

Calculate Vector dotproduct.

return a.b
Vectors are treated as 3D vectors.

Parameters
a- Pointer to first source vector
b- Pointer to second source vector
Returns
Dotproduct of a and b

◆ triVec4Cross()

triVec4f * triVec4Cross ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Calculate Vector crossproduct.

a = b x c
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to first source vector
c- Pointer to second source vector
Returns
Pointer to a

◆ triVec4Reflect()

triVec4f * triVec4Reflect ( triVec4f a,
const triVec4f b,
const triVec4f c 
)

Reflect Vector.

Reflect b on the normale c. a = b - 2*(b.c)*c
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to incoming vector
c- Pointer to surface normale
Returns
Pointer to a

◆ triVec4Refract()

triVec4f * triVec4Refract ( triVec4f a,
const triVec4f b,
const triVec4f c,
const triFloat  eta 
)

Refract Vector.

Refract b on the normale c as in Snell's law - eta = n1/n2.
Vectors are treated as 3D vectors.

Parameters
a- Pointer to destination vector
b- Pointer to incoming vector
c- Pointer to surface normale
eta- Relative refraction index n1/n2
Returns
Pointer to a