Matrix-vector operations¶
Overview¶
These functions apply a rotation or a rigid body transformation to a vector.
The operand abbreviations are explained in Getting Started: dr is a
rotation matrix, d a full transformation \(D = (R, \underline{t})\),
and inv after either one means its inverse.
Points and free vectors transform differently. The coordinates of a point, such as the location of a marker on a body, are transformed from frame \(b\) to frame \(a\) with both the rotation and the translation:
A free vector, such as a velocity, a force or the direction of an axis, has no location, so its components are transformed by the rotation alone:
Using the wrong one is a common source of errors.
Inverse transformations go the other way, transforming coordinates from frame \(a\) to frame \(b\). They are applied directly from \(R\) and \(\underline{t}\), without computing and storing the inverse:
Translations along an axis. The drvtx, drvty and drvtz
functions rotate a vector that lies along a coordinate axis,
\(R\,(t\,\underline{e}_x)\). That is just \(t\) times the first column
of \(R\), so it costs 3 multiplications instead of the 9 multiplications
and 6 additions of a general matrix-vector product.
Double precision¶
Compute the double precision matrix product of a 3x3 matrix \(R^{oi}\) and a 3x1 vector \(\underline{v}^i_{oi}\) . |
|
Compute the double precision matrix product of a 3x3 matrix \(R^{oi}\) and the inverse of a 3x1 input vector \(\underline{v}^i_{oi}\) . |
|
Rotate a vector by an inverse rotation: vo = ri^T * vi. |
|
Rotate a negated vector by an inverse rotation: vo = -ri^T * vi. |
|
Rotate a vector along the x axis: vo = ri * (ti * ex). |
|
Rotate a negated vector along the x axis: vo = ri * (-ti * ex). |
|
Rotate a vector along the y axis: vo = ri * (ti * ey). |
|
Rotate a negated vector along the y axis: vo = ri * (-ti * ey). |
|
Rotate a vector along the z axis: vo = ri * (ti * ez). |
|
Rotate a negated vector along the z axis: vo = ri * (-ti * ez). |
|
Transform a point by an SE3 transformation: vo = Di * vi = R * vi + t. |
|
Transform a point by an inverse SE3 transformation: vo = Di^-1 * vi = R^T (vi - t). |
-
static inline void ksl_product_drv(const ksl_mat3x3_t *r_oi, const ksl_vec3_t *v_i, ksl_vec3_t *v_o)¶
Compute the double precision matrix product of a 3x3 matrix \(R^{oi}\) and a 3x1 vector \(\underline{v}^i_{oi}\).
\(R^{oi} \underline{v}^i_{oi} \rightarrow \underline{v}^o_{oi} \)
- Parameters:
r_oi – [in] input 3x3 matrix
v_i – [in] input vector
v_o – [out] result returned in v_o
-
static inline void ksl_product_drvinv(const ksl_mat3x3_t *ri, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Compute the double precision matrix product of a 3x3 matrix \(R^{oi}\) and the inverse of a 3x1 input vector \(\underline{v}^i_{oi}\).
\(R^{oi} (-\underline{v}^i_{oi}) \rightarrow \underline{v}^o_{io} \)
\(-R^{oi} \underline{v}^i_{oi} \rightarrow \underline{v}^o_{io} \)
\(R^{oi} \underline{v}^i_{io} \rightarrow \underline{v}^o_{io} \)
- Parameters:
ri – [in] input 3x3 matrix
vi – [in] input vector
vo – [out] result, -ri * vi
-
static inline void ksl_product_drinvv(const ksl_mat3x3_t *ri, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Rotate a vector by an inverse rotation: vo = ri^T * vi.
- Parameters:
ri – [in] rotation matrix
vi – [in] vector
vo – [out] product ri^T * vi
-
static inline void ksl_product_drinvvinv(const ksl_mat3x3_t *ri, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Rotate a negated vector by an inverse rotation: vo = -ri^T * vi.
- Parameters:
ri – [in] rotation matrix
vi – [in] vector
vo – [out] product -ri^T * vi
-
static inline void ksl_product_drvtx(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a vector along the x axis: vo = ri * (ti * ex).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the x axis
vo – [out] ti times the x column of ri
-
static inline void ksl_product_drvtxinv(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a negated vector along the x axis: vo = ri * (-ti * ex).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the x axis
vo – [out] -ti times the x column of ri
-
static inline void ksl_product_drvty(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a vector along the y axis: vo = ri * (ti * ey).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the y axis
vo – [out] ti times the y column of ri
-
static inline void ksl_product_drvtyinv(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a negated vector along the y axis: vo = ri * (-ti * ey).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the y axis
vo – [out] -ti times the y column of ri
-
static inline void ksl_product_drvtz(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a vector along the z axis: vo = ri * (ti * ez).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the z axis
vo – [out] ti times the z column of ri
-
static inline void ksl_product_drvtzinv(const ksl_mat3x3_t *ri, const double ti, ksl_vec3_t *vo)¶
Rotate a negated vector along the z axis: vo = ri * (-ti * ez).
- Parameters:
ri – [in] rotation matrix
ti – [in] length of the vector along the z axis
vo – [out] -ti times the z column of ri
-
static inline void ksl_product_dv(const ksl_SE3_t *Di, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Transform a point by an SE3 transformation: vo = Di * vi = R * vi + t.
- Parameters:
Di – [in] SE3 transformation
vi – [in] point
vo – [out] transformed point
-
static inline void ksl_product_dinvv(const ksl_SE3_t *Di, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Transform a point by an inverse SE3 transformation: vo = Di^-1 * vi = R^T (vi - t).
Expresses a point given in the reference frame in the frame of Di.
- Parameters:
Di – [in] SE3 transformation to invert
vi – [in] point
vo – [out] transformed point
Single precision¶
Compute the single precision matrix product of a 3x3 matrix \(R^{oi}\) and a 3x1 vector \(\underline{v}^i_{oi}\) . |
|
Single precision version of ksl_product_drvinv(). |
|
Single precision version of ksl_product_drinvv(). |
|
Single precision version of ksl_product_drinvvinv(). |
|
Single precision version of ksl_product_drvtx(). |
|
Single precision version of ksl_product_drvtxinv(). |
|
Single precision version of ksl_product_drvty(). |
|
Single precision version of ksl_product_drvtyinv(). |
|
Single precision version of ksl_product_drvtz(). |
|
Single precision version of ksl_product_drvtzinv(). |
|
Single precision version of ksl_product_dv(). |
|
Single precision version of ksl_product_dinvv(). |
-
static inline void ksl_product_drvf(const ksl_mat3x3f_t *r_oi, const ksl_vec3f_t *v_i, ksl_vec3f_t *v_o)¶
Compute the single precision matrix product of a 3x3 matrix \(R^{oi}\) and a 3x1 vector \(\underline{v}^i_{oi}\).
\(R^{oi} \underline{v}^i_{oi} \rightarrow \underline{v}^o_{oi} \)
- Parameters:
r_oi – [in] input 3x3 matrix
v_i – [in] input vector
v_o – [out] result returned in v_o
-
static inline void ksl_product_drvinvf(const ksl_mat3x3f_t *ri, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvinv().
-
static inline void ksl_product_drinvvf(const ksl_mat3x3f_t *ri, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drinvv().
-
static inline void ksl_product_drinvvinvf(const ksl_mat3x3f_t *ri, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drinvvinv().
-
static inline void ksl_product_drvtxf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvtx().
-
static inline void ksl_product_drvtxinvf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvtxinv().
-
static inline void ksl_product_drvtyf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvty().
-
static inline void ksl_product_drvtyinvf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvtyinv().
-
static inline void ksl_product_drvtzf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvtz().
-
static inline void ksl_product_drvtzinvf(const ksl_mat3x3f_t *ri, const float ti, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_drvtzinv().
-
static inline void ksl_product_dvf(const ksl_SE3f_t *Di, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_dv().
-
static inline void ksl_product_dinvvf(const ksl_SE3f_t *Di, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Single precision version of ksl_product_dinvv().