RenderScript Quaternion Functions

Overview

The following functions manipulate quaternions.

Summary

Functions
rsQuaternionAdd Add two quaternions
rsQuaternionConjugate Conjugate a quaternion
rsQuaternionDot Dot product of two quaternions
rsQuaternionGetMatrixUnit Get a rotation matrix from a quaternion
rsQuaternionLoadRotate Create a rotation quaternion
rsQuaternionLoadRotateUnit Quaternion that represents a rotation about an arbitrary unit vector
rsQuaternionMultiply Multiply a quaternion by a scalar or another quaternion
rsQuaternionNormalize Normalize a quaternion
rsQuaternionSet Create a quaternion
rsQuaternionSlerp Spherical linear interpolation between two quaternions

rsQuaternionAdd : Add two quaternions

Parameters
qDestination quaternion to add to.
rhsQuaternion to add.

Adds two quaternions, i.e. *q += *rhs;

rsQuaternionConjugate : Conjugate a quaternion

Parameters
qQuaternion to modify.

Conjugates the quaternion.

rsQuaternionDot : Dot product of two quaternions

Parameters
q0First quaternion.
q1Second quaternion.

Returns the dot product of two quaternions.

rsQuaternionGetMatrixUnit : Get a rotation matrix from a quaternion

Parameters
mResulting matrix.
qNormalized quaternion.

Computes a rotation matrix from the normalized quaternion.

rsQuaternionLoadRotate : Create a rotation quaternion

void rsQuaternionLoadRotate(rs_quaternion* q, float rot, float x, float y, float z);
Parameters
qDestination quaternion.
rotAngle to rotate by.
xX component of a vector.
yY component of a vector.
zZ component of a vector.

Loads a quaternion that represents a rotation about an arbitrary vector (doesn't have to be unit)

rsQuaternionLoadRotateUnit : Quaternion that represents a rotation about an arbitrary unit vector

void rsQuaternionLoadRotateUnit(rs_quaternion* q, float rot, float x, float y, float z);
Parameters
qDestination quaternion.
rotAngle to rotate by, in radians.
xX component of the vector.
yY component of the vector.
zZ component of the vector.

Loads a quaternion that represents a rotation about an arbitrary unit vector.

rsQuaternionMultiply : Multiply a quaternion by a scalar or another quaternion

Parameters
qDestination quaternion.
scalarScalar to multiply the quaternion by.
rhsQuaternion to multiply the destination quaternion by.

Multiplies a quaternion by a scalar or by another quaternion, e.g. *q = *q * scalar; or *q = *q * *rhs;.

rsQuaternionNormalize : Normalize a quaternion

Parameters
qQuaternion to normalize.

Normalizes the quaternion.

rsQuaternionSet : Create a quaternion

Parameters
qDestination quaternion.
wW component.
xX component.
yY component.
zZ component.
rhsSource quaternion.

Creates a quaternion from its four components or from another quaternion.

rsQuaternionSlerp : Spherical linear interpolation between two quaternions

Parameters
qResult quaternion from the interpolation.
q0First input quaternion.
q1Second input quaternion.
tHow much to interpolate by.

Performs spherical linear interpolation between two quaternions.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-02-10 UTC.