22 #ifndef __ND_CUDA_QUAT_H__
23 #define __ND_CUDA_QUAT_H__
25 #include "ndCudaVector.h"
26 #include "ndCudaMatrix3x3.h"
36 inline __device__ __host__
ndCudaQuat(
float x,
float y,
float z,
float w)
56 const float sinAng = sinf(angle);
57 x = unitAxis.x * sinAng;
58 y = unitAxis.y * sinAng;
59 z = unitAxis.z * sinAng;
72 const float x2 = x * quat1.x;
73 const float y2 = y * quat1.y;
74 const float z2 = z * quat1.z;
76 const float xy = x * quat1.y;
77 const float xz = x * quat1.z;
78 const float xw = x * quat1.w;
79 const float yz = y * quat1.z;
80 const float yw = y * quat1.w;
81 const float zw = z * quat1.w;
83 const ndCudaVector front(1.0f - y2 - z2, xy + zw, xz - yw, 0.0f);
84 const ndCudaVector up (xy - zw, 1.0f - x2 - z2, yz + xw, 0.0f);
85 const ndCudaVector right(xz + yw, yz - xw, 1.0f - x2 - y2, 0.0f);
89 inline ndCudaQuat __device__ __host__ Normalize()
const
91 return ndCudaVector::Normalize();