geVec3d is an implementation of a 3d vector object. It contains many of the standard vector operations, plus a few which are conveniences.
geVec3d was designed to be an efficient, but descriptive way of handling 3d vectors. Because of the common use of vectors as temporary objects, it was decided that the structure definition of the vector would be exposed in the header file, and there would be no Create/Destroy functions implemented.
void geVec3d_Add(const geVec3d *V1, const geVec3d *V2, geVec3d *V1PlusV2)
Description: Adds V1 to V2 and puts the result in V1PlusV2.
Parameters:
| V1 | Vector to be added |
| V2 | Vector to be added |
| V1PlusV2 | Sum of the two inputs |
Returns: void
void geVec3d_AddScaled(const geVec3d *V1, const geVec3d *V2, geFloat Scale, geVec3d *V1PlusV2Scaled)
Description: Scales V2 by Scale, adds the result to V1, and puts the sum in V1PlusV2Scaled.
Parameters:
| V1 | Input vector |
| V2 | Input vector |
| Scale | Scale value for V2 |
| V1PlusV2 | V1 + (V2 * Scale) |
Returns: void
void geVec3d_Clear(geVec3d *V)
Description: Sets the values of the vector to zero.
Parameters:
| V | Vector to be cleared |
Returns: void
geBoolean geVec3d_Compare(const geVec3d *V1, const geVec3d *V2, geFloat Tolerance)
Description: Compares V1 to V2, applying the Tolerance value to the comparisons of each element. If each element pair compares within the tolerance, the return is GE_TRUE. Otherwise it is GE_FALSE.
Parameters:
| V1 | Vector to be compared |
| V2 | Vector to be compared |
| Tolerance | Floating point tolerance to be applied to each pair of vector elements. Usually, this is a small number. |
Returns: geBoolean
void geVec3d_Copy(const geVec3d *Vsrc, geVec3d *Vdest)
Description: Copies the vector Vsrc to Vdest
Parameters:
| Vsrc | Source vector |
| Vdest | Destination vector |
Returns: void
void geVec3d_CrossProduct(const geVec3d *V1, const geVec3d *V2, geVec3d *Result)
Description: Calculates the cross product of V1 with V2, and places the result in Result.
Parameters:
| V1 | Input vector |
| V2 |
InputVector |
| Result | V1 x V2 |
Returns: void
geFloat geVec3d_DistanceBetween(const geVec3d *V1, const geVec3d *V2)
Description: Calculates the distance between two vectors.
Parameters:
| V1 | Input vector |
| V2 | InputVector |
Returns: Returns the length of V2 - V1.
void geVec3d_DotProduct(const geVec3d *V1, const geVec3d *V2, geVec3d *Result)
Description: Calculates the dot product of V1 with V2, and places the result in Result.
Parameters:
| V1 | Input vector |
| V2 | Input vector |
| Result | V1 dot V2 |
Returns: void
void geVec3d_Get(const geVec3d *V, geFloat *X, geFloat *Y, geFloat *Z)
Description: Gets the components of the vector into distinct variables.
Parameters:
| V | Input vector |
| X | Modified to the value V->X |
| Y | Modified to the value V->Y |
| Z | Modified to the value V->Z |
Returns: void
geFloat geVec3d_GetElement(const geVec3d *V, int ElementIndex)
Description: Treats the input vector as an array, and returns the corresponding element's value.
Parameters:
| V | Input vector | ||||||
| ElementIndex |
|
Returns: Value of V->X, Y or Z, depending on ElementIndex.
void geVec3d_Inverse(geVec3d *V)
Description: Sets V equal to -V.
Parameters:
| V | Vector to be inverted |
Returns: void
geBoolean geVec3d_IsNormalized(const geVec3d *V)
Description: Determines if the vector has been normalized.
Parameters:
| V | Vector to be tested. |
Returns: GE_TRUE if the vector is of length 1.0, GE_FALSE otherwise.
geBoolean geVec3d_IsValid(const geVec3d *V)
Description: Determines if the vector is valid. This is a debugging API, primarily. It was designed to test for vectors that contained NAN values on Intel machines, since it is easy to let NAN values slip into calculations. Since NANs do not generate hardware exceptions, it can be exceedingly difficult to determine when data has gone bad.
Parameters:
| V | Vector to be tested. |
Returns: GE_TRUE if the vector is valid, GE_FALSE otherwise.
geFloat geVec3d_Length(const geVec3d *V)
Description: Returns the length of the input vector
Parameters:
| V | Input vector |
Returns: Length of V.
Description: Do not use this API. It has been superceeded by geVec3d_AddScaled, and will be going away.
geFloat geVec3d_Normalize(geVec3d *V)
Description: Normalizes the input vector. If the vector is length zero, then it is not modified.
Parameters:
| V | Vector to be normalized |
Returns: The length of the vector before normalization.
void geVec3d_Scale(const geVec3d *V, geFloat Scale, geVec3d *Result)
Description: Scales the input vector.
Parameters:
| V | Input vector |
| Scale | Value to scale V by |
| Result | V scaled by Scale |
Returns: void
void geVec3d_Set(geVec3d *V, geFloat X, geFloat Y, geFloat Z)
Description: Sets a vector from discrete components.
Parameters:
| V | Vector to be initialized |
| X | X value for the vector |
| Y | Y value for the vector |
| Z | Z value for the vector |
Returns: void
void geVec3d_Subtract(const geVec3d *V1, const geVec3d *V2, geVec3d *V2MinusV1)
Description: Subtracts two vectors.
Parameters:
| V1 | Input vector |
| V1 | Input vector |
| V2MinusV1 | Set to the result of V2 - V1. |
Returns: void