26 c[0] = c[1] = c[2] = 0.0f;
37 for (i = 0; i < 4; ++
i) {
55 l = sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);
57 c[0] = c[1] = c[2] = 0.0f;
62 c[0] = (float)s * axis[0];
63 c[1] = (float)s * axis[1];
64 c[2] = (float)s * axis[2];
65 c[3] = (float)
cos(omega);
76 for (i = 0; i < 4; ++
i) {
88 for (i = 0; i < 3; ++
i) {
105 c[0] = qa[3] * qb[0] + qa[0] * qb[3] + qa[1] * qb[2] - qa[2] * qb[1];
106 c[1] = qa[3] * qb[1] + qa[1] * qb[3] + qa[2] * qb[0] - qa[0] * qb[2];
107 c[2] = qa[3] * qb[2] + qa[2] * qb[3] + qa[0] * qb[1] - qa[1] * qb[0];
108 c[3] = qa[3] * qb[3] - qa[0] * qb[0] - qa[1] * qb[1] - qa[2] * qb[2];
118 for (i = 0; i < 4; ++
i) {
131 l = sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2] + c[3] * c[3]);
133 c[0] = c[1] = c[2] = 0.0f;
138 for (i = 0; i < 4; ++
i) {
139 c[
i] = (float)(c[i] * m);
152 l = sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2] + c[3] * c[3]);
154 c[0] = c[1] = c[2] = 0.0f;
158 c[0] = (float)(-c[0] * m);
159 c[1] = (float)(-c[1] * m);
160 c[2] = (float)(-c[2] * m);
161 c[3] = (float)(c[3] * m);
171 return(a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]);
177 return(c[0]*c[0] + c[1]*c[1] + c[2]*c[2] + c[3]*c[3]);
185 s = sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2]);
194 for (i = 0; i < 3; ++
i) {
195 c[
i] = (float)(c[i] * t);
217 om = sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2]);
221 sinom =
sin(om) / om;
225 for (i = 0; i < 3; ++
i) {
226 c[
i] = (float)(c[i] * sinom);
228 c[3] = (float)
cos(om);
241 l = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
250 sp =
sin((1.0
f - t) * om) / sinom;
251 sq =
sin(t * om) / sinom;
257 for (i = 0; i < 4; ++
i) {
258 c[
i] = (float)(sp * a[i] + sq * b[i]);
276 float dn[4], dp[4],
x[4];
282 for (i = 0; i < 4; i++) {
283 x[
i] = -1.0f / 4.0f * (dn[
i] + dp[
i]);
292 printf(
"%f %f %f %f\n", q[0], q[1], q[2], q[3]);
LIB3DSAPI void lib3ds_quat_slerp(float c[4], float a[4], float b[4], float t)
LIB3DSAPI void lib3ds_quat_squad(float c[4], float a[4], float p[4], float q[4], float b[4], float t)
LIB3DSAPI void lib3ds_quat_exp(float c[4])
GLboolean GLboolean GLboolean GLboolean a
LIB3DSAPI float lib3ds_quat_norm(float c[4])
LIB3DSAPI void lib3ds_quat_neg(float c[4])
LIB3DSAPI void lib3ds_quat_identity(float c[4])
LIB3DSAPI void lib3ds_quat_ln_dif(float c[4], float a[4], float b[4])
LIB3DSAPI void lib3ds_quat_inv(float c[4])
void lib3ds_quat_dump(float q[4])
LIB3DSAPI void lib3ds_quat_scalar(float c[4], float k)
LIB3DSAPI void lib3ds_quat_ln(float c[4])
LIB3DSAPI float lib3ds_quat_dot(float a[4], float b[4])
LIB3DSAPI void lib3ds_quat_normalize(float c[4])
LIB3DSAPI void lib3ds_quat_cnj(float c[4])
GLdouble GLdouble GLdouble GLdouble q
LIB3DSAPI void lib3ds_quat_mul(float c[4], float a[4], float b[4])
GLdouble GLdouble GLdouble b
LIB3DSAPI void lib3ds_quat_tangent(float c[4], float p[4], float q[4], float n[4])
LIB3DSAPI void lib3ds_quat_axis_angle(float c[4], float axis[3], float angle)
LIB3DSAPI void lib3ds_quat_copy(float dest[4], float src[4])