WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
clockwerk Namespace Reference

Classes

class  CircularBuffer
 Simple Circular Buffer for data storage. More...
class  DataIO
 Class for inter-object communication. More...
class  DataIOBase
class  GraphTreeObject
 Base class for object organization. More...
class  Queue
 Simple first in, first out queue for data storage. More...
class  Time
 Wrapper to manage and convert time as timespce. More...
class  CartesianVector
 Standard vector class derived from Matrix. More...
class  Matrix
 Matrix math implementation. More...
class  DCM
 Class defining a direction cosine matrix inherited from Matrix. More...
class  Euler321
 Class defining a 3-2-1 Euler angle sequence. More...
class  MRP
 Modified Rodrigues Parameter class definiton. More...
class  Quaternion
 Quaternion class for attitude representation. More...
class  JsonCdl
 Load JSON file using jsmn utility. More...
class  Interpolator
 A class for performing simple x-y linear interpolation. More...
class  PersistenceTracker
 Track the persistence of a threshold. More...

Enumerations

enum  dataio_types_e : uint8 {
  INTEGER , FLOATING_POINT , VECTOR , ARRAY ,
  MATRIX , GRAPH_TREE , POINTER , STD_STRING ,
  UNDEFINED , C_STRING , TIME
}
enum  graph_tree_types_e : int8 {
  BASE_GRAPH_TREE = 0 , DATAIO = 1 , TASK = 2 , EXECUTIVE = 3 ,
  FRAME = 4 , BODY = 5 , NODE = 6
}
enum  cdl_types_e : uint8 { INT32_TP , FPOINT_TP , CARTESIANVECTOR3_TP , QUATERNION_TP }
 Type definition for CDL types which may be loaded. More...

Functions

void connectSignals (clockwerk::DataIOBase &upstream, clockwerk::DataIOBase &downstream)
 Function to tie two signals together.
void disconnect (clockwerk::DataIOBase &obj)
 Function to disconnect a DataIO object from its parent.
template<uint32 R1, uint32 C1R2, uint32 C2>
void multiply (const Matrix< R1, C1R2 > &A, const Matrix< C1R2, C2 > &B, Matrix< R1, C2 > &result)
 Function to multiply two matrices.
template<uint32 R, uint32 C>
void multiply (const floating_point &a, const Matrix< R, C > &A, Matrix< R, C > &result)
 Function to multiply a scalar by a matrix.
template<uint32 R, uint32 C>
void eMultiply (const Matrix< R, C > &A, const Matrix< R, C > &B, Matrix< R, C > &result)
 Function to multiply two matrices element-wise.
template<uint32 R, uint32 C>
void add (const floating_point &a, const Matrix< R, C > &A, Matrix< R, C > &result)
 Function to add a scalar to a matrix.
template<uint32 R, uint32 C>
void eAdd (const Matrix< R, C > &A, const Matrix< R, C > &B, Matrix< R, C > &result)
 Function to add two matrices element-wise.
template<uint32 R, uint32 C>
void eSubtract (Matrix< R, C > A, Matrix< R, C > B, Matrix< R, C > &result)
 Function to subtract B from A, element-wise.
template<uint32 R1, uint32 C1R2, uint32 C2>
Matrix< R1, C2 > operator* (const Matrix< R1, C1R2 > &A, const Matrix< C1R2, C2 > &B)
 Overload of matrix multiplication - Two matrices.
template<uint32 R, uint32 C>
Matrix< R, C > operator* (const floating_point &a, const Matrix< R, C > &A)
 Overload of matrix multiplication - Matrix and scalar.
template<uint32 R, uint32 C>
Matrix< R, C > operator* (const Matrix< R, C > &A, const floating_point &a)
template<uint32 R, uint32 C>
Matrix< R, C > operator+ (const Matrix< R, C > &A, const Matrix< R, C > &B)
 Overload of matrix addition - Two matrices.
template<uint32 R, uint32 C>
Matrix< R, C > operator+ (const floating_point &a, const Matrix< R, C > &A)
 Overload of matrix addition - Matrix and scalar.
template<uint32 R, uint32 C>
Matrix< R, C > operator+ (const Matrix< R, C > &A, const floating_point &a)
template<uint32 R, uint32 C>
Matrix< R, C > operator- (const Matrix< R, C > &A, const Matrix< R, C > &B)
 Returns value – less efficient in some cases.
template<uint32 M, uint32 K>
int16 cholSolve (const Matrix< M, M > &A, const Matrix< M, K > &B, Matrix< M, K > &X)
 Perform cholesky solve Ax=b on square, posdef matrix A and put the solution in X.
int16 safeDivide (float a, float b, float &result)
 Overloaded functions to perform safe division.
int16 safeDivide (double a, double b, double &result)
int16 safeDivide (int32 a, int32 b, int32 &result)
int16 safeDivide (uint64 a, uint64 b, uint64 &result)
int16 safeSqrt (float input, float &result)
 Overloaded functions to perform safe square root.
int16 safeSqrt (double input, double &result)
int16 safeNroot (float input, int32 rt, float &result)
 Overloaded functions to perform safe n root.
int16 safeNroot (double input, int32 rt, double &result)
int16 safeAcos (float input, float &result)
 Overloaded functions to perform save cosine inverse.
int16 safeAcos (double input, double &result)
int16 safeAsin (float input, float &result)
 Overloaded functions to perform save sine inverse.
int16 safeAsin (double input, double &result)
int16 safeTan (float input, float &result)
 Overloaded functions to perform safe tangent.
int16 safeTan (double input, double &result)
bool floatEquals (floating_point a, floating_point b, floating_point tolerance=1e-6)
 Compares if two floats are equal within a certain range.
int16 sgn (floating_point val)
 Return the sign of the value.
void cross (CartesianVector< 3 > a, CartesianVector< 3 > b, CartesianVector< 3 > &result)
CartesianVector< 3 > cross (const CartesianVector< 3 > &a, const CartesianVector< 3 > &b)
void tilde (const CartesianVector< 3 > &v, Matrix< 3, 3 > &t)
Matrix< 3, 3 > tilde (const CartesianVector< 3 > &v)
template<uint32 L>
void dot (const CartesianVector< L > &a, const CartesianVector< L > &b, floating_point &result)
template<uint32 L>
floating_point dot (const CartesianVector< L > &a, const CartesianVector< L > &b)
template<uint32 R1, uint32 C1R2>
CartesianVector< R1 > operator* (const Matrix< R1, C1R2 > &A, const CartesianVector< C1R2 > &B)
 Overload of matrix multiplication - Matrix and vector.
template<uint32 L>
CartesianVector< L > operator* (const floating_point &a, const CartesianVector< L > &A)
 Overload of vector multiplication - vector and scalar.
template<uint32 L>
CartesianVector< L > operator* (const CartesianVector< L > &A, const floating_point &a)
template<uint32 L>
CartesianVector< L > operator+ (const CartesianVector< L > &A, const CartesianVector< L > &B)
 Overload of matrix addition - Two matrices.
template<uint32 L>
CartesianVector< L > operator+ (const floating_point &a, const CartesianVector< L > &A)
 Overload of matrix addition - Matrix and scalar.
template<uint32 L>
CartesianVector< L > operator+ (const CartesianVector< L > &A, const floating_point &a)
template<uint32 L>
CartesianVector< L > operator- (const CartesianVector< L > &A, const CartesianVector< L > &B)
 Returns value – less efficient in some cases.
DCM operator* (const DCM &A, const DCM &B)
 Overload of DCM multiplication - Two DCMs.
Euler321 operator* (const Euler321 &a, const Euler321 &b)
 Overload of Euler321 multiplication - Two Euler321s.
MRP operator* (const MRP &a, const MRP &b)
 Overload of MRP multiplication - Two MRPs.
CartesianVector< 3 > operator* (const DCM &A, const CartesianVector< 3 > &b)
 Attitude rotation of vector via DCM.
CartesianVector< 3 > operator* (const Euler321 &a, const CartesianVector< 3 > &b)
 Attitude rotation of vector via Euler321.
CartesianVector< 3 > operator* (const MRP &a, const CartesianVector< 3 > &b)
 Attitude rotation of vector via MRP.
void toUpper (char *input)
 Converts a C-style string to uppercase in place.
void toLower (char *input)
 Converts a C-style string to lowercase in place.
bool caseInsensitiveEqual (const char *a, const char *b)
 Compares two C-style strings case-insensitively.
int16 strip (const char *input, char *output, size_t output_size)
 Removes leading and trailing whitespace from an input string.
int16 stringReplace (const char *source, const char *orig, const char *repl, char *output, size_t output_size)
 Replaces the first occurrence of a substring with another string.
int16 splitString (const char *text, const char *delimiter, char **tokens, size_t max_tokens, char *token_buf, size_t token_buf_size)
 Splits a string using a specified delimiter.
bool isValidNumber (const char *s)
 Checks whether a C-style string represents a valid number.
int16 numberToString (int64 num, char *out, size_t out_size)
int16 numberToString (int32 num, char *out, size_t out_size)
int16 numberToString (int16 num, char *out, size_t out_size)
int16 numberToString (int8 num, char *out, size_t out_size)
int16 numberToString (bool num, char *out, size_t out_size)
 Converts an integer to a C-style string.
int16 numberToString (uint64 num, char *out, size_t out_size)
int16 numberToString (uint32 num, char *out, size_t out_size)
int16 numberToString (uint16 num, char *out, size_t out_size)
int16 numberToString (uint8 num, char *out, size_t out_size)
int16 numberToString (char num, char *out, size_t out_size)
 Converts a char to a C-style string.
int16 numberToString (float num, char *out, size_t out_size, uint8 precision=6)
 Converts a float to a C-style string with a specified precision.
int16 numberToString (float16 num, char *out, size_t out_size, uint8 precision=3)
 Converts a float16 to a C-style string with a specified precision.
int16 numberToString (double num, char *out, size_t out_size, uint8 precision=6)
 Converts a double to a C-style string with a specified precision.
int16 numberFromString (const char *s, uint8 &num)
 Overloaded - convert string to number.
int16 numberFromString (const char *s, uint16 &num)
int16 numberFromString (const char *s, uint32 &num)
int16 numberFromString (const char *s, uint64 &num)
int16 numberFromString (const char *s, int8 &num)
int16 numberFromString (const char *s, int16 &num)
int16 numberFromString (const char *s, int32 &num)
int16 numberFromString (const char *s, int64 &num)
int16 numberFromString (const char *s, float &num)
int16 numberFromString (const char *s, double &num)
size_t strnlen (const char *s, size_t maxlen)
 Function to calculate the string length with a length bound.
template<typename T>
int16 setArrayFromString (const char *s, T *array, size_t array_size)
 Converts a bracket-enclosed comma-separated string to a float array.
template<size_t N>
int16 numberToString (const std::array< char, N > &val, char *retval, size_t size)
 Converts an array to a C-style string.
template<typename Tn, size_t N>
int16 numberToString (const std::array< Tn, N > &val, char *retval, size_t size)
 Converts an array to a C-style string.

Variables

const floating_point NSEC_PER_SEC_D = 1000000000.0
const uint16 MSEC_PER_SEC_I = 1000
const uint32 NSEC_PER_MSEC_I = 1000000
const uint32 NSEC_PER_SEC_I = 1000000000
const uint32 MAX_CHARS_PER_MATRIX_STRING = 1000
const uint8 QUATERNION_NUM_ELEMENTS = 4
 Constant for the number of elements in a quaternion.
const uint8 MAX_CHARS_PER_STRING_VALUE = 32
const uint16 MAX_CHARS_PER_ARRAY_STRING = 200

Enumeration Type Documentation

◆ cdl_types_e

enum clockwerk::cdl_types_e : uint8

Type definition for CDL types which may be loaded.

Enumerator
INT32_TP 

Integer type – can be single value or array.

FPOINT_TP 

floating_point type – can be single value or array

CARTESIANVECTOR3_TP 

Cartesian vector type – is floating_point based.

QUATERNION_TP 

Quaternion type – is floating_point based.

◆ dataio_types_e

This enumeration stores information on the data type held within the DataIO object. The storage defines data types primarily for logging, which is used in simulation.

Enumerator
INTEGER 
FLOATING_POINT 
VECTOR 
ARRAY 
MATRIX 
GRAPH_TREE 
POINTER 
STD_STRING 
UNDEFINED 
C_STRING 
TIME 

◆ graph_tree_types_e

This enumeration defines the possible derivations of the graph tree object which may be used to store helpful information on it. It's messy but it works well. Derivations may be added here as they are developed. If not, they will default to not defined.

Enumerator
BASE_GRAPH_TREE 
DATAIO 
TASK 
EXECUTIVE 
FRAME 
BODY 
NODE 

Function Documentation

◆ add()

template<uint32 R, uint32 C>
void clockwerk::add ( const floating_point & a,
const Matrix< R, C > & A,
Matrix< R, C > & result )

Function to add a scalar to a matrix.

Parameters
aScalar to add to A
AMatrix in the scalar addition operation
resultPBR return of a+A result
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ caseInsensitiveEqual()

bool clockwerk::caseInsensitiveEqual ( const char * a,
const char * b )

Compares two C-style strings case-insensitively.

Parameters
[in]aFirst null-terminated string.
[in]bSecond null-terminated string.
Returns
true if the strings match ignoring case, false otherwise.

◆ cholSolve()

template<uint32 M, uint32 K>
int16 clockwerk::cholSolve ( const Matrix< M, M > & A,
const Matrix< M, K > & B,
Matrix< M, K > & X )

Perform cholesky solve Ax=b on square, posdef matrix A and put the solution in X.

Template Parameters
MThe number of rows/cols of matrix A
KThe number of columns of X and B
Parameters
AThe matrix to solve and take cholesky decomposition on
BThe solution vector
XImplicit return of X in AX=B
Returns
Error code corresponding to success/failure

◆ connectSignals()

void clockwerk::connectSignals ( clockwerk::DataIOBase & upstream,
clockwerk::DataIOBase & downstream )

Function to tie two signals together.

Parameters
upstreamThe upstream (i.e. output) signal to connect
downstreamThe downstream (i.e. input) signal to connect

◆ cross() [1/2]

void clockwerk::cross ( CartesianVector< 3 > a,
CartesianVector< 3 > b,
CartesianVector< 3 > & result )

◆ cross() [2/2]

CartesianVector< 3 > clockwerk::cross ( const CartesianVector< 3 > & a,
const CartesianVector< 3 > & b )

◆ disconnect()

void clockwerk::disconnect ( clockwerk::DataIOBase & obj)

Function to disconnect a DataIO object from its parent.

Parameters
objThe object to disconnect from upstream

◆ dot() [1/2]

template<uint32 L>
floating_point clockwerk::dot ( const CartesianVector< L > & a,
const CartesianVector< L > & b )

◆ dot() [2/2]

template<uint32 L>
void clockwerk::dot ( const CartesianVector< L > & a,
const CartesianVector< L > & b,
floating_point & result )

◆ eAdd()

template<uint32 R, uint32 C>
void clockwerk::eAdd ( const Matrix< R, C > & A,
const Matrix< R, C > & B,
Matrix< R, C > & result )

Function to add two matrices element-wise.

Parameters
AFirst matrix in the element-wise addition operation
BSecond matrix in the element-wise addition operation
resultPBR return of A+B result
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ eMultiply()

template<uint32 R, uint32 C>
void clockwerk::eMultiply ( const Matrix< R, C > & A,
const Matrix< R, C > & B,
Matrix< R, C > & result )

Function to multiply two matrices element-wise.

Parameters
AFirst matrix in the element-wise multiplication operation
BSecond matrix in the element-wise multiplication operation
resultPBR return of A.*B result
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ eSubtract()

template<uint32 R, uint32 C>
void clockwerk::eSubtract ( Matrix< R, C > A,
Matrix< R, C > B,
Matrix< R, C > & result )

Function to subtract B from A, element-wise.

Parameters
AFirst matrix in the element-wise subtraction operation
BSecond matrix in the element-wise subtraction operation
resultPBR return of A-B result
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ floatEquals()

bool clockwerk::floatEquals ( floating_point a,
floating_point b,
floating_point tolerance = 1e-6 )

Compares if two floats are equal within a certain range.

Parameters
aFirst float to compare
bSecond float to compare
toleranceTolerance between float compares, default 1e-6
Returns
True if they are effectively equal, false if not

◆ isValidNumber()

bool clockwerk::isValidNumber ( const char * s)

Checks whether a C-style string represents a valid number.

Parameters
[in]sNull-terminated string to check.
Returns
true if the string is a valid number, false otherwise.

◆ multiply() [1/2]

template<uint32 R, uint32 C>
void clockwerk::multiply ( const floating_point & a,
const Matrix< R, C > & A,
Matrix< R, C > & result )

Function to multiply a scalar by a matrix.

Parameters
aScalar by which to multiply A
AMatrix in the scalar multiplication operation
resultPBR return of a*A result
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ multiply() [2/2]

template<uint32 R1, uint32 C1R2, uint32 C2>
void clockwerk::multiply ( const Matrix< R1, C1R2 > & A,
const Matrix< C1R2, C2 > & B,
Matrix< R1, C2 > & result )

Function to multiply two matrices.


Standard functions

Parameters
AFirst matrix in the multiplication operation
BSecond matrix in the multiplication operation
resultPBR return of A*B result
Returns
Error code corresponding to errors in clockwerkerrors.h
Note
Here we are using the "standard" O^3 matrix multiplication algorithm. Quick lookup indicates that more highly optimized matrix multiplication algorithms, such as strassen, require much larger sizes than we will typically be working with to be valuable.

◆ numberFromString() [1/10]

int16 clockwerk::numberFromString ( const char * s,
double & num )

◆ numberFromString() [2/10]

int16 clockwerk::numberFromString ( const char * s,
float & num )

◆ numberFromString() [3/10]

int16 clockwerk::numberFromString ( const char * s,
int16 & num )

◆ numberFromString() [4/10]

int16 clockwerk::numberFromString ( const char * s,
int32 & num )

◆ numberFromString() [5/10]

int16 clockwerk::numberFromString ( const char * s,
int64 & num )

◆ numberFromString() [6/10]

int16 clockwerk::numberFromString ( const char * s,
int8 & num )

◆ numberFromString() [7/10]

int16 clockwerk::numberFromString ( const char * s,
uint16 & num )

◆ numberFromString() [8/10]

int16 clockwerk::numberFromString ( const char * s,
uint32 & num )

◆ numberFromString() [9/10]

int16 clockwerk::numberFromString ( const char * s,
uint64 & num )

◆ numberFromString() [10/10]

int16 clockwerk::numberFromString ( const char * s,
uint8 & num )

Overloaded - convert string to number.

Parameters
sThe string to convert
numImplicit return of the converted number
Returns
Error code corresponding to success/failure

◆ numberToString() [1/15]

int16 clockwerk::numberToString ( bool num,
char * out,
size_t out_size )

Converts an integer to a C-style string.

Parameters
[in]numThe integer value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [2/15]

int16 clockwerk::numberToString ( char num,
char * out,
size_t out_size )

Converts a char to a C-style string.

Parameters
[in]numThe value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [3/15]

template<size_t N>
int16 clockwerk::numberToString ( const std::array< char, N > & val,
char * retval,
size_t size )

Converts an array to a C-style string.

Parameters
[in]numThe value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [4/15]

template<typename Tn, size_t N>
int16 clockwerk::numberToString ( const std::array< Tn, N > & val,
char * retval,
size_t size )

Converts an array to a C-style string.

Parameters
[in]numThe value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [5/15]

int16 clockwerk::numberToString ( double num,
char * out,
size_t out_size,
uint8 precision = 6 )

Converts a double to a C-style string with a specified precision.

Parameters
[in]numThe double value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
[in]precisionNumber of decimal places to include. Must be 0-->9 and rounds to 9 if above
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [6/15]

int16 clockwerk::numberToString ( float num,
char * out,
size_t out_size,
uint8 precision = 6 )

Converts a float to a C-style string with a specified precision.

Parameters
[in]numThe float value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
[in]precisionNumber of decimal places to include. Must be 0-->9 and rounds to 9 if above
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [7/15]

int16 clockwerk::numberToString ( float16 num,
char * out,
size_t out_size,
uint8 precision = 3 )

Converts a float16 to a C-style string with a specified precision.

Parameters
[in]numThe float16 value to convert.
[out]outOutput buffer to store the string.
[in]out_sizeSize of the output buffer.
[in]precisionNumber of decimal places to include. Must be 0-->9 and rounds to 9 if above
Returns
NO_ERROR on success, or error code if the buffer is too small.

◆ numberToString() [8/15]

int16 clockwerk::numberToString ( int16 num,
char * out,
size_t out_size )

◆ numberToString() [9/15]

int16 clockwerk::numberToString ( int32 num,
char * out,
size_t out_size )

◆ numberToString() [10/15]

int16 clockwerk::numberToString ( int64 num,
char * out,
size_t out_size )

◆ numberToString() [11/15]

int16 clockwerk::numberToString ( int8 num,
char * out,
size_t out_size )

◆ numberToString() [12/15]

int16 clockwerk::numberToString ( uint16 num,
char * out,
size_t out_size )

◆ numberToString() [13/15]

int16 clockwerk::numberToString ( uint32 num,
char * out,
size_t out_size )

◆ numberToString() [14/15]

int16 clockwerk::numberToString ( uint64 num,
char * out,
size_t out_size )

◆ numberToString() [15/15]

int16 clockwerk::numberToString ( uint8 num,
char * out,
size_t out_size )

◆ operator*() [1/12]

template<uint32 L>
CartesianVector< L > clockwerk::operator* ( const CartesianVector< L > & A,
const floating_point & a )

◆ operator*() [2/12]

CartesianVector< 3 > clockwerk::operator* ( const DCM & A,
const CartesianVector< 3 > & b )

Attitude rotation of vector via DCM.

Note
Returns value – less efficient in some cases

◆ operator*() [3/12]

DCM clockwerk::operator* ( const DCM & A,
const DCM & B )

Overload of DCM multiplication - Two DCMs.


Operator overloads – NOTE: May be less efficient than equivalent PBR function in some cases due to

return by value. Where overload is less efficient, it is explicitly noted.

Note
Returns value – less efficient in some cases

◆ operator*() [4/12]

CartesianVector< 3 > clockwerk::operator* ( const Euler321 & a,
const CartesianVector< 3 > & b )

Attitude rotation of vector via Euler321.

Note
Returns value – less efficient in some cases

◆ operator*() [5/12]

Euler321 clockwerk::operator* ( const Euler321 & a,
const Euler321 & b )

Overload of Euler321 multiplication - Two Euler321s.

Note
Returns value – less efficient in some cases
TODO: Update with more efficient multiplication rather than using DCM

◆ operator*() [6/12]

template<uint32 L>
CartesianVector< L > clockwerk::operator* ( const floating_point & a,
const CartesianVector< L > & A )

Overload of vector multiplication - vector and scalar.

Note
Returns value – less efficient in some cases

◆ operator*() [7/12]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator* ( const floating_point & a,
const Matrix< R, C > & A )

Overload of matrix multiplication - Matrix and scalar.

Note
Returns value – less efficient in some cases

◆ operator*() [8/12]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator* ( const Matrix< R, C > & A,
const floating_point & a )

◆ operator*() [9/12]

template<uint32 R1, uint32 C1R2>
CartesianVector< R1 > clockwerk::operator* ( const Matrix< R1, C1R2 > & A,
const CartesianVector< C1R2 > & B )

Overload of matrix multiplication - Matrix and vector.


Operator overloads – NOTE: May be less efficient than equivalent PBR function in some cases due to

return by value. Where overload is less efficient, it is explicitly noted.

Note
Returns value – less efficient in some cases

◆ operator*() [10/12]

template<uint32 R1, uint32 C1R2, uint32 C2>
Matrix< R1, C2 > clockwerk::operator* ( const Matrix< R1, C1R2 > & A,
const Matrix< C1R2, C2 > & B )

Overload of matrix multiplication - Two matrices.


Operator overloads – NOTE: May be less efficient than equivalent PBR function in some cases due to

return by value. Where overload is less efficient, it is explicitly noted.

Note
Returns value – less efficient in some cases

◆ operator*() [11/12]

CartesianVector< 3 > clockwerk::operator* ( const MRP & a,
const CartesianVector< 3 > & b )

Attitude rotation of vector via MRP.

Note
Returns value – less efficient in some cases

◆ operator*() [12/12]

MRP clockwerk::operator* ( const MRP & a,
const MRP & b )

Overload of MRP multiplication - Two MRPs.

Note
Returns value – less efficient in some cases
TODO: Update with more efficient multiplication rather than using DCM

◆ operator+() [1/6]

template<uint32 L>
CartesianVector< L > clockwerk::operator+ ( const CartesianVector< L > & A,
const CartesianVector< L > & B )

Overload of matrix addition - Two matrices.

Note
Returns value – less efficient in some cases

◆ operator+() [2/6]

template<uint32 L>
CartesianVector< L > clockwerk::operator+ ( const CartesianVector< L > & A,
const floating_point & a )

◆ operator+() [3/6]

template<uint32 L>
CartesianVector< L > clockwerk::operator+ ( const floating_point & a,
const CartesianVector< L > & A )

Overload of matrix addition - Matrix and scalar.

Note
Returns value – less efficient in some cases

◆ operator+() [4/6]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator+ ( const floating_point & a,
const Matrix< R, C > & A )

Overload of matrix addition - Matrix and scalar.

Note
Returns value – less efficient in some cases

◆ operator+() [5/6]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator+ ( const Matrix< R, C > & A,
const floating_point & a )

◆ operator+() [6/6]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator+ ( const Matrix< R, C > & A,
const Matrix< R, C > & B )

Overload of matrix addition - Two matrices.

Note
Returns value – less efficient in some cases

◆ operator-() [1/2]

template<uint32 L>
CartesianVector< L > clockwerk::operator- ( const CartesianVector< L > & A,
const CartesianVector< L > & B )

Returns value – less efficient in some cases.

◆ operator-() [2/2]

template<uint32 R, uint32 C>
Matrix< R, C > clockwerk::operator- ( const Matrix< R, C > & A,
const Matrix< R, C > & B )

Returns value – less efficient in some cases.

◆ safeAcos() [1/2]

int16 clockwerk::safeAcos ( double input,
double & result )

◆ safeAcos() [2/2]

int16 clockwerk::safeAcos ( float input,
float & result )

Overloaded functions to perform save cosine inverse.

Parameters
inputThe input value to take cosine of
resultThe result of the cos
Returns
Error code corresponding to success/failure

◆ safeAsin() [1/2]

int16 clockwerk::safeAsin ( double input,
double & result )

◆ safeAsin() [2/2]

int16 clockwerk::safeAsin ( float input,
float & result )

Overloaded functions to perform save sine inverse.

Parameters
inputThe input value to take sine of
resultThe result of the sin
Returns
Error code corresponding to success/failure

◆ safeDivide() [1/4]

int16 clockwerk::safeDivide ( double a,
double b,
double & result )

◆ safeDivide() [2/4]

int16 clockwerk::safeDivide ( float a,
float b,
float & result )

Overloaded functions to perform safe division.

Parameters
aDividend
bDivisor
resultPBR value to receive result of division
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ safeDivide() [3/4]

int16 clockwerk::safeDivide ( int32 a,
int32 b,
int32 & result )

◆ safeDivide() [4/4]

int16 clockwerk::safeDivide ( uint64 a,
uint64 b,
uint64 & result )

◆ safeNroot() [1/2]

int16 clockwerk::safeNroot ( double input,
int32 rt,
double & result )

◆ safeNroot() [2/2]

int16 clockwerk::safeNroot ( float input,
int32 rt,
float & result )

Overloaded functions to perform safe n root.

Parameters
inputThe value to take the n root of
rtThe degree of root to take
resultPBR value to receive result of n-root
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ safeSqrt() [1/2]

int16 clockwerk::safeSqrt ( double input,
double & result )

◆ safeSqrt() [2/2]

int16 clockwerk::safeSqrt ( float input,
float & result )

Overloaded functions to perform safe square root.

Parameters
inputThe value to take the square root of
resultPBR value to receive result of square
Returns
Error code corresponding to errors in clockwerkerrors.h

◆ safeTan() [1/2]

int16 clockwerk::safeTan ( double input,
double & result )

◆ safeTan() [2/2]

int16 clockwerk::safeTan ( float input,
float & result )

Overloaded functions to perform safe tangent.

Parameters
inputThe input value to take tangent of
resultThe result of the tangent
Returns
Error code corresponding to success/failure

◆ setArrayFromString()

template<typename T>
int16 clockwerk::setArrayFromString ( const char * s,
T * array,
size_t array_size )

Converts a bracket-enclosed comma-separated string to a float array.

Example string: "[1.0,2.5,3.4]"

Parameters
[in]sNull-terminated string in bracketed format.
[out]arrayDestination array to receive parsed floats.
[in]array_sizeExpected size of the array to populate.
Returns
NO_ERROR on success, or an error code on failure.

◆ sgn()

int16 clockwerk::sgn ( floating_point val)

Return the sign of the value.

Parameters
valThe value to return the sign of
Returns

◆ splitString()

int16 clockwerk::splitString ( const char * text,
const char * delimiter,
char ** tokens,
size_t max_tokens,
char * token_buf,
size_t token_buf_size )

Splits a string using a specified delimiter.

This function tokenizes the input text, placing pointers to each token in the tokens array, and stores the tokens themselves in a provided static buffer.

Parameters
[in]textInput null-terminated string to split.
[in]delimiterDelimiter string.
[out]tokensArray of pointers to store token locations.
[in]max_tokensMaximum number of tokens to store in the array.
[out]token_bufBuffer to store token strings.
[in]token_buf_sizeSize of token_buf.
Returns
Number of tokens found, or negative error code on failure.

◆ stringReplace()

int16 clockwerk::stringReplace ( const char * source,
const char * orig,
const char * repl,
char * output,
size_t output_size )

Replaces the first occurrence of a substring with another string.

Writes the result to the provided output buffer.

Parameters
[in]sourceInput source string.
[in]origSubstring to search for in the source.
[in]replReplacement substring.
[out]outputOutput buffer to receive the new string.
[in]output_sizeSize of the output buffer, including null terminator.
Returns
NO_ERROR on success, or error code if buffer too small or null.

◆ strip()

int16 clockwerk::strip ( const char * input,
char * output,
size_t output_size )

Removes leading and trailing whitespace from an input string.

Copies the stripped result into the provided output buffer.

Parameters
[in]inputInput null-terminated string.
[out]outputOutput buffer to receive stripped string.
[in]output_sizeSize of the output buffer, including space for null terminator.
Returns
NO_ERROR on success, or error code if buffer too small or null.

◆ strnlen()

size_t clockwerk::strnlen ( const char * s,
size_t maxlen )

Function to calculate the string length with a length bound.

Parameters
spoint to string array
maxlenMax length of the string
Returns
Size of string. If there is no null terminator, returns max value

◆ tilde() [1/2]

Matrix< 3, 3 > clockwerk::tilde ( const CartesianVector< 3 > & v)

◆ tilde() [2/2]

void clockwerk::tilde ( const CartesianVector< 3 > & v,
Matrix< 3, 3 > & t )

◆ toLower()

void clockwerk::toLower ( char * input)

Converts a C-style string to lowercase in place.

Parameters
[in,out]inputPointer to a null-terminated string to be converted.

◆ toUpper()

void clockwerk::toUpper ( char * input)

Converts a C-style string to uppercase in place.

Parameters
[in,out]inputPointer to a null-terminated string to be converted.

Variable Documentation

◆ MAX_CHARS_PER_ARRAY_STRING

const uint16 clockwerk::MAX_CHARS_PER_ARRAY_STRING = 200

◆ MAX_CHARS_PER_MATRIX_STRING

const uint32 clockwerk::MAX_CHARS_PER_MATRIX_STRING = 1000

◆ MAX_CHARS_PER_STRING_VALUE

const uint8 clockwerk::MAX_CHARS_PER_STRING_VALUE = 32

◆ MSEC_PER_SEC_I

const uint16 clockwerk::MSEC_PER_SEC_I = 1000

◆ NSEC_PER_MSEC_I

const uint32 clockwerk::NSEC_PER_MSEC_I = 1000000

◆ NSEC_PER_SEC_D

const floating_point clockwerk::NSEC_PER_SEC_D = 1000000000.0

◆ NSEC_PER_SEC_I

const uint32 clockwerk::NSEC_PER_SEC_I = 1000000000

◆ QUATERNION_NUM_ELEMENTS

const uint8 clockwerk::QUATERNION_NUM_ELEMENTS = 4

Constant for the number of elements in a quaternion.