kzc_vector4.hpp File Reference

4D vector. More...

Classes

struct  KzcVector4
 Structure of 4D vector. More...
 

Functions

KZ_INLINE struct KzcVector4 kzcVector4 (kzFloat x, kzFloat y, kzFloat z, kzFloat w)
 Creates a 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4GetX (const struct KzcVector4 *vector)
 Gets the X component of a 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4GetY (const struct KzcVector4 *vector)
 Gets the Y component of a 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4GetZ (const struct KzcVector4 *vector)
 Gets the Z component of a 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4GetW (const struct KzcVector4 *vector)
 Gets the W component of a 4D vector. More...
 
KZ_INLINE kzFloatkzcVector4GetComponents (struct KzcVector4 *vector)
 Gets the underlying component array of a 4D vector. More...
 
KZ_INLINE void kzcVector4Set (struct KzcVector4 *vector, kzFloat x, kzFloat y, kzFloat z, kzFloat a)
 Sets values for 4D vector. More...
 
KZ_INLINE void kzcVector4SetX (struct KzcVector4 *vector, kzFloat x)
 Sets X component for 4D vector. More...
 
KZ_INLINE void kzcVector4SetY (struct KzcVector4 *vector, kzFloat y)
 Sets Y component for 4D vector. More...
 
KZ_INLINE void kzcVector4SetZ (struct KzcVector4 *vector, kzFloat z)
 Sets Z component for 4D vector. More...
 
KZ_INLINE void kzcVector4SetW (struct KzcVector4 *vector, kzFloat w)
 Sets W component for 4D vector. More...
 
KZ_INLINE void kzcVector4Add (const struct KzcVector4 *first, const struct KzcVector4 *second, struct KzcVector4 *targetVector)
 Adds two 4D vectors. More...
 
KZ_INLINE void kzcVector4Subtract (const struct KzcVector4 *first, const struct KzcVector4 *second, struct KzcVector4 *targetVector)
 Subtracts two 4D vectors. More...
 
KZ_INLINE void kzcVector4ComponentMultiply (const struct KzcVector4 *first, const struct KzcVector4 *second, struct KzcVector4 *targetVector)
 Component-multiplies two 4D vectors. More...
 
KZ_INLINE void kzcVector4ComponentDivide (const struct KzcVector4 *first, const struct KzcVector4 *second, struct KzcVector4 *targetVector)
 Component-divides two 4D vectors. More...
 
KZ_INLINE void kzcVector4ComponentModulo (const struct KzcVector4 *first, const struct KzcVector4 *second, struct KzcVector4 *targetVector)
 Component-modulo of two 4D vectors. More...
 
KZ_INLINE void kzcVector4ComponentAbs (const struct KzcVector4 *vector, struct KzcVector4 *out_vector)
 Abs of a 4D vector. More...
 
KZ_INLINE void kzcVector4ComponentCeil (const struct KzcVector4 *vector, struct KzcVector4 *out_vector)
 Ceil of a 4D vector. More...
 
KZ_INLINE void kzcVector4ComponentFloor (const struct KzcVector4 *vector, struct KzcVector4 *out_vector)
 Floor of a 4D vector. More...
 
KZ_INLINE void kzcVector4ComponentRound (const struct KzcVector4 *vector, struct KzcVector4 *out_vector)
 Round of a 4D vector. More...
 
KZ_INLINE void kzcVector4ComponentSqrt (const struct KzcVector4 *vector, struct KzcVector4 *out_vector)
 Square root of a 4D vector component-wise. More...
 
KZ_INLINE void kzcVector4ComponentPow (const struct KzcVector4 *vector, kzFloat exponent, struct KzcVector4 *out_vector)
 Raises a 4D vector to power of 'exponent' component-wise. More...
 
KZ_INLINE void kzcVector4Scale (const struct KzcVector4 *vector, kzFloat factor, struct KzcVector4 *targetVector)
 Scales 4D vector. More...
 
KZ_INLINE void kzcVector4Negate (const struct KzcVector4 *vector, struct KzcVector4 *targetVector)
 Negates 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4Dot (const struct KzcVector4 *left, const struct KzcVector4 *right)
 Calculates dot product of two 4D vectors. More...
 
KZ_INLINE kzFloat kzcVector4GetLengthSquared (const struct KzcVector4 *vector)
 Returns length squared of a 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4GetLength (const struct KzcVector4 *vector)
 Returns the length of 4D vector. More...
 
KZ_INLINE kzFloat kzcVector4Distance (const struct KzcVector4 *vector1, const struct KzcVector4 *vector2)
 Returns the distance between two 4D point vectors. More...
 
KZ_INLINE void kzcVector4Normalize (struct KzcVector4 *vector)
 Normalizes a 4D vector. More...
 
KZ_INLINE void kzcVector4Reflect (const struct KzcVector4 *vector, const struct KzcVector4 *axis, struct KzcVector4 *targetVector)
 Reflects a 4D vector according to given axis vector. More...
 
KZ_INLINE kzBool kzcVector4IsEqual (const struct KzcVector4 *first, const struct KzcVector4 *second)
 Checks if two 4D vectors are equal. More...
 
KZ_INLINE void kzcVector4Cross (const struct KzcVector4 *left, const struct KzcVector4 *right, struct KzcVector4 *targetVector)
 Calculates cross product of two vectors. More...
 
KZ_INLINE struct KzcVector4 kzcVector4ComponentMax (const struct KzcVector4 *vectorA, const struct KzcVector4 *vectorB)
 Returns the component maximum of two vectors. More...
 
KZ_INLINE struct KzcVector4 kzcVector4ComponentMin (const struct KzcVector4 *vectorA, const struct KzcVector4 *vectorB)
 Returns the component minimum of two vectors. More...
 
KZ_INLINE struct KzcVector4 kzcVector4ComponentStep (const struct KzcVector4 *vectorA, const struct KzcVector4 *vectorB)
 Returns the component-wise step() of two vectors. More...
 
void kzcVector4SetInvalid (struct KzcVector4 *vector)
 Sets the vector components to NaN. More...
 

Variables

KANZI_API const struct KzcVector4 KZC_VECTOR4_ZERO
 Constant zero 4D vector. More...
 
KANZI_API const struct KzcVector4 KZC_VECTOR4_X_AXIS
 Constant unit 4D vector for X axis. More...
 
KANZI_API const struct KzcVector4 KZC_VECTOR4_Y_AXIS
 Constant unit 4D vector for Y axis. More...
 
KANZI_API const struct KzcVector4 KZC_VECTOR4_Z_AXIS
 Constant unit 4D vector for Z axis. More...
 

Detailed Description

4D vector.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

KZ_INLINE struct KzcVector4 kzcVector4 ( kzFloat  x,
kzFloat  y,
kzFloat  z,
kzFloat  w 
)

Creates a 4D vector.

KZ_INLINE kzFloat kzcVector4GetX ( const struct KzcVector4 vector)

Gets the X component of a 4D vector.

KZ_INLINE kzFloat kzcVector4GetY ( const struct KzcVector4 vector)

Gets the Y component of a 4D vector.

KZ_INLINE kzFloat kzcVector4GetZ ( const struct KzcVector4 vector)

Gets the Z component of a 4D vector.

KZ_INLINE kzFloat kzcVector4GetW ( const struct KzcVector4 vector)

Gets the W component of a 4D vector.

KZ_INLINE kzFloat* kzcVector4GetComponents ( struct KzcVector4 vector)

Gets the underlying component array of a 4D vector.

KZ_INLINE void kzcVector4Set ( struct KzcVector4 vector,
kzFloat  x,
kzFloat  y,
kzFloat  z,
kzFloat  a 
)

Sets values for 4D vector.

KZ_INLINE void kzcVector4SetX ( struct KzcVector4 vector,
kzFloat  x 
)

Sets X component for 4D vector.

KZ_INLINE void kzcVector4SetY ( struct KzcVector4 vector,
kzFloat  y 
)

Sets Y component for 4D vector.

KZ_INLINE void kzcVector4SetZ ( struct KzcVector4 vector,
kzFloat  z 
)

Sets Z component for 4D vector.

KZ_INLINE void kzcVector4SetW ( struct KzcVector4 vector,
kzFloat  w 
)

Sets W component for 4D vector.

KZ_INLINE void kzcVector4Add ( const struct KzcVector4 first,
const struct KzcVector4 second,
struct KzcVector4 targetVector 
)

Adds two 4D vectors.

KZ_INLINE void kzcVector4Subtract ( const struct KzcVector4 first,
const struct KzcVector4 second,
struct KzcVector4 targetVector 
)

Subtracts two 4D vectors.

KZ_INLINE void kzcVector4ComponentMultiply ( const struct KzcVector4 first,
const struct KzcVector4 second,
struct KzcVector4 targetVector 
)

Component-multiplies two 4D vectors.

KZ_INLINE void kzcVector4ComponentDivide ( const struct KzcVector4 first,
const struct KzcVector4 second,
struct KzcVector4 targetVector 
)

Component-divides two 4D vectors.

KZ_INLINE void kzcVector4ComponentModulo ( const struct KzcVector4 first,
const struct KzcVector4 second,
struct KzcVector4 targetVector 
)

Component-modulo of two 4D vectors.

KZ_INLINE void kzcVector4ComponentAbs ( const struct KzcVector4 vector,
struct KzcVector4 out_vector 
)

Abs of a 4D vector.

KZ_INLINE void kzcVector4ComponentCeil ( const struct KzcVector4 vector,
struct KzcVector4 out_vector 
)

Ceil of a 4D vector.

KZ_INLINE void kzcVector4ComponentFloor ( const struct KzcVector4 vector,
struct KzcVector4 out_vector 
)

Floor of a 4D vector.

KZ_INLINE void kzcVector4ComponentRound ( const struct KzcVector4 vector,
struct KzcVector4 out_vector 
)

Round of a 4D vector.

KZ_INLINE void kzcVector4ComponentSqrt ( const struct KzcVector4 vector,
struct KzcVector4 out_vector 
)

Square root of a 4D vector component-wise.

KZ_INLINE void kzcVector4ComponentPow ( const struct KzcVector4 vector,
kzFloat  exponent,
struct KzcVector4 out_vector 
)

Raises a 4D vector to power of 'exponent' component-wise.

KZ_INLINE void kzcVector4Scale ( const struct KzcVector4 vector,
kzFloat  factor,
struct KzcVector4 targetVector 
)

Scales 4D vector.

KZ_INLINE void kzcVector4Negate ( const struct KzcVector4 vector,
struct KzcVector4 targetVector 
)

Negates 4D vector.

KZ_INLINE kzFloat kzcVector4Dot ( const struct KzcVector4 left,
const struct KzcVector4 right 
)

Calculates dot product of two 4D vectors.

KZ_INLINE kzFloat kzcVector4GetLengthSquared ( const struct KzcVector4 vector)

Returns length squared of a 4D vector.

KZ_INLINE kzFloat kzcVector4GetLength ( const struct KzcVector4 vector)

Returns the length of 4D vector.

KZ_INLINE kzFloat kzcVector4Distance ( const struct KzcVector4 vector1,
const struct KzcVector4 vector2 
)

Returns the distance between two 4D point vectors.

KZ_INLINE void kzcVector4Normalize ( struct KzcVector4 vector)

Normalizes a 4D vector.

KZ_INLINE void kzcVector4Reflect ( const struct KzcVector4 vector,
const struct KzcVector4 axis,
struct KzcVector4 targetVector 
)

Reflects a 4D vector according to given axis vector.

Axis has to be normalized.

KZ_INLINE kzBool kzcVector4IsEqual ( const struct KzcVector4 first,
const struct KzcVector4 second 
)

Checks if two 4D vectors are equal.

KZ_INLINE void kzcVector4Cross ( const struct KzcVector4 left,
const struct KzcVector4 right,
struct KzcVector4 targetVector 
)

Calculates cross product of two vectors.

Uses only the first 3 parts of the vectors and sets last component to zero.

KZ_INLINE struct KzcVector4 kzcVector4ComponentMax ( const struct KzcVector4 vectorA,
const struct KzcVector4 vectorB 
)

Returns the component maximum of two vectors.

KZ_INLINE struct KzcVector4 kzcVector4ComponentMin ( const struct KzcVector4 vectorA,
const struct KzcVector4 vectorB 
)

Returns the component minimum of two vectors.

KZ_INLINE struct KzcVector4 kzcVector4ComponentStep ( const struct KzcVector4 vectorA,
const struct KzcVector4 vectorB 
)

Returns the component-wise step() of two vectors.

void kzcVector4SetInvalid ( struct KzcVector4 vector)

Sets the vector components to NaN.

Variable Documentation

KANZI_API const struct KzcVector4 KZC_VECTOR4_ZERO

Constant zero 4D vector.

KANZI_API const struct KzcVector4 KZC_VECTOR4_X_AXIS

Constant unit 4D vector for X axis.

KANZI_API const struct KzcVector4 KZC_VECTOR4_Y_AXIS

Constant unit 4D vector for Y axis.

KANZI_API const struct KzcVector4 KZC_VECTOR4_Z_AXIS

Constant unit 4D vector for Z axis.