3D Vectors¶
Overview¶
A three-dimensional vector is an ordered set of three numbers, written as a column matrix
In kinematics and dynamics, vectors describe the positions of points, displacements, linear and angular velocities, forces and moments. The components of a vector are always measured in some reference frame: the same physical vector has different components in different frames, and the components in two frames are related by a rotation matrix (see 3x3 Matrices). A superscript names the frame, so \(\underline{v}^a\) is the vector \(\underline{v}\) with its components expressed in frame \(a\).
The operations used most often are the dot product, which gives the length of a vector and the angle between two vectors, and the cross product, which appears in moments (\(\underline{r} \times \underline{f}\)) and in the velocity of a point on a rotating body (\(\underline{\omega} \times \underline{r}\)). The cross product can also be written as a product with the skew-symmetric matrix \(\tilde{a}\) (see Notation):
Storage. ksl_vec3_t holds three double values with no padding, 24
bytes in all (ksl_vec3f_t: three float values, 12 bytes;
ksl_vec3i_t: three int values). An array of n vectors is therefore
one contiguous block of 3n numbers. The components can be read by name or
by index:
ksl_vec3_t v = ksl_vec3(1.0, 2.0, 3.0);
double y = v.y; /* by name */
double z = v.at[2]; /* by index, 0 to 2 */
Function names. Functions are named after the operation and the operand
types, for example ksl_add_vv (vector plus vector), ksl_cross_vv and
ksl_dot_vv. ksl_product_av multiplies a scalar a by a vector.
axpy stands for “a times x plus y” (\(\underline{y} \leftarrow a
\underline{x} + \underline{y}\)), a name borrowed from standard linear algebra
libraries; xpy and nxpy are the cases \(a = 1\) and
\(a = -1\). An inv suffix on a vector means its negative, so
ksl_cross_vvinv computes \(\underline{v}_1 \times
(-\underline{v}_2)\).
Double precision¶
3 dimensional double precision vector |
|
vec3 constructor |
|
initialize n ksl_vec3_t double precision vectors datastructures on the heap |
|
compute the norm of a double precision vector |
|
Normalize a double precision vector. |
|
Normalize a double precision vector leaving original datastructure unmodified; results are returned in second datastructure. |
|
Scale a double precision vector. |
|
Scale a double precision vector, returning results in second vector. |
|
Copy a double precision ksl_vec3_t vi into ksl_vec3_t vo. |
|
Swap double precision vectors vio1 and vio2. |
|
Copy inverse of double precision ksl_vec3_t vi into vo. |
|
invert a double precision vector in place |
|
double precision dot product of two vectors |
|
Computes the double precision product of a vector and a scalar. |
|
Computes the double precision product of the inverse of a vector and a scalar. |
|
Computes the double precision product of a vector and 1/scalar. |
|
Adds two double precision vectors. |
|
Subtract two double precision vectors. |
|
axpy (ax plus y stored in y) for double precision vectors |
|
double precision subtract v1i from v2i in place. This is a variation of axpy where a = -1 |
|
Adds two double precision vectors. This is a variation of axpy where a = 1. |
|
Compute double precision cross product of v1i with v2i. |
|
Compute double precision cross product of v1i with v2i^-1. |
|
Add a double precision Vector with a primitive translation along x-axis. |
|
Add a double precision Vector with the inverse of a translation along the x-axis. |
|
Add a double precision Vector with a translation along the y-axis. |
|
Add a double precision Vector with the inverse of a translation along the y-axis. |
|
Add a double precision Vector with a translation along the z-axis. |
|
Add a double precision Vector with the inverse of a translation along the z-axis. |
-
union ksl_vec3_t¶
- #include <types.h>
3 dimensional double precision vector
-
static inline ksl_vec3_t ksl_vec3(const double x, const double y, const double z)¶
vec3 constructor
-
inline ksl_vec3_t *ksl_vec3_alloc(int)¶
initialize n ksl_vec3_t double precision vectors datastructures on the heap
-
static inline double ksl_vec3_l2norm(const ksl_vec3_t *v)¶
compute the norm of a double precision vector
-
static inline void ksl_vec3_normalize(ksl_vec3_t *v)¶
Normalize a double precision vector.
- Parameters:
v – [in/out] vector to normalize
-
static inline void ksl_vec3_normalized(const ksl_vec3_t *v, ksl_vec3_t *vo)¶
Normalize a double precision vector leaving original datastructure unmodified; results are returned in second datastructure.
- Parameters:
v – [in] vector to normalize
vo – [out] unit vector in the direction of v
-
static inline void ksl_vec3_scale(ksl_vec3_t *v, const double k)¶
Scale a double precision vector.
- Parameters:
v – [in,out] vector to scale in place
k – [in] scale factor
-
static inline void ksl_vec3_scaled(const ksl_vec3_t *v, const double k, ksl_vec3_t *vo)¶
Scale a double precision vector, returning results in second vector.
- Parameters:
v – [in] vector to scale
k – [in] scale factor
vo – [out] scaled vector, k * v
-
static inline void ksl_vec3_copy(const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Copy a double precision ksl_vec3_t vi into ksl_vec3_t vo.
\(V_i \rightarrow V_o\)
- Parameters:
vi – input vector \(V_i\)
vo – output vector \(V_o\)
-
static inline void ksl_vec3_swap(ksl_vec3_t *vio1, ksl_vec3_t *vio2)¶
Swap double precision vectors vio1 and vio2.
\(V_io1 \rightarrow V_io2\) \(V_io2 \rightarrow V_io1\)
- Parameters:
vio1 – input/output vector \(V_io1\)
vio2 – input/output vector \(V_io2\)
-
static inline void ksl_vec3_inverted(const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Copy inverse of double precision ksl_vec3_t vi into vo.
\(-V_i \rightarrow V_o\)
- Parameters:
vi – input vector \(V_i\)
vo – output vector \(V_o\)
-
static inline void ksl_vec3_invert(ksl_vec3_t *vi)¶
invert a double precision vector in place
\(-V_i \rightarrow V_i\)
- Parameters:
vi – [in/out] input vector \(V_i\)
-
static inline double ksl_dot_vv(const ksl_vec3_t *vi0, const ksl_vec3_t *vi1)¶
double precision dot product of two vectors
\( V_i0 \cdot V_i1 \rightarrow V_o\)
- Parameters:
vi0 – first input vector
vi1 – second input vector
-
static inline void ksl_product_av(const double ki, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Computes the double precision product of a vector and a scalar.
\(V_i * k_i \rightarrow V_o\)
- Parameters:
ki – [in] scalar
vi – [in] vector
vo – [out] product ki * vi
-
static inline void ksl_product_avinv(const double ki, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Computes the double precision product of the inverse of a vector and a scalar.
\(-V_i * k_i \rightarrow V_o\)
- Parameters:
vi – [in] A 3x1 input vector
ki – [in] double precision scalar
vo – [out] the results are stored in vo
-
static inline void ksl_product_ainvv(const double ki, const ksl_vec3_t *vi, ksl_vec3_t *vo)¶
Computes the double precision product of a vector and 1/scalar.
Note: this function does not check for divide by zero.
\(V_i * 1 / k_i \rightarrow V_o\)
- Parameters:
vi – [in] A 3x1 input vector
ki – [in] a double precision scalar
vo – [out] the results are returned in vo
-
static inline void ksl_add_vv(const ksl_vec3_t *v1i, const ksl_vec3_t *v2i, ksl_vec3_t *vo)¶
Adds two double precision vectors.
Add 3 by 1 column matrices v1i and v2i and store results in vo.
\(V_{1i} + V_{2i} \rightarrow V_o\)
- Parameters:
v1i – a first column vector input
v2i – second column vector
vo – the results of v1i + v2i are stored in vo
-
static inline void ksl_subtract_vv(const ksl_vec3_t *v1i, const ksl_vec3_t *v2i, ksl_vec3_t *vo)¶
Subtract two double precision vectors.
Add 3 by 1 column matrix v1i to v2i
\(V_{2i} = V_{1i} - V_{2i}\)
- Parameters:
v1i – [in]
v2i – [in]
vo – [out]
-
static inline void ksl_axpy_vv(const double k, const ksl_vec3_t *v1x, ksl_vec3_t *v2y)¶
axpy (ax plus y stored in y) for double precision vectors
Add 3 by 1 column matrix v1x scaled by k to v2y.
\(V_{2y} += k V_{1x} \)
- Parameters:
k – [in] scale factor
v1x – [in] vector to scale and add
v2y – [in,out] vector that k * v1x is added to
-
static inline void ksl_nxpy_vv(const ksl_vec3_t *v1i, ksl_vec3_t *v2i)¶
double precision subtract v1i from v2i in place. This is a variation of axpy where a = -1
\(V_{2i} -= V_{1i} \)
- Parameters:
v1i – [in]
v2i – [in/out]
-
static inline void ksl_xpy_vv(const ksl_vec3_t *v1i, ksl_vec3_t *v2i)¶
Adds two double precision vectors. This is a variation of axpy where a = 1.
Add 3 by 1 column matrix v1i to v2i
\(V_{2i} += V_{1i} \)
- Parameters:
v1i – [in] vector to add
v2i – [in,out] vector that v1i is added to
-
static inline void ksl_cross_vv(const ksl_vec3_t *v1i, const ksl_vec3_t *v2i, ksl_vec3_t *vo)¶
Compute double precision cross product of v1i with v2i.
\(V_{1i} \times V_{2i} \rightarrow V_o\)
- Parameters:
v1i – a first 3x1 vector
v2i – a second 3x1 vector
vo – the results are stored in vo
-
static inline void ksl_cross_vvinv(const ksl_vec3_t *v1i, const ksl_vec3_t *v2i, ksl_vec3_t *vo)¶
Compute double precision cross product of v1i with v2i^-1.
\(V_{1i} \times V_{2i} \rightarrow V_o\)
- Parameters:
v1i – [in] a first 3x1 vector
v2i – [in] a second 3x1 vector
vo – [out] results are stored in vo
-
static inline void ksl_add_vvx(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with a primitive translation along x-axis.
Computes the result of a general 3-d translation, followed by a translation along the x axis using sparse algebra.
\(t_{i} + t_{x} \rightarrow t_o\)
is equivalent to:
\(t_{i} \rightarrow t_o\)
\(t_o[0] + t_x \rightarrow t_o[0]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvxinv(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with the inverse of a translation along the x-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the x axis using sparse algebra.
\(t_{i} + t_{x} \rightarrow t_o\)
is equivalent to:
\(t_{i} \rightarrow t_o\)
\(t_o[0] + t_x \rightarrow t_o[0]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvy(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with a translation along the y-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the y axis using sparse algebra.
\(t_{i} + t_{y} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[1] + t_y \rightarrow t_o[1]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvyinv(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with the inverse of a translation along the y-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the y axis using sparse algebra.
\(t_{i} + t_{y} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[1] - t_y \rightarrow t_o[1]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvz(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with a translation along the z-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the z axis using sparse algebra.
\(t_{i} + t_{z} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[2] + t_z \rightarrow t_o[2]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvzinv(const ksl_vec3_t *t1i, const double t2i, ksl_vec3_t *to)¶
Add a double precision Vector with the inverse of a translation along the z-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the z axis using sparse algebra.
\(t_{i} + t_{z} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[2] - t_z \rightarrow t_o[2]\)
- Parameters:
t1i – [in] a pointer to a general 3-d translation
t2i – [in] translation along z-axis
to – [out] a pointer to a general 3-d translation where the result is stored.
Cubic splines¶
Second derivatives of the natural cubic spline through n key points. |
|
Second derivatives of the clamped cubic spline through n key points. |
|
Evaluate a cubic spline through n key points and its derivatives. |
-
void ksl_vec3_spline_natural(const int n, const ksl_vec3_t *keys, ksl_vec3_t *m, double *work)¶
Second derivatives of the natural cubic spline through n key points.
The keys \(p_0, \dots, p_{n-1}\) are reached at \(t = 0, 1, \dots, n - 1\). On the segment from key k to key k + 1, with \(u = t - k\), the spline is
\[ p(t) = (1 - u)\,p_k + u\,p_{k+1} + \frac{(1 - u)^3 - (1 - u)}{6}\,\underline{m}_k + \frac{u^3 - u}{6}\,\underline{m}_{k+1}, \]and its first derivative is continuous at the interior keys when
\[ \underline{m}_{k-1} + 4\,\underline{m}_k + \underline{m}_{k+1} = 6\,(p_{k+1} - 2p_k + p_{k-1}), \qquad k = 1, \dots, n - 2. \]The natural end conditions are \(\underline{m}_0 = \underline{m}_{n-1} = \underline{0}\). The tridiagonal system is solved by its \(LDL^{T}\) factors without pivoting (the matrix is strictly diagonally dominant), for the three coordinates at once. The spline is continuous in position, first and second derivative ( \(C^2\)). Evaluate it with ksl_vec3_spline().
- Parameters:
n – [in] number of keys, at least 2
keys – [in] key points
m – [out] n second derivatives \(\underline{m}_k\)
work – [out] scratch array of n doubles
-
void ksl_vec3_spline_clamped(const int n, const ksl_vec3_t *keys, const ksl_vec3_t *v0, const ksl_vec3_t *vn, ksl_vec3_t *m, double *work)¶
Second derivatives of the clamped cubic spline through n key points.
As ksl_vec3_spline_natural(), but with the first derivatives \(\underline{v}_0\) at the first key and \(\underline{v}_{n-1}\) at the last key prescribed, which replaces the natural end conditions by
\[ 2\,\underline{m}_0 + \underline{m}_1 = 6\,(p_1 - p_0 - \underline{v}_0), \qquad \underline{m}_{n-2} + 2\,\underline{m}_{n-1} = 6\,(\underline{v}_{n-1} - p_{n-1} + p_{n-2}). \]- Parameters:
n – [in] number of keys, at least 2
keys – [in] key points
v0 – [in] first derivative at the first key
vn – [in] first derivative at the last key
m – [out] n second derivatives \(\underline{m}_k\)
work – [out] scratch array of n doubles
-
void ksl_vec3_spline(const int n, const ksl_vec3_t *keys, const ksl_vec3_t *m, const double *t, ksl_vec3_t *po, ksl_vec3_t *dpo, ksl_vec3_t *ddpo)¶
Evaluate a cubic spline through n key points and its derivatives.
Evaluates the spline of ksl_vec3_spline_natural() or ksl_vec3_spline_clamped() at t, which runs from 0 at keys[0] to n - 1 at keys[n - 1], together with
\[ p'(t) = p_{k+1} - p_k - \frac{3(1 - u)^2 - 1}{6}\,\underline{m}_k + \frac{3u^2 - 1}{6}\,\underline{m}_{k+1}, \qquad p''(t) = (1 - u)\,\underline{m}_k + u\,\underline{m}_{k+1}. \]t outside [0, n - 1] is clamped. dpo and ddpo may be NULL.
- Parameters:
n – [in] number of keys, at least 2
keys – [in] key points
m – [in] second derivatives from ksl_vec3_spline_natural() or ksl_vec3_spline_clamped()
t – [in] key parameter
po – [out] point p(t)
dpo – [out] first derivative p’(t), or NULL
ddpo – [out] second derivative p’’(t), or NULL
Single precision¶
3 dimensional single precision vector |
|
vec3f constructor |
|
initialize n ksl_vec3f_t single precision vectors datastructures on the heap |
|
compute the norm of a single precision vector |
|
Normalize a single precision vector. |
|
Normalize a single precision vector leaving original datastructure unmodified; results are returned in second datastructure. |
|
Scale a single precision vector. |
|
Scale a single precision vector, returning results in second vector. |
|
Copy a single precision ksl_vec3f_t vi into ksl_vec3f_t vo. |
|
Swap single precision vectors vio1 and vio2. |
|
Copy inverse of single precision ksl_vec3f_t vi into vo. |
|
invert a single precision vector in place |
|
single precision dot product of two vectors |
|
Computes the single precision product of the inverse of a vector and a scalar. |
|
Computes the single precision product of a vector and a scalar. |
|
Adds two single precision vectors. |
|
Subtract two single precision vectors. |
|
axpy (ax plus y stored in y) for single precision vectors |
|
single precision subtract v1i from v2i in place. This is a variation of axpy where a = -1 |
|
Adds two single precision vectors. This is a variation of axpy where a = 1. |
|
Compute single precision cross product of v1i with v2i. |
|
Compute single precision cross product of v1i with v2i^-1. |
|
Add a single precision Vector with a primitive translation along x-axis. |
|
Add a single precision Vector with the inverse of a translation along the x-axis. |
|
Add a single precision Vector with a translation along the y-axis. |
|
Add a single precision Vector with the inverse of a translation along the y-axis. |
|
Add a single precision Vector with a translation along the z-axis. |
|
Add a single precision vector with the inverse of a translation along the z-axis. |
-
union ksl_vec3f_t¶
- #include <types.h>
3 dimensional single precision vector
-
static inline ksl_vec3f_t ksl_vec3f(const float x, const float y, const float z)¶
vec3f constructor
-
inline ksl_vec3f_t *ksl_vec3f_alloc(int)¶
initialize n ksl_vec3f_t single precision vectors datastructures on the heap
-
static inline float ksl_vec3f_l2norm(const ksl_vec3f_t *v)¶
compute the norm of a single precision vector
-
static inline void ksl_vec3f_normalize(ksl_vec3f_t *v)¶
Normalize a single precision vector.
- Parameters:
v – [in/out] vector to normalize
-
static inline void ksl_vec3f_normalized(const ksl_vec3f_t *v, ksl_vec3f_t *vo)¶
Normalize a single precision vector leaving original datastructure unmodified; results are returned in second datastructure.
- Parameters:
v – [in] vector to normalize
vo – [out] unit vector in the direction of v
-
static inline void ksl_vec3f_scale(ksl_vec3f_t *v, const float k)¶
Scale a single precision vector.
- Parameters:
v – [in,out] vector to scale in place
k – [in] scale factor
-
static inline void ksl_vec3f_scaled(const ksl_vec3f_t *v, const float k, ksl_vec3f_t *vo)¶
Scale a single precision vector, returning results in second vector.
- Parameters:
v – [in] vector to scale
k – [in] scale factor
vo – [out] scaled vector, k * v
-
static inline void ksl_vec3f_copy(const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Copy a single precision ksl_vec3f_t vi into ksl_vec3f_t vo.
\(V_i \rightarrow V_o\)
- Parameters:
vi – input vector \(V_i\)
vo – output vector \(V_o\)
-
static inline void ksl_vec3f_swap(ksl_vec3f_t *vio1, ksl_vec3f_t *vio2)¶
Swap single precision vectors vio1 and vio2.
\(V_io1 \rightarrow V_io2\) \(V_io2 \rightarrow V_io1\)
- Parameters:
vio1 – input/output vector \(V_io1\)
vio2 – input/output vector \(V_io2\)
-
static inline void ksl_vec3f_inverted(const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Copy inverse of single precision ksl_vec3f_t vi into vo.
\(-V_i \rightarrow V_o\)
- Parameters:
vi – [in] input vector \(V_i\)
vo – [out] output vector \(V_o\)
-
static inline void ksl_vec3f_invert(ksl_vec3f_t *vi)¶
invert a single precision vector in place
\(-V_i \rightarrow V_i\)
- Parameters:
vi – [in/out] input vector \(V_i\)
-
static inline float ksl_dot_vvf(const ksl_vec3f_t *vi0, const ksl_vec3f_t *vi1)¶
single precision dot product of two vectors
\( V_i0 \cdot V_i1 \rightarrow V_o\)
- Parameters:
vi0 – first input vector
vi1 – second input vector
-
static inline void ksl_product_avinvf(const float ki, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Computes the single precision product of the inverse of a vector and a scalar.
\(-V_i * k_i \rightarrow V_o\)
- Parameters:
vi – [in] A 3x1 input vector
ki – [in] double precision scalar
vo – [out] the results are stored in vo[3]
-
static inline void ksl_product_avf(const float ki, const ksl_vec3f_t *vi, ksl_vec3f_t *vo)¶
Computes the single precision product of a vector and a scalar.
\(V_i * k_i \rightarrow V_o\)
- Parameters:
ki – [in] scalar
vi – [in] vector
vo – [out] product ki * vi
-
static inline void ksl_add_vvf(const ksl_vec3f_t *v1i, const ksl_vec3f_t *v2i, ksl_vec3f_t *vo)¶
Adds two single precision vectors.
Add 3 by 1 column matrices v1i and v2i and store results in vo.
\(V_{1i} + V_{2i} \rightarrow V_o\)
- Parameters:
v1i – a first column vector input
v2i – second column vector
vo – the results of v1i + v2i are stored in vo
-
static inline void ksl_subtract_vvf(const ksl_vec3f_t *v1i, const ksl_vec3f_t *v2i, ksl_vec3f_t *vo)¶
Subtract two single precision vectors.
Add 3 by 1 column matrix v1i to v2i
\(V_{2i} = V_{1i} - V_{2i}\)
- Parameters:
v1i – [in]
v2i – [in]
vo – [out]
-
static inline void ksl_axpy_vvf(const float k, const ksl_vec3f_t *v1x, ksl_vec3f_t *v2y)¶
axpy (ax plus y stored in y) for single precision vectors
Add 3 by 1 column matrix v1x scaled by k to v2y.
\(V_{2y} += k V_{1x} \)
- Parameters:
k – [in] scale factor
v1x – [in] vector to scale and add
v2y – [in,out] vector that k * v1x is added to
-
static inline void ksl_nxpy_vvf(const ksl_vec3f_t *v1i, ksl_vec3f_t *v2i)¶
single precision subtract v1i from v2i in place. This is a variation of axpy where a = -1
\(V_{2i} -= V_{1i} \)
- Parameters:
v1i – [in]
v2i – [in/out]
-
static inline void ksl_xpy_vvf(const ksl_vec3f_t *v1i, ksl_vec3f_t *v2i)¶
Adds two single precision vectors. This is a variation of axpy where a = 1.
Add 3 by 1 column matrix v1i to v2i
\(V_{2i} += V_{1i} \)
- Parameters:
v1i – [in] vector to add
v2i – [in,out] vector that v1i is added to
-
static inline void ksl_cross_vvf(const ksl_vec3f_t *v1i, const ksl_vec3f_t *v2i, ksl_vec3f_t *vo)¶
Compute single precision cross product of v1i with v2i.
\(V_{1i} \times V_{2i} \rightarrow V_o\)
- Parameters:
v1i – a first 3x1 vector
v2i – a second 3x1 vector
vo – the results are stored in vo
-
static inline void ksl_cross_vvinvf(const ksl_vec3f_t *v1i, const ksl_vec3f_t *v2i, ksl_vec3f_t *vo)¶
Compute single precision cross product of v1i with v2i^-1.
\(V_{1i} \times V_{2i} \rightarrow V_o\)
- Parameters:
v1i – [in] a first 3x1 vector
v2i – [in] a second 3x1 vector
vo – [out] results are stored in vo
-
static inline void ksl_add_vvxf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision Vector with a primitive translation along x-axis.
Computes the result of a general 3-d translation, followed by a translation along the x axis using sparse algebra.
\(t_{i} + t_{x} \rightarrow t_o\)
is equivalent to:
\(t_{i} \rightarrow t_o\)
\(t_o[0] + t_x \rightarrow t_o[0]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvxinvf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision Vector with the inverse of a translation along the x-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the x axis using sparse algebra.
\(t_{i} + t_{x} \rightarrow t_o\)
is equivalent to:
\(t_{i} \rightarrow t_o\)
\(t_o[0] + t_x \rightarrow t_o[0]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvyf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision Vector with a translation along the y-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the y axis using sparse algebra.
\(t_{i} + t_{y} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[1] + t_y \rightarrow t_o[1]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvyinvf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision Vector with the inverse of a translation along the y-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the y axis using sparse algebra.
\(t_{i} + t_{y} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[1] - t_y \rightarrow t_o[1]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvzf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision Vector with a translation along the z-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the z axis using sparse algebra.
\(t_{i} + t_{z} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[2] + t_z \rightarrow t_o[2]\)
- Parameters:
t1i – a pointer to a general 3-d translation
t2i – a pointer to a double
to – a pointer to a general 3-d translation where the result is stored.
-
static inline void ksl_add_vvzinvf(const ksl_vec3f_t *t1i, const float t2i, ksl_vec3f_t *to)¶
Add a single precision vector with the inverse of a translation along the z-axis.
Computes the result of a general 3-d transformation, followed by a tranformation along the z axis using sparse algebra.
\(t_{i} + t_{z} \rightarrow t_o\)
is equivalent to:
\(t_{i}[0:2] \rightarrow t_o[0:2]\)
\(t_o[2] - t_z \rightarrow t_o[2]\)
- Parameters:
t1i – [in] a pointer to a general 3-d translation
t2i – [in] translation along z-axis
to – [out] a pointer to a general 3-d translation where the result is stored.
Integer¶
3 dimensional integer vector |
|
vec3i constructor |
|
initialize n ksl_vec3i_t vectors of integers on the heap |
|
Test whether two integer 3-vectors are equal. |
-
union ksl_vec3i_t¶
- #include <types.h>
3 dimensional integer vector
-
static inline ksl_vec3i_t ksl_vec3i(const int x, const int y, const int z)¶
vec3i constructor
-
inline ksl_vec3i_t *ksl_vec3i_alloc(int)¶
initialize n ksl_vec3i_t vectors of integers on the heap
-
static inline bool ksl_vec3i_isEqual(const ksl_vec3i_t *v1, const ksl_vec3i_t *v2)¶
Test whether two integer 3-vectors are equal.
- Parameters:
v1 – [in] first vector
v2 – [in] second vector
- Returns:
true if all three components are equal