Vector Operations
VectorIdentity
Sets the input vector = [0, 0, 0, 1]
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | A | double* | Pointer to a vector [1x4] |
Return | BOOL | Always 0 |
Usage
plcbit VectorIdentity(double In[4]);
VectorAdd
Adds 2 vectors component wise, assumes [1x3].
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | A | double* | Pointer to first vector [1x3] |
In | B | double* | Pointer to second vector [1x3] |
Out | OUT | double* | Pointer to result of A + B |
Return | BOOL | Always 0 |
Usage
plcbit VectorAdd(double* A, double* B, double* Out);
VectorSubtract
Subtracts vector B from vector A, assumes [1x3].
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | A | double* | Pointer to first vector [1x3] |
In | B | double* | Pointer to second vector [1x3] |
Out | OUT | double* | Pointer to result of A - B |
Return | BOOL | Always 0 |
Usage
plcbit VectorSubtract(double* A, double* B, double* Out);
VectorDotProduct
Calculate a dot product of two vectors, assumes [1x3].
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | A | double* | Pointer to first vector [1x3] |
In | B | double* | Pointer to second vector [1x3] |
Return | double | Result of A . B |
Usage
double VectorDotProduct(double* A, double* B);
VectorCrossProduct
Take the cross product of A x B, assumes [1x3].
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | A | double* | Pointer to first vector [1x3] |
In | B | double* | Pointer to second vector [1x3] |
Out | Out | double* | Pointer to result of A x B |
Return | BOOL | Always 0 |
Usage
plcbit VectorCrossProduct(double* A, double* B, double* Out);
VectorNormalize
Normalizes a length 4 vector to be a unit vector, assumes [1x4].
It will divide the first three elements of the vector by the vectors magnitude. The last element = 1.
Parameters
Direction | Name | Variable Type | Description |
---|---|---|---|
In | In | double* | Pointer to vector [1x4] |
Out | Out | double* | Pointer to calculated unit vector [1x4] |
Return | BOOL | Always 0 |
Usage
plcbit VectorNormalize(double* In, double* Out);