kzc_vector3.hpp File Reference

3D Vector. More...

Classes

struct  KzcVector3
 Structure of 3D vector. More...
 

Functions

KZ_INLINE struct KzcVector3 kzcVector3 (kzFloat x, kzFloat y, kzFloat z)
 Creates a 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3GetX (const struct KzcVector3 *vector)
 Gets the X component of a 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3GetY (const struct KzcVector3 *vector)
 Gets the Y component of a 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3GetZ (const struct KzcVector3 *vector)
 Gets the Z component of a 3D vector. More...
 
KZ_INLINE kzFloatkzcVector3GetComponents (struct KzcVector3 *vector)
 Gets the underlying component array of a 3D vector. More...
 
KZ_INLINE void kzcVector3Set (struct KzcVector3 *vector, kzFloat x, kzFloat y, kzFloat z)
 Sets values for 3D vector. More...
 
KZ_INLINE void kzcVector3SetX (struct KzcVector3 *vector, kzFloat x)
 Sets X component for 3D vector. More...
 
KZ_INLINE void kzcVector3SetY (struct KzcVector3 *vector, kzFloat y)
 Sets Y component for 3D vector. More...
 
KZ_INLINE void kzcVector3SetZ (struct KzcVector3 *vector, kzFloat z)
 Sets Z component for 3D vector. More...
 
KZ_INLINE void kzcVector3Add (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Adds two 3D vectors. More...
 
KZ_INLINE void kzcVector3Subtract (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Subtracts two 3D vectors. More...
 
KZ_INLINE void kzcVector3ComponentMultiply (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Component-multiplies two 3D vectors. More...
 
KZ_INLINE void kzcVector3ComponentDivide (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Component-divides two 3D vectors. More...
 
KZ_INLINE void kzcVector3ComponentModulo (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Component-modulo of two 3D vectors. More...
 
KZ_INLINE void kzcVector3ComponentAbs (const struct KzcVector3 *vector, struct KzcVector3 *out_vector)
 Abs of a 3D vector. More...
 
KZ_INLINE void kzcVector3ComponentCeil (const struct KzcVector3 *vector, struct KzcVector3 *out_vector)
 Ceil of a 3D vector. More...
 
KZ_INLINE void kzcVector3ComponentFloor (const struct KzcVector3 *vector, struct KzcVector3 *out_vector)
 Floor of a 3D vector. More...
 
KZ_INLINE void kzcVector3ComponentRound (const struct KzcVector3 *vector, struct KzcVector3 *out_vector)
 Round of a 3D vector. More...
 
KZ_INLINE void kzcVector3ComponentSqrt (const struct KzcVector3 *vector, struct KzcVector3 *out_vector)
 Square root of a 3D vector component-wise. More...
 
KZ_INLINE void kzcVector3ComponentPow (const struct KzcVector3 *vector, kzFloat exponent, struct KzcVector3 *out_vector)
 Raises a 3D vector to power of 'exponent' component-wise. More...
 
KZ_INLINE void kzcVector3Scale (const struct KzcVector3 *vector, kzFloat factor, struct KzcVector3 *targetVector)
 Scales 3D vector. More...
 
KZ_INLINE void kzcVector3Negate (const struct KzcVector3 *vector, struct KzcVector3 *targetVector)
 Negates 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3Dot (const struct KzcVector3 *first, const struct KzcVector3 *second)
 Calculates dot product of two 3D vectors. More...
 
KZ_INLINE kzFloat kzcVector3GetLengthSquared (const struct KzcVector3 *vector)
 Returns length squared of a 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3GetLength (const struct KzcVector3 *vector)
 Returns length of a 3D vector. More...
 
KZ_INLINE kzFloat kzcVector3Distance (const struct KzcVector3 *vector1, const struct KzcVector3 *vector2)
 Returns the distance between two 3D point vectors. More...
 
KZ_INLINE void kzcVector3Normalize (struct KzcVector3 *vector)
 Normalizes a 3D vector. More...
 
KZ_INLINE void kzcVector3ProjectVector3 (const struct KzcVector3 *vectorA, const struct KzcVector3 *vectorB, struct KzcVector3 *result)
 Projects vector B onto vector A. More...
 
KZ_INLINE void kzcVector3Reflect (const struct KzcVector3 *vector, const struct KzcVector3 *axis, struct KzcVector3 *targetVector)
 Reflects a 3D vector according to given axis vector. More...
 
KZ_INLINE kzBool kzcVector3IsEqual (const struct KzcVector3 *first, const struct KzcVector3 *second)
 Checks if two vectors are equal. More...
 
KZ_INLINE struct KzcVector4 kzcVector3ToVector4 (const struct KzcVector3 *vector)
 Converts a 3D vector to a 4D vector. More...
 
KZ_INLINE struct KzcVector3 kzcVector3FromVector4 (const struct KzcVector4 *vector)
 Converts a 4D vector to a 3D vector. More...
 
KZ_INLINE void kzcVector3Cross (const struct KzcVector3 *first, const struct KzcVector3 *second, struct KzcVector3 *targetVector)
 Calculates cross product of two 3D vectors. More...
 
KZ_INLINE void kzcVector3GetOrthogonalVector (const struct KzcVector3 *source, struct KzcVector3 *out_result)
 Finds some vector that is orthogonal to the given vector. More...
 
KZ_INLINE struct KzcVector3 kzcVector3ComponentMax (const struct KzcVector3 *vectorA, const struct KzcVector3 *vectorB)
 Returns the component maximum of two vectors. More...
 
KZ_INLINE struct KzcVector3 kzcVector3ComponentMin (const struct KzcVector3 *vectorA, const struct KzcVector3 *vectorB)
 Returns the component minimum of two vectors. More...
 
KZ_INLINE struct KzcVector3 kzcVector3ComponentStep (const struct KzcVector3 *vectorA, const struct KzcVector3 *vectorB)
 Returns the component-wise step() of two vectors. More...
 
void kzcVector3SetInvalid (struct KzcVector3 *vector)
 Sets the vector components to NaN. More...
 

Variables

KANZI_API const struct KzcVector3 KZC_VECTOR3_ZERO
 Constant zero 3D vector. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_X_AXIS
 Constant unit 3D vector for X axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_Y_AXIS
 Constant unit 3D vector for Y axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_Z_AXIS
 Constant unit 3D vector for Z axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_X_AXIS_NEGATIVE
 Constant unit 3D vector for negative X axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_Y_AXIS_NEGATIVE
 Constant unit 3D vector for negative Y axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_Z_AXIS_NEGATIVE
 Constant unit 3D vector for negative Z axis. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_MAXIMUM
 Constant 3D vector with each field at maximum. More...
 
KANZI_API const struct KzcVector3 KZC_VECTOR3_MINIMUM
 Constant 3D vector with each field at minimum. More...
 

Detailed Description

3D Vector.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

KZ_INLINE struct KzcVector3 kzcVector3 ( kzFloat  x,
kzFloat  y,
kzFloat  z 
)

Creates a 3D vector.

KZ_INLINE kzFloat kzcVector3GetX ( const struct KzcVector3 vector)

Gets the X component of a 3D vector.

KZ_INLINE kzFloat kzcVector3GetY ( const struct KzcVector3 vector)

Gets the Y component of a 3D vector.

KZ_INLINE kzFloat kzcVector3GetZ ( const struct KzcVector3 vector)

Gets the Z component of a 3D vector.

KZ_INLINE kzFloat* kzcVector3GetComponents ( struct KzcVector3 vector)

Gets the underlying component array of a 3D vector.

KZ_INLINE void kzcVector3Set ( struct KzcVector3 vector,
kzFloat  x,
kzFloat  y,
kzFloat  z 
)

Sets values for 3D vector.

KZ_INLINE void kzcVector3SetX ( struct KzcVector3 vector,
kzFloat  x 
)

Sets X component for 3D vector.

KZ_INLINE void kzcVector3SetY ( struct KzcVector3 vector,
kzFloat  y 
)

Sets Y component for 3D vector.

KZ_INLINE void kzcVector3SetZ ( struct KzcVector3 vector,
kzFloat  z 
)

Sets Z component for 3D vector.

KZ_INLINE void kzcVector3Add ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Adds two 3D vectors.

KZ_INLINE void kzcVector3Subtract ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Subtracts two 3D vectors.

KZ_INLINE void kzcVector3ComponentMultiply ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Component-multiplies two 3D vectors.

KZ_INLINE void kzcVector3ComponentDivide ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Component-divides two 3D vectors.

KZ_INLINE void kzcVector3ComponentModulo ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Component-modulo of two 3D vectors.

KZ_INLINE void kzcVector3ComponentAbs ( const struct KzcVector3 vector,
struct KzcVector3 out_vector 
)

Abs of a 3D vector.

KZ_INLINE void kzcVector3ComponentCeil ( const struct KzcVector3 vector,
struct KzcVector3 out_vector 
)

Ceil of a 3D vector.

KZ_INLINE void kzcVector3ComponentFloor ( const struct KzcVector3 vector,
struct KzcVector3 out_vector 
)

Floor of a 3D vector.

KZ_INLINE void kzcVector3ComponentRound ( const struct KzcVector3 vector,
struct KzcVector3 out_vector 
)

Round of a 3D vector.

KZ_INLINE void kzcVector3ComponentSqrt ( const struct KzcVector3 vector,
struct KzcVector3 out_vector 
)

Square root of a 3D vector component-wise.

KZ_INLINE void kzcVector3ComponentPow ( const struct KzcVector3 vector,
kzFloat  exponent,
struct KzcVector3 out_vector 
)

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

KZ_INLINE void kzcVector3Scale ( const struct KzcVector3 vector,
kzFloat  factor,
struct KzcVector3 targetVector 
)

Scales 3D vector.

KZ_INLINE void kzcVector3Negate ( const struct KzcVector3 vector,
struct KzcVector3 targetVector 
)

Negates 3D vector.

KZ_INLINE kzFloat kzcVector3Dot ( const struct KzcVector3 first,
const struct KzcVector3 second 
)

Calculates dot product of two 3D vectors.

KZ_INLINE kzFloat kzcVector3GetLengthSquared ( const struct KzcVector3 vector)

Returns length squared of a 3D vector.

KZ_INLINE kzFloat kzcVector3GetLength ( const struct KzcVector3 vector)

Returns length of a 3D vector.

KZ_INLINE kzFloat kzcVector3Distance ( const struct KzcVector3 vector1,
const struct KzcVector3 vector2 
)

Returns the distance between two 3D point vectors.

KZ_INLINE void kzcVector3Normalize ( struct KzcVector3 vector)

Normalizes a 3D vector.

KZ_INLINE void kzcVector3ProjectVector3 ( const struct KzcVector3 vectorA,
const struct KzcVector3 vectorB,
struct KzcVector3 result 
)

Projects vector B onto vector A.

KZ_INLINE void kzcVector3Reflect ( const struct KzcVector3 vector,
const struct KzcVector3 axis,
struct KzcVector3 targetVector 
)

Reflects a 3D vector according to given axis vector.

Axis has to be normalized.

KZ_INLINE kzBool kzcVector3IsEqual ( const struct KzcVector3 first,
const struct KzcVector3 second 
)

Checks if two vectors are equal.

KZ_INLINE struct KzcVector4 kzcVector3ToVector4 ( const struct KzcVector3 vector)

Converts a 3D vector to a 4D vector.

W will be zero.

KZ_INLINE struct KzcVector3 kzcVector3FromVector4 ( const struct KzcVector4 vector)

Converts a 4D vector to a 3D vector.

W will be discarded.

KZ_INLINE void kzcVector3Cross ( const struct KzcVector3 first,
const struct KzcVector3 second,
struct KzcVector3 targetVector 
)

Calculates cross product of two 3D vectors.

KZ_INLINE void kzcVector3GetOrthogonalVector ( const struct KzcVector3 source,
struct KzcVector3 out_result 
)

Finds some vector that is orthogonal to the given vector.

Length of the source vector must be 1. Resulting vector is not necessarily of unit length.

KZ_INLINE struct KzcVector3 kzcVector3ComponentMax ( const struct KzcVector3 vectorA,
const struct KzcVector3 vectorB 
)

Returns the component maximum of two vectors.

KZ_INLINE struct KzcVector3 kzcVector3ComponentMin ( const struct KzcVector3 vectorA,
const struct KzcVector3 vectorB 
)

Returns the component minimum of two vectors.

KZ_INLINE struct KzcVector3 kzcVector3ComponentStep ( const struct KzcVector3 vectorA,
const struct KzcVector3 vectorB 
)

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

void kzcVector3SetInvalid ( struct KzcVector3 vector)

Sets the vector components to NaN.

Variable Documentation

KANZI_API const struct KzcVector3 KZC_VECTOR3_ZERO

Constant zero 3D vector.

KANZI_API const struct KzcVector3 KZC_VECTOR3_X_AXIS

Constant unit 3D vector for X axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_Y_AXIS

Constant unit 3D vector for Y axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_Z_AXIS

Constant unit 3D vector for Z axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_X_AXIS_NEGATIVE

Constant unit 3D vector for negative X axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_Y_AXIS_NEGATIVE

Constant unit 3D vector for negative Y axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_Z_AXIS_NEGATIVE

Constant unit 3D vector for negative Z axis.

KANZI_API const struct KzcVector3 KZC_VECTOR3_MAXIMUM

Constant 3D vector with each field at maximum.

KANZI_API const struct KzcVector3 KZC_VECTOR3_MINIMUM

Constant 3D vector with each field at minimum.