C-functions for vector operations. More...
#include "c_basic_math.h"Go to the source code of this file.
Defines | |
| #define | MAX_VECTOR_DIM 64 |
| max. number of elements in a vector | |
Functions | |
| BM_STATUS | initDblVector (double *vector, const unsigned int dim, const double value) |
| set all elements of the vector to value | |
| BM_STATUS | copyDblVector (double *dest, const double *source, const unsigned int dim) |
| copy all elements of vector source to vector dest | |
| BM_STATUS | addDblVector (double *result, const double *augend, const double *addend, const unsigned int dim) |
| safe vector addition | |
| BM_STATUS | subDblVector (double *result, const double *minuend, const double *subtrahend, const unsigned int dim) |
| safe vector subtraction | |
| double | innerProductDblVector (const double *multiplier, const double *multiplicand, const unsigned int dim, BM_STATUS *bms) |
| safe vector inner product | |
| BM_STATUS | doubleMulDblVector (double *result, const double *vector, const unsigned int dim, const double scalar) |
| safe vector multiplication with a scalar | |
| BM_STATUS | doubleDivDblVector (double *result, const double *vector, const unsigned int dim, const double scalar) |
| safe vector divsion with a scalar | |
| BM_STATUS | crossProductDblVector (double *result, const double *multiplier, const double *multiplicand, const unsigned int dim) |
| safe vector cross product | |
| double | lengthDblVector (const double *vector, const unsigned int dim, BM_STATUS *bms) |
| length of vector ( abs(vector) ) | |
| BM_STATUS | invertDirectionDblVector (double *result, const double *vector, const unsigned int dim) |
| invert direction of vector ( -(vector) ) | |
| int | isNullDblVector (const double *vector, const unsigned int dim, BM_STATUS *bms) |
| is null vector ( |vector| < MICRO (0.000001) ) | |
| int | is1DblVector (const double *vector, const unsigned int dim, BM_STATUS *bms) |
| is 1 vector ( |vector| == 1 ) | |
| BM_STATUS | directionDblVector (double *direction, const double *vector, const unsigned int dim) |
| returns the unit direction vector of vector ( |dir| == 1 ) | |
| int | compareLengthDblVector (const double *vector1, const double *vector2, const unsigned int dim, BM_STATUS *bms) |
| compares the length of 2 vectors ( |v1| compare |v2| ) | |
| double | angleDblVector (const double *vector1, const double *vector2, const unsigned int dim, BM_STATUS *bms) |
| calculates the crossing angle of 2 vectors | |
| int | isEqualDblVector (const double *vector1, const double *vector2, const unsigned int dim, BM_STATUS *bms) |
| is vector1 equal vector2 ( vector1 == vector2 ) | |
| int | isParallelDblVector (const double *vector1, const double *vector2, const unsigned int dim, BM_STATUS *bms) |
| checks the direction of vector1 and vector2 (dir1 == dir2) or (-dir1==dir2) | |
| int | isOrthogonalDblVector (const double *vector1, const double *vector2, const unsigned int dim, BM_STATUS *bms) |
| checks if vector1 is orthogonal to vector2 | |
C-functions for vector operations.
This file contains all C-style functions for safe vector operations
| BM_STATUS addDblVector | ( | double * | result, | |
| const double * | augend, | |||
| const double * | addend, | |||
| const unsigned int | dim | |||
| ) |
safe vector addition
result = augend + addend
| result | [out] pointer to the destination vector's first element. Can also point to augend or addend. | |
| augend | [in] pointer to the vector's first element | |
| addend | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors |
| double angleDblVector | ( | const double * | vector1, | |
| const double * | vector2, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
calculates the crossing angle of 2 vectors
returns the angle in radiand
| vector1 | [in] pointer to the vector's first element | |
| vector2 | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| int compareLengthDblVector | ( | const double * | vector1, | |
| const double * | vector2, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
compares the length of 2 vectors ( |v1| compare |v2| )
returns -1 if |vector1| < |vector2|
returns 0 if |vector1| == |vector2|
returns 1 if |vector1| > |vector2|
| vector1 | [in] pointer to the vector's first element | |
| vector2 | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| BM_STATUS copyDblVector | ( | double * | dest, | |
| const double * | source, | |||
| const unsigned int | dim | |||
| ) |
copy all elements of vector source to vector dest
| dest | [out] pointer to the destination vector's first element | |
| source | [in] pointer to the source vector's first element | |
| dim | [in] number of elements in vector |
| BM_STATUS crossProductDblVector | ( | double * | result, | |
| const double * | multiplier, | |||
| const double * | multiplicand, | |||
| const unsigned int | dim | |||
| ) |
safe vector cross product
result (vector) = multiplier * multiplicand
| result | [out] pointer to the vector's first element It's strictly forbidden that result points to multiplier or multiplicand. (will be checked!!!) | |
| multiplier | [in] pointer to the vector's first element | |
| multiplicand | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors |
| BM_STATUS directionDblVector | ( | double * | direction, | |
| const double * | vector, | |||
| const unsigned int | dim | |||
| ) |
returns the unit direction vector of vector ( |dir| == 1 )
calculates the direction of vector
| direction | [out] pointer to the vector's first element | |
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors |
| BM_STATUS doubleDivDblVector | ( | double * | result, | |
| const double * | vector, | |||
| const unsigned int | dim, | |||
| const double | scalar | |||
| ) |
safe vector divsion with a scalar
result (vector) = vector / scalar
| result | [out] pointer to the vector's first element Can also point to vector. | |
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| scalar | [in] the value to be divided with each element of vector |
| BM_STATUS doubleMulDblVector | ( | double * | result, | |
| const double * | vector, | |||
| const unsigned int | dim, | |||
| const double | scalar | |||
| ) |
safe vector multiplication with a scalar
result (vector) = vector * scalar
| result | [out] pointer to the vector's first element Can also point to vector. | |
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| scalar | [in] the value to be multiplied with each element of vector |
| BM_STATUS initDblVector | ( | double * | vector, | |
| const unsigned int | dim, | |||
| const double | value | |||
| ) |
set all elements of the vector to value
| vector | [out] pointer to the vector's first element | |
| dim | [in] number of elements in vector | |
| value | [in] the value to be set into each element in vector |
| double innerProductDblVector | ( | const double * | multiplier, | |
| const double * | multiplicand, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
safe vector inner product
result (scalar) = multiplier * multiplicand
| multiplier | [in] pointer to the vector's first element | |
| multiplicand | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| BM_STATUS invertDirectionDblVector | ( | double * | result, | |
| const double * | vector, | |||
| const unsigned int | dim | |||
| ) |
invert direction of vector ( -(vector) )
result = -(vector)
| result | [out] pointer to the vector's first element Can also point to vector. | |
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors |
| int is1DblVector | ( | const double * | vector, | |
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
is 1 vector ( |vector| == 1 )
returns 1 if the length of the vector == 1 (+-MICRO)
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| int isEqualDblVector | ( | const double * | vector1, | |
| const double * | vector2, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
is vector1 equal vector2 ( vector1 == vector2 )
returns 1 both vectors are equal
| vector1 | [in] pointer to the vector's first element | |
| vector2 | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| int isNullDblVector | ( | const double * | vector, | |
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
is null vector ( |vector| < MICRO (0.000001) )
returns 1 if the length of the vector >= MICRO
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| int isOrthogonalDblVector | ( | const double * | vector1, | |
| const double * | vector2, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
checks if vector1 is orthogonal to vector2
returns 1 if vector1 is orthogonal (normal) to vector2
| vector1 | [in] pointer to the vector's first element | |
| vector2 | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| int isParallelDblVector | ( | const double * | vector1, | |
| const double * | vector2, | |||
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
checks the direction of vector1 and vector2 (dir1 == dir2) or (-dir1==dir2)
returns 1 if vector1 is parallel to vector2
retruns 2 if vector1 is anti parallel to vector2 (oposite direction)
| vector1 | [in] pointer to the vector's first element | |
| vector2 | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| double lengthDblVector | ( | const double * | vector, | |
| const unsigned int | dim, | |||
| BM_STATUS * | bms | |||
| ) |
length of vector ( abs(vector) )
length (scalar) = |vector|
| vector | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors | |
| bms | [out,opt] A pointer to receive basic math status informations (can be null). bms remains unchanged if there is no error in this operation. bms acts accumulative. |
| BM_STATUS subDblVector | ( | double * | result, | |
| const double * | minuend, | |||
| const double * | subtrahend, | |||
| const unsigned int | dim | |||
| ) |
safe vector subtraction
result = minuend - subtrahend
| result | [out] pointer to the destination vector's first element. Can also point to augend or addend. | |
| minuend | [in] pointer to the vector's first element | |
| subtrahend | [in] pointer to the vector's first element | |
| dim | [in] number of elements in the vectors |
1.6.3