PyEVSpace C Capsule#
Importing the Capsule#
The capsule must be imported before it can be used. The public C API defines a global capsule variable and a macro to handle the importing.
-
static EVSpace_CAPI *EVSpaceAPI#
A global variable to hold the C API capsule.
-
EVSpace_IMPORT#
Imports the capsule into the global
EVSpaceAPI
pointer. Place this macro after including the evspace_api.h header and you will have access to the capsule.#include <evspace_api.h> EVSpace_IMPORT;
The following macro also defines the name of the capsule if it is needed:
-
EVSpace_CAPSULE_NAME#
Expands to the name of the capsule needed for some of CPython’s capsule methods.
C API Capsule#
-
struct EVSpace_CAPI#
Python capsule object that contain all functions of the PyEVSpace C API. For more details on capsules check out the official Python docs. The capsule can be imported using the
EVSpace_IMPORT
macro, which sets the global pointerEVSpaceAPI
using thePyCapsule_Import()
method. There are helper macros for every function inside the capsule to avoid cumbersome method calls. For example to create a newEVSpace_Vector
:new_vector_long = EVSpaceAPI->Vector_FromArray(arr, EVSpaceAPI->VectorType); new_vector_short = Vector_FromArray(arr);
You can use these macros to massively reduce the length of your code. The struct is defined as follows.
typedef struct { /* type objects */ PyTypeObject* VectorType; PyTypeObject* MatrixType; PyTypeObject* AnglesType; PyTypeObject* OrderType; PyTypeObject* RefFrameType; /* constructors */ EVSpace_Vector* (*Vector_FromArray)(double*, PyTypeObject*); EVSpace_Vector* (*Vector_StealArray)(double*, PyTypeObject*); EVSpace_Matrix* (*Matrix_FromArray)(double*, PyTypeObject*); EVSpace_Matrix* (*Matrix_StealArray)(double*, PyTypeObject*); EVSpace_Angles* (*Angles_New)(double, double, double, PyTypeObject*); EVSpace_Order* (*Order_New)(EVSpace_Axis, EVSpace_Axis, EVSpace_Axis, PyTypeObject*); EVSpace_ReferenceFrame* (*RefFrame_New)(EVSpace_Order*, EVSpace_Angles*, EVSpace_Vector*, PyTypeObject*); /* vector number methods */ EVSpace_Vector* (*Vector_add)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_subtract)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_multiply)(const EVSpace_Vector*, double); EVSpace_Vector* (*Vector_multiply_m)(const EVSpace_Vector*, const EVSpace_Matrix*); EVSpace_Vector* (*Vector_divide)(const EVSpace_Vector*, double); void (*Vector_iadd)(EVSpace_Vector*, const EVSpace_Vector*); void (*Vector_isubtract)(EVSpace_Vector*, const EVSpace_Vector*); void (*Vector_imultiply)(EVSpace_Vector*, double); void (*Vector_idivide)(EVSpace_Vector*, double); EVSpace_Vector* (*Vector_negative)(const EVSpace_Vector*); /* matrix number methods */ EVSpace_Matrix* (*Matrix_add)(const EVSpace_Matrix*, const EVSpace_Matrix*); EVSpace_Matrix* (*Matrix_subtract)(const EVSpace_Matrix*, const EVSpace_Matrix*); EVSpace_Vector* (*Matrix_multiply_v)(const EVSpace_Matrix*, const EVSpace_Vector*); EVSpace_Matrix* (*Matrix_multiply_m)(const EVSpace_Matrix*, const EVSpace_Matrix*); EVSpace_Matrix* (*Matrix_multiply_s)(const EVSpace_Matrix*, double); EVSpace_Matrix* (*Matrix_divide)(const EVSpace_Matrix*, double); void (*Matrix_iadd)(EVSpace_Matrix*, const EVSpace_Matrix*); void (*Matrix_isubtract)(EVSpace_Matrix*, const EVSpace_Matrix*); void (*Matrix_imultiply)(EVSpace_Matrix*, double); void (*Matrix_idivide)(EVSpace_Matrix*, double); EVSpace_Matrix* (*Matrix_negative)(const EVSpace_Matrix*); /* vector class methods */ double (*Vector_mag)(const EVSpace_Vector*); double (*Vector_mag2)(const EVSpace_Vector*); void (*Vector_normalize)(EVSpace_Vector*); /* module methods */ double (*Vector_dot)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_cross)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_norm)(const EVSpace_Vector*); double (*Vector_vang)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_vxcl)(const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Vector_proj)(const EVSpace_Vector*, const EVSpace_Vector*); double (*Matrix_det)(const EVSpace_Matrix*); EVSpace_Matrix* (*Matrix_transpose)(const EVSpace_Matrix*); /* rotation orders */ const EVSpace_Order* Order_XYZ; const EVSpace_Order* Order_XZY; const EVSpace_Order* Order_YXZ; const EVSpace_Order* Order_YZX; const EVSpace_Order* Order_ZXY; const EVSpace_Order* Order_ZYX; const EVSpace_Order* Order_XYX; const EVSpace_Order* Order_XZX; const EVSpace_Order* Order_YXY; const EVSpace_Order* Order_YZY; const EVSpace_Order* Order_ZXZ; const EVSpace_Order* Order_ZYZ; /* rotation matrix methods */ EVSpace_Matrix* (*Get_matrix)(EVSpace_Axis, double); EVSpace_Matrix* (*Get_euler)(const EVSpace_Order*, const EVSpace_Angles*); EVSpace_Matrix* (*Get_from_to)(const EVSpace_Order*, const EVSpace_Angles*, const EVSpace_Order*, const EVSpace_Angles*); /* rotate vector methods */ EVSpace_Vector* (*Rotate_axis_to)(EVSpace_Axis, double, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_axis_from)(EVSpace_Axis, double, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_euler_to)(const EVSpace_Order*, const EVSpace_Angles*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_euler_from)(const EVSpace_Order*, const EVSpace_Angles*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_matrix_to)(const EVSpace_Matrix*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_matrix_from)(const EVSpace_Matrix*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_offset_to)(const EVSpace_Matrix*, const EVSpace_Vector*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_offset_from)(const EVSpace_Matrix*, const EVSpace_Vector*, const EVSpace_Vector*); /* reference frame methods */ EVSpace_Vector* (*Rotate_ref_to)(const EVSpace_ReferenceFrame*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_ref_from)(const EVSpace_ReferenceFrame*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_ref_to_ref)(const EVSpace_ReferenceFrame*, const EVSpace_ReferenceFrame*, const EVSpace_Vector*); EVSpace_Vector* (*Rotate_ref_from_ref)(const EVSpace_ReferenceFrame*, const EVSpace_ReferenceFrame*, const EVSpace_Vector*); } EVSpace_CAPI;
-
PyTypeObject *EVSpace_CAPI.VectorType#
The static
PyTypeObject
implementation ofVector
, whose C type isEVSpace_Vector
.
-
PyTypeObject *EVSpace_CAPI.MatrixType#
The static
PyTypeObject
implementation ofMatrix
, whose C type isEVSpace_Matrix
.
-
PyTypeObject *EVSpace_CAPI.AnglesType#
The static
PyTypeObject
implementation ofAngles
, whose C type isEVSpace_Angles
.
-
PyTypeObject *EVSpace_CAPI.OrderType#
The static
PyTypeObject
implementation ofOrder
, whose C type isEVSpace_Order
.
-
PyTypeObject *EVSpace_CAPI.RefFrameType#
The static
PyTypeObject
implementation ofReferenceFrame
, whose C type isEVSpace_ReferenceFrame
.
Capsule Members#
Constructors#
-
EVSpace_Vector *EVSpace_CAPI.Vector_FromArray(double *array, PyTypeObject *type)#
Creates a new
EVSpace_Vector
instance by copying the data from array. If array is NULL, the vector components will be initialized to zero.The array parameter must have a size of at least three. Since the data is only copied from the array, it is still the users responsibility to free the memory to avoid leaks.
The type parameter must be the
PyTypeObject
implementation ofEVSpace_Vector
, which can be found in the capsule asVectorType
.- Parameters:
array – array of size three with the x, y and z values
type – the Python type of
EVSpace_Vector
- Returns:
a pointer to the new vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_StealArray(double *array, PyTypeObject *type)#
Creates a new
EVSpace_Vector
instance by stealing an array pointer for the underlying data array. This is a much more efficient constructor thanVector_FromArray()
because no copying is done. The underlying data pointer is set to the array parameter, and array is set to NULL on success.The type parameter must be the
PyTypeObject
implementation ofEVSpace_Vector
, which can be found in the capsule asVectorType
.Note
The array parameter is set to NULL only if this function succeeds. If the function does not succeed (NULL is returned) it is still the users responsibility to free array to avoid a memory leak.
- Parameters:
array – array of size three with the x, y and z value. set to NULL on success
type – the Python type of
EVSpace_Vector
- Returns:
a pointer to the new vector
- Return values:
NULL – if an error occurred
-
EVSpace_Matrix *EVSpace_CAPI.Matrix_FromArray(double *array, PyTypeObject *type)#
Creates a new
EVSpace_Matrix
instance by copying the data from array. If array is NULL, the matrix components will be initialized to zero.The array parameter must have a size of at least nine. Since the data is only copied from the array, it is still the users responsibility to free the memory to avoid leaks.
The type parameter must be the
PyTypeObject
implementation ofEVSpace_Matrix
, which can be found in the capsule asMatrixType
.- Parameters:
array – array of size nine holding the matrix component values
type – the Python type of
EVSpace_Matrix
- Returns:
a pointer to the new matrix
- Return values:
NULL – if an error occurred
-
EVSpace_Matrix *EVSpace_CAPI.Matrix_StealArray(double *array, PyTypeObject *type)#
Creates a new
EVSpace_Matrix
instance by stealing an array pointer for the underlying data array. This is a much more efficient constructor thanMatrix_FromArray()
because no copying is done. The underlying data pointer is set to the array argument, and array is set to NULL on success.The type parameter must be the
PyTypeObject
implementation ofEVSpace_Matrix
, which can be found in the capsule asMatrixType
.Note
The array parameter is set to NULL only if this function succeeds. If the function does not succeed (NULL is returned) it is still the users responsibility to free array to avoid a memory leak.
- Parameters:
array – array of size nine holding the matrix component values
type – the Python type of
EVSpace_Matrix
- Returns:
a pointer to the new matrix
- Return values:
NULL – if an error occurred
-
EVSpace_Angles *EVSpace_CAPI.Angles_New(double alpha, double beta, double gamma, PyTypeObject *type)#
Creates a new
EVSpace_Angles
instance setting the angles to the given arguments.- Parameters:
alpha – first angle of an Euler rotation in radians
beta – second angle of an Euler rotation in radians
gamma – third angle of an euler rotation in radians
type – the Python type of
EVSpace_Angles
- Returns:
a pointer to the new instance
- Return values:
NULL – if an error occurred
-
EVSpace_Order *EVSpace_CAPI.Order_New(EVSpace_Axis first, EVSpace_Axis second, EVSpace_Axis third, PyTypeObject *type)#
Creates a new
EVSpace_Order
instance with the given axes parameters as the type attributes.- Parameters:
first – the first axis of rotation
second – the second axis of rotation
third – the third axis of rotation
type – the Python type of
EVSpace_Order
- Returns:
a pointer to the new instance
- Return values:
NULL – if an error occurred
-
EVSpace_ReferenceFrame *EVSpace_CAPI.RefFrame_New(EVSpace_Order *order, EVSpace_Angles *angles, EVSpace_Vector *offset, PyTypeObject *type)#
Creates a new
EVSpace_ReferenceFrame
instance based on the Euler rotation orderand angle parameters.An optional offset vector can be set as well.- Parameters:
order – the Euler rotation order
angles – the angles associated with the Euler rotation
offset – optional parameter to set the offset of a reference frame, should be NULL if there is no offset
type – the Python type of
EVSpace_ReferenceFrame
- Returns:
a pointer to the new reference frame
- Return values:
NULL – if an error occurred
Vector numeric methods#
-
EVSpace_Vector *EVSpace_CAPI.Vector_add(const EVSpace_Vector *lhs, const EVSpace_Vector *rhs)#
Returns a new
EVSpace_Vector
equal to \(lhs + rhs\).- Parameters:
lhs – vector to be added to
rhs – vector to add to
- Returns:
the sum of lhs and rhs
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_subtract(const EVSpace_Vector *lhs, const EVSpace_Vector *rhs)#
Returns a new
EVSpace_Vector
equal to \(lhs - rhs\).- Parameters:
lhs – vector to be subtracted from
rhs – vector to subtract
- Returns:
the difference of lhs, and rhs
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_multiply(const EVSpace_Vector *lhs, double scalar)#
Returns a new
EVSpace_Vector
equal to \(lhs * scalar\).- Parameters:
lhs – vector to be multiplied
rhs – scalar to multiply each element of lhs by
- Returns:
the product of lhs and scalar
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_multiply_m(const EVSpace_Vector *vector, const EVSpace_Matrix *matrix)#
Computes the left vector multiplication of a matrix.
- Parameters:
vector – vector to multiply
matrix – matrix transformation
- Returns:
the transformed vector
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Vector_divide(const EVSpace_Vector *lhs, double scalar)#
Returns a new
EVSpace_Vector
equal to \(lhs / scalar\). This is equivalent toEVSpace_CAPI.EVSpace_Vector_multiply(lhs, 1.0 / scalar);
-
void EVSpace_CAPI.Vector_iadd(EVSpace_Vector *self, const EVSpace_Vector *other)#
Inplace vector addition. This function doesn’t call any Python code and will always succeed.
- Parameters:
self – vector to be added to
other – vector to add to self
-
void EVSpace_CAPI.Vector_isubtract(EVSpace_Vector *self, const EVSpace_Vector *other)#
Inplace vector subtraction. This function doesn’t call any Python code and will always succeed.
- Parameters:
self – vector to be subtracted from
other – vector to subtract from self
-
void EVSpace_CAPI.Vector_imultiply(EVSpace_Vector *self, double scalar)#
Inplace scalar multiplication. This function doesn’t call any Python code and will always succeed.
- Parameters:
self – vector to multiply
scalar – scalar to multiply self by
-
void EVSpace_CAPI.Vector_idivide(EVSpace_Vector *self, double scalar)#
Inplace scalar division. This function doesn’t call any Python code and will always succeed.
- Parameters:
self – vector to divide
scalar – scalar to divide self by
-
PyObject *EVSpace_CAPI.Vector_negative(const EVSpace_Vector *self)#
Urnary negative operator, returns a new vector pointing in the opposite direction of self.
- Parameters:
self – vector to negate
- Returns:
the negative vector of self
- Return values:
NULL – if an error occurrs
Matrix numeric methods#
-
PyObject *EVSpace_CAPI.Matrix_add(const EVSpace_Matrix *lhs, const EVSpace_Matrix *rhs)#
Returns a new matrix equal to \(lhs + rhs\).
- Parameters:
lhs – first matrix
rhs – second matrix
- Returns:
matrix sum of lhs and rhs
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Matrix_subtract(const EVSpace_Matrix *lhs, const EVSpace_Matrix *rhs)#
Returns a new matrix equal to \(lhs - rhs\).
- Parameters:
lhs – first matrix
rhs – second matrix
- Returns:
matrix difference of lhs and rhs
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Matrix_multiply_v(const EVSpace_Matrix *matrix, const EVSpace_Vector *vector)#
Left-hand matrix multiplication of a vector.
- Parameters:
matrix – matrix to multiply vector by
vector – vector to multiply
- Returns:
a new transformed vector
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Matrix_multiply_m(const EVSpace_Matrix *lhs, const EVSpace_Matrix *rhs)#
Compound two transformations via matrix multiplication.
- Parameters:
lhs – first matrix
rhs – second matrix
- Returns:
the compounded matrix
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Matrix_multiply_s(const EVSpace_Matrix *self, double scalar)#
Scalar matrix multiplication.
- Parameters:
self – matrix to multipliy
scalar – scalar to multiply each component of matrix by
- Returns:
matrix product
- Return values:
NULL – if an error occurred
-
PyObject *EVSpace_CAPI.Matrix_divide(const EVSpace_Matrix *lhs, double scalar)#
Matrix scalar division.
- Parameters:
lhs – matrix to divide
scalar – scalar to divide each component of matrix by
- Returns:
matrix quotient
- Return values:
NULL – if an error occurred
-
void EVSpace_CAPI.Matrix_iadd(EVSpace_Matrix *self, const EVSpace_Matrix *other)#
Inplace matrix addition, adding other to self
- Parameters:
self – matrix to be added to
other – matrix to add to self
-
void EVSpace_CAPI.Matrix_isubtract(EVSpace_Matrix *self, const EVSpace_Matrix *other)#
Inplace matrix subtraction, subtracting other from self.
- Parameters:
self – matrix to be subtracted from
other – matrix to subtract
-
void EVSpace_CAPI.Matrix_imultiply(EVSpace_Matrix *self, double scalar)#
Inplace scalar multiplication.
- Parameters:
self – matrix to multiply
scalar – scalar to multiply each component of matrix by
-
void EVSpace_CAPI.Matrix_idivide(EVSpace_Matrix *self, double other)#
Inplace scalar division.
- Parameters:
self – matrix to divide
scalar – scalar to divide each component of matrix by
-
PyObject *EVSpace_CAPI.Matrix_negative(const EVSpace_Matrix *matrix)#
Unary negative operator, negates each component of matrix.
- Parameters:
matrix – matrix to negate
- Returns:
negative matrix of matrix
- Return values:
NULL – if an error occurred
Vector instance methods#
-
double EVSpace_CAPI.Vector_mag(const EVSpace_Vector *vector)#
Computes the magnitude, or length, of a vector. This function doesn’t call any Python code and always succeeds.
- Parameters:
vector – vector to compute the magnitude of
- Returns:
the length of vector
-
double EVSpace_CAPI.Vector_mag2(const EVSpace_Vector *vector)#
Computes the square of the magnitude of a vector. This is more efficient than squaring the value returned from
EVSpace_mag()
and also avoids rounding errors.- Parameters:
vector – vector to find the magnitude of
- Returns:
the square of the length of vector
-
void EVSpace_CAPI.Vector_normalize(EVSpace_Vector *self)#
Normalizes a vector inplace, which maintains its direction but changes its length to 1.0.
- Parameters:
self – vector to normalize
Vector module methods#
-
double EVSpace_CAPI.Vector_dot(const EVSpace_Vector *lhs, const EVSpace_Vector *rhs)#
Computes the dot product of two vectors.
- Parameters:
lhs – first vector
rhs – second vector
- Returns:
the dot product of lhs and rhs
-
EVSpace_Vector *EVSpace_CAPI.Vector_cross(const EVSpace_Vector *lhs, const EVSpace_Vector *rhs)#
Computes the cross product of two vectors. This uses a right-hand coordinate frame. This vector can be negated to compute a cross product for a left-hand coordinate frame.
- Parameters:
lhs – first vector
rhs – second vector
- Returns:
the right-handed cross product of lhs and rhs
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_norm(const EVSpace_Vector *vector)#
Returns a new vector equal to the norm of self. The returned vector points in the same difection as self but has a length of 1.0.
- Parameters:
self – vector to compute the norm of
- Returns:
a normalized version of self
- Return values:
NULL – if an error occurred
-
double EVSpace_CAPI.Vector_vang(const EVSpace_Vector *from, const EVSpace_Vector *to)#
Compute the angle between two vectors. This is always the shortest angle between from and to.
Note: don’t be confused by the nomenclature of the parameters,
EVSpace_vang(from, to)
is equal toEVSpace_vang(to, from)
.- Parameters:
from – first vector
to – second vector
- Returns:
the shortest angle between from and to in radians
-
EVSpace_Vector *EVSpace_CAPI.Vector_vxcl(const EVSpace_Vector *vector, const EVSpace_Vector *exclude)#
Creates a new vector equal to vector with all parts of exclude removed from it. This is in effect the vector projection of vector on the plane whose normal vector is exclude. The result of this function and the exclude vector are linearly independent vectors.
- Parameters:
vector – starting vector
exclude – vector to exclude from vector
- Returns:
the projection of vector onto the plane whose normal vector is exclude.
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Vector_proj(const EVSpace_Vector *proj, const EVSpace_Vector *onto)#
The projection of one vector onto another. If the angle between vectors u and v is theta, u projected onto v is the vector pointing in the direction of v whose length is \(|u| * cos(theta)\). If the dot product of u and v is negative, this vector points in the opposite direction of v.
- Parameters:
proj – vector to project
onto – vector to be projected on
- Returns:
the projection of proj onto onto
- Return values:
NULL – if an error occurred
Matrix module methods#
-
double EVSpace_CAPI.Matrix_det(const EVSpace_Matrix *matrix)#
Computes the determinate of a matrix.
- Parameters:
matrix – matrix to compute the determinate of
- Returns:
the determinate of matrix
-
EVSpace_Matrix *EVSpace_CAPI.Matrix_transpose(const EVSpace_Matrix *matrix)#
Returns a new matrix equal to the transpose of matrix. The returned matrix of this function has the values of matrix but with the rows and columns switched.
- Parameters:
matrix – matrix to transpose
- Returns:
the transpose of matrix
- Return values:
NULL – if an error occurred
Rotation order instances#
-
const EVSpace_Order *Order_XYZ#
-
const EVSpace_Order *Order_XZY#
-
const EVSpace_Order *Order_YXZ#
-
const EVSpace_Order *Order_YZX#
-
const EVSpace_Order *Order_ZXY#
-
const EVSpace_Order *Order_ZYX#
-
const EVSpace_Order *Order_XYX#
-
const EVSpace_Order *Order_XZX#
-
const EVSpace_Order *Order_YXY#
-
const EVSpace_Order *Order_YZY#
-
const EVSpace_Order *Order_ZXZ#
-
const EVSpace_Order *Order_ZYZ#
Rotation matrix methods#
The following functions create a rotation matrix, indicated by the function name.
-
EVSpace_Matrix *EVSpace_CAPI.Get_matrix(EVSpace_Axis axis, double angle)#
C equivalent to
getMatrixAxis()
.- Parameters:
axis – axis to rotate around
angle – angle in radians
- Returns:
the equivalent rotation matrix
- Return values:
NULL – if an error occurred
-
EVSpace_Matrix *EVSpace_CAPI.Get_euler(const EVSpace_Order *order, const EVSpace_Angles *angles)#
C equivalent to
getMatrixEuler()
.- Parameters:
order – Euler order
angles – rotation angles
- Returns:
the equivalent rotation matrix
- Return values:
NULL – if an error occurred
-
EVSpace_Matrix *EVSpace_CAPI.Get_from_to(const EVSpace_Order *orderFrom, const EVSpace_Angles *anglesFrom, const EVSpace_Order *orderTo, const EVSpace_Angles *anglesTo)#
Computes the rotation matrix that defines moving from one reference frame to another. Both reference frames must be defined as an Euler rotation. C equivalent to
getMatrixFromTo()
.- Parameters:
orderFrom – Euler order of the reference frame moving from
anglesFrom – rotation angles of the reference frame moving from
orderTo – Euler order of the reference frame moving to
anglesTo – rotation angles of the reference frame moving to
- Returns:
the equivalent rotation matrix
- Reval NULL:
if an error occurred
Vector rotate methods#
The following functions rotate vectors either to or from a reference frame, indecated by the function name.
-
EVSpace_Vector *EVSpace_CAPI.Rotate_axis_to(EVSpace_Axis axis, double angle, const EVSpace_Vector *vector)#
C equivalent to
rotateAxisTo()
.- Parameters:
axis – rotation axis
angle – rotation angle in radians
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_axis_from(EVSpace_Axis axis, double angle, const EVSpace_Vector *vector)#
C equivalent to
rotateAxisFrom()
.- Parameters:
axis – rotation axis
angle – rotation angle in radians
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_euler_to(const EVSpace_Order *order, const EVSpace_Angles *angles, const EVSpace_Vector *vector)#
C equivalent to
rotateEulerTo()
.- Parameters:
order – Euler rotation order
angles – rotation angles
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_euler_from(const EVSpace_Order *order, const EVSpace_Angles *angles, const EVSpace_Vector *vector)#
C equivalent to
rotateEulerFrom()
.- Parameters:
order – Euler rotation order
angles – rotation angles
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_matrix_to(const EVSpace_Matrix *matrix, const EVSpace_Vector *vector)#
C equivalent to
rotateMatrixTo()
.- Parameters:
matrix – a rotation matrix
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_matrix_from(const EVSpace_Matrix *matrix, const EVSpace_Vector *vector)#
C equivalent to
rotateMatrixTo()
.- Parameters:
matrix – a rotation matrix
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_offset_to(const EVSpace_Matrix *matrix, const EVSpace_Vector *offset, const EVSpace_Vector *vector)#
C equivalent to
rotateOffsetTo()
.- Parameters:
matrix – a rotation matrix
offset – a vector pointing to the offset reference frame’s origin
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_offset_from(const EVSpace_Matrix *matrix, const EVSpace_Vector *offset, const EVSpace_Vector *vector)#
C equivalent to
rotateOffsetFrom()
.- Parameters:
matrix – a rotation matrix
offset – a vector pointing to the offset reference frame’s origin
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
Reference frame functions#
-
EVSpace_Vector *EVSpace_CAPI.Rotate_ref_to(const EVSpace_ReferenceFrame *frame, const EVSpace_Vector *vector)#
Rotates a vector to a reference frame via an EVSpace_ReferenceFrame object. C equivalent to
ReferenceFrame.rotateTo()
.- Parameters:
frame – reference frame object
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_ref_from(const EVSpace_ReferenceFrame *frame, const EVSpace_Vector *vector)#
Rotates a vector from a reference frame via an EVSpace_ReferenceFrame object. C equivalent to
ReferenceFrame.rotateTo()
.- Parameters:
frame – reference frame object
vector – vector to rotate
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_ref_to_ref(const EVSpace_ReferenceFrame *frame, const EVSpace_ReferenceFrame *to, const EVSpace_Vector *vector)#
Rotates a vector from a reference frame, to another. C equivalent to
ReferenceFrame.rotateToFrame()
.- Parameters:
frame – reference frame moving from
to – reference frame moving to
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred
-
EVSpace_Vector *EVSpace_CAPI.Rotate_ref_from_ref(const EVSpace_ReferenceFrame *frame, const EVSpace_ReferenceFrame *from, const EVSpace_Vector *vector)#
Rotates a vector to a reference frame, from another. C equivalent to
ReferenceFrame.rotateFromFrame()
.- Parameters:
frame – reference frame moving from
to – reference frame moving to
- Returns:
the rotated vector
- Return values:
NULL – if an error occurred