Quaternions are used to perform linear algebra rotations.
More...
|
EAPI EPhysics_Quaternion * | ephysics_quaternion_new (void) |
| Create a new quaternion.
|
|
EAPI void | ephysics_quaternion_get (const EPhysics_Quaternion *quat, double *x, double *y, double *z, double *w) |
| Get quaternion values.
|
|
EAPI void | ephysics_quaternion_axis_angle_get (const EPhysics_Quaternion *quat, double *nx, double *ny, double *nz, double *a) |
| Get quaternion axis and angle.
|
|
EAPI void | ephysics_quaternion_set (EPhysics_Quaternion *quat, double x, double y, double z, double w) |
| Set quaternion values.
|
|
EAPI void | ephysics_quaternion_axis_angle_set (EPhysics_Quaternion *quat, double nx, double ny, double nz, double a) |
| Set quaternion using axis angle notation.
|
|
EAPI void | ephysics_quaternion_euler_set (EPhysics_Quaternion *quat, double yaw, double pitch, double roll) |
| Set quaternion using Euler angles.
|
|
EAPI void | ephysics_quaternion_normalize (EPhysics_Quaternion *quat) |
| Normalize the quaternion.
|
|
EAPI void | ephysics_quaternion_invert (EPhysics_Quaternion *quat) |
| Invert the quaternion.
|
|
EAPI void | ephysics_quaternion_scale (EPhysics_Quaternion *quat, double scale) |
| Scale the quaternion.
|
|
EAPI void | ephysics_quaternion_inverse_scale (EPhysics_Quaternion *quat, double scale) |
| Inversely scale the quaternion.
|
|
EAPI EPhysics_Quaternion * | ephysics_quaternion_sum (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result) |
| Returns a sum of two quaternions.
|
|
EAPI EPhysics_Quaternion * | ephysics_quaternion_diff (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result) |
| Returns a difference between two quaternions.
|
|
EAPI EPhysics_Quaternion * | ephysics_quaternion_multiply (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result) |
| Multiply two quaternions.
|
|
EAPI EPhysics_Quaternion * | ephysics_quaternion_slerp (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, double ratio, EPhysics_Quaternion *result) |
| Return the quaternion which is the result of Spherical Linear Interpolation between two quaternions.
|
|
EAPI double | ephysics_quaternion_dot (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2) |
| Return the dot product between two quaternions.
|
|
EAPI double | ephysics_quaternion_angle_get (const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2) |
| Return the angle between two quaternions.
|
|
EAPI double | ephysics_quaternion_length_get (const EPhysics_Quaternion *quat) |
| Return the length of the quaternion.
|
|
EAPI double | ephysics_quaternion_length2_get (const EPhysics_Quaternion *quat) |
| Return the length squared of the quaternion.
|
|
Quaternions are used to perform linear algebra rotations.
Functions regarding rotation, like ephysics_body_rotation_set() and ephysics_body_rotation_get() would need that. Quaternions can be used to rotate evas maps as well, with evas_map_util_quat_rotate(), but in this case quaternion values need to be get with ephysics_quaternion_get(), since evas don't accept EPhysics_Quaternion type.
A quaternion can be created with ephysics_quaternion_new(), and many operations can be performed with that, as:
◆ EPhysics_Quaternion
Quaternion handle, represents a quaternion to be used to rotate bodies.
Created with ephysics_quaternion_new() and deleted with free().
◆ ephysics_quaternion_new()
◆ ephysics_quaternion_get()
EAPI void ephysics_quaternion_get |
( |
const EPhysics_Quaternion * |
quat, |
|
|
double * |
x, |
|
|
double * |
y, |
|
|
double * |
z, |
|
|
double * |
w |
|
) |
| |
◆ ephysics_quaternion_axis_angle_get()
EAPI void ephysics_quaternion_axis_angle_get |
( |
const EPhysics_Quaternion * |
quat, |
|
|
double * |
nx, |
|
|
double * |
ny, |
|
|
double * |
nz, |
|
|
double * |
a |
|
) |
| |
◆ ephysics_quaternion_set()
EAPI void ephysics_quaternion_set |
( |
EPhysics_Quaternion * |
quat, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z, |
|
|
double |
w |
|
) |
| |
◆ ephysics_quaternion_axis_angle_set()
EAPI void ephysics_quaternion_axis_angle_set |
( |
EPhysics_Quaternion * |
quat, |
|
|
double |
nx, |
|
|
double |
ny, |
|
|
double |
nz, |
|
|
double |
a |
|
) |
| |
◆ ephysics_quaternion_euler_set()
EAPI void ephysics_quaternion_euler_set |
( |
EPhysics_Quaternion * |
quat, |
|
|
double |
yaw, |
|
|
double |
pitch, |
|
|
double |
roll |
|
) |
| |
◆ ephysics_quaternion_normalize()
Normalize the quaternion.
A normalized quaternion is such that x^2 + y^2 + z^2 + w^2 = 1.
- Parameters
-
quat | Quaternion to be normalized. |
- Examples
- test_rotating_forever.c.
◆ ephysics_quaternion_invert()
Invert the quaternion.
- Parameters
-
quat | Quaternion to be inverted. |
◆ ephysics_quaternion_scale()
◆ ephysics_quaternion_inverse_scale()
◆ ephysics_quaternion_sum()
Returns a sum of two quaternions.
- Parameters
-
quat1 | First quaternion to sum. |
quat2 | Second quaternion to sum. |
result | Quaternion used to store the result. If it's NULL , a new quaternion will be allocated (and should be freed after usage). |
- Returns
- The sum quaternion or
NULL
on error.
◆ ephysics_quaternion_diff()
Returns a difference between two quaternions.
- Parameters
-
quat1 | First quaternion. |
quat2 | Second quaternion. |
result | Quaternion used to store the result. If it's NULL , a new quaternion will be allocated (and should be freed after usage). |
- Returns
- The difference between
quat1
and quat2
, or NULL
on error.
◆ ephysics_quaternion_multiply()
Multiply two quaternions.
- Parameters
-
quat1 | First quaternion. |
quat2 | Second quaternion. |
result | Quaternion used to store the result. If it's NULL , a new quaternion will be allocated (and should be freed after usage). |
- Returns
- The
quat1
multiplied by quat2
on the right, or NULL
on error.
- Examples
- test_rotating_forever.c.
◆ ephysics_quaternion_slerp()
Return the quaternion which is the result of Spherical Linear Interpolation between two quaternions.
Slerp interpolates assuming constant velocity.
- Parameters
-
quat1 | First quaternion. |
quat2 | Second quaternion. |
ratio | The ratio between quat1 and quat2 to interpolate. If ratio = 0, the result is quat1 , if ratio = 1, the result is quat2 . |
result | Quaternion used to store the result. If it's NULL , a new quaternion will be allocated (and should be freed after usage). |
- Returns
- The result of slerp between
quat1
and quat2
, or NULL
on error.
◆ ephysics_quaternion_dot()
Return the dot product between two quaternions.
- Parameters
-
quat1 | First quaternion. |
quat2 | Second quaternion. |
- Returns
- The dot product between
quat1
and quat2
or 0
on error.
◆ ephysics_quaternion_angle_get()
Return the angle between two quaternions.
- Parameters
-
quat1 | First quaternion. |
quat2 | Second quaternion. |
- Returns
- The angle between
quat1
and quat2
or 0
on error.
◆ ephysics_quaternion_length_get()
Return the length of the quaternion.
- Parameters
-
quat | Quaternion to get length of. |
- Returns
- The length of
quat
or 0
on error.
◆ ephysics_quaternion_length2_get()
Return the length squared of the quaternion.
- Parameters
-
quat | Quaternion to get length of. |
- Returns
- The length of
quat
or 0
on error.