Zephyr Scientific Library (zscilib)
Data Structures | Enumerations | Functions
quaternions.h File Reference

API header file for quaternions in zscilib. More...

#include <zsl/zsl.h>
#include <zsl/matrices.h>
#include <zsl/orientation/euler.h>

Go to the source code of this file.

Data Structures

struct  zsl_quat
 Represents a quaternion, a 4D structure capable of representing 3D rigid body orientations. More...
 

Enumerations

enum  zsl_quat_type {
  ZSL_QUAT_TYPE_EMPTY = 0,
  ZSL_QUAT_TYPE_IDENTITY = 1
}
 Represents various 'types' of quaternions that can be initialised with the zsl_quat_init function. More...
 

Functions

void zsl_quat_init (struct zsl_quat *q, enum zsl_quat_type type)
 Convenience function to set the supplied quaternion into a known state. More...
 
zsl_real_t zsl_quat_magn (struct zsl_quat *q)
 Calculates the magnitude (or length) of the quaternion, a scalar value equal to the square root of the sum of the squares of the four components. More...
 
int zsl_quat_to_unit (struct zsl_quat *q, struct zsl_quat *qn)
 Normalises the input to be a "unit" or "rotation" quaternion, AKA a versor, such that the square root of the sum of the squares of the four componeents, sqrt(r^2+i^2+j^2+k^2), equals 1.0. This normalisation process is what allows a quaternion to represent an rotation. More...
 
int zsl_quat_to_unit_d (struct zsl_quat *q)
 Normalises to unit quaternion (destructive). More...
 
bool zsl_quat_is_unit (struct zsl_quat *q)
 Verifies that this is a "unit" quaternion, meaning that it has a magnitude of 1, where sqrt(r^2+i^2+j^2+k^2) = 1.0. More...
 
int zsl_quat_scale (struct zsl_quat *q, zsl_real_t s, struct zsl_quat *qs)
 Multiples each element in the quaternion by a scalar value. More...
 
int zsl_quat_scale_d (struct zsl_quat *q, zsl_real_t s)
 Multiples each element in the quaternion by a scalar value (destructive). More...
 
int zsl_quat_mult (struct zsl_quat *qa, struct zsl_quat *qb, struct zsl_quat *qm)
 Multiples the two supplied unit quaternions (a * b) together, and stores the results in qm. More...
 
int zsl_quat_exp (struct zsl_quat *q, struct zsl_quat *qe)
 Calculates the exponential of a unit quaternion. More...
 
int zsl_quat_log (struct zsl_quat *q, struct zsl_quat *ql)
 Calculates the natural logarithm of a unit quaternion. More...
 
int zsl_quat_pow (struct zsl_quat *q, zsl_real_t pow, struct zsl_quat *qout)
 Multiples the supplied unit quaternions to the specified exponent, and stores the results in qout (where qout = qa^pow). More...
 
int zsl_quat_conj (struct zsl_quat *q, struct zsl_quat *qc)
 Calculates the complex conjugate of 'q'. More...
 
int zsl_quat_inv (struct zsl_quat *q, struct zsl_quat *qi)
 Calculates the multiplicative inverse of unit quaternion 'q'. More...
 
int zsl_quat_inv_d (struct zsl_quat *q)
 Inverts unit quaternion 'q' (destructive). More...
 
int zsl_quat_diff (struct zsl_quat *qa, struct zsl_quat *qb, struct zsl_quat *qd)
 Calculates the rotation (qd) from qa to qb using the multiplicative inverse, such that qb = qa * qd. More...
 
int zsl_quat_rot (struct zsl_quat *qa, struct zsl_quat *qb, struct zsl_quat *qr)
 Rotates the pure quaternion qb using the quaternion qa. More...
 
int zsl_quat_lerp (struct zsl_quat *qa, struct zsl_quat *qb, zsl_real_t t, struct zsl_quat *qi)
 Linear interpolation (LERP). More...
 
int zsl_quat_slerp (struct zsl_quat *qa, struct zsl_quat *qb, zsl_real_t t, struct zsl_quat *qi)
 Spherical linear interpolation (SLERP). More...
 
int zsl_quat_from_ang_vel (struct zsl_vec *w, struct zsl_quat *qin, zsl_real_t t, struct zsl_quat *qout)
 Updates an orientation quaternion with new information in form of angular velocity and time elapsed. More...
 
int zsl_quat_from_ang_mom (struct zsl_vec *l, struct zsl_quat *qin, zsl_real_t *i, zsl_real_t t, struct zsl_quat *qout)
 Updates an orientation quaternion with new information in form of angular momentum, moment of inertia and time elapsed. More...
 
int zsl_quat_to_euler (struct zsl_quat *q, struct zsl_euler *e)
 Converts a unit quaternion to it's equivalent Euler angle. Euler values expressed in radians. More...
 
int zsl_quat_from_euler (struct zsl_euler *e, struct zsl_quat *q)
 Converts a Euler angle to a unit quaternion. Euler values expressed in radians. More...
 
int zsl_quat_to_rot_mtx (struct zsl_quat *q, struct zsl_mtx *m)
 Converts a unit quaternion to it's equivalent rotation matrix. More...
 
int zsl_quat_from_rot_mtx (struct zsl_mtx *m, struct zsl_quat *q)
 Converts a rotation matrix to it's equivalent unit quaternion. More...
 
int zsl_quat_to_axis_angle (struct zsl_quat *q, struct zsl_vec *a, zsl_real_t *b)
 Converts a unit quaternion to it's axis-angle rotation equivalent. More...
 
int zsl_quat_from_axis_angle (struct zsl_vec *a, zsl_real_t *b, struct zsl_quat *q)
 Converts axis-angle rotation to its unit quaternion equivalent. More...
 
int zsl_quat_print (struct zsl_quat *q)
 Print the supplied quaternion using printf in a human-readable manner. More...
 

Detailed Description

API header file for quaternions in zscilib.

This file contains the zscilib quaternion APIs

Definition in file quaternions.h.