22 #ifndef __ND_CUDA_MATRIX3x3_H__
23 #define __ND_CUDA_MATRIX3x3_H__
25 #include "ndCudaVector.h"
26 #include "ndCudaIntrinsics.h"
51 return ndCudaMatrix3x3(A.RotateVector(m_front), A.RotateVector(m_up), A.RotateVector(m_right));
56 return ndCudaVector((m_front * v).AddHorizontal(), (m_up * v).AddHorizontal(), (m_right * v).AddHorizontal(), 0.0f);
61 return m_front.Scale(v.x) + m_up.Scale(v.y) + m_right.Scale(v.z);
68 for (
int i = 0; i < 3; ++i)
70 float pivot = cuAbs(tmp.m_data[i].GetElement(i));
71 if (pivot <
float(0.01f))
74 for (
int j = i + 1; j < 3; ++j)
76 float pivot1 = cuAbs(tmp.m_data[j].GetElement(i));
86 float a0 = ret.GetElement(i);
87 ret.SetElement(i, ret.GetElement(permute));
88 ret.SetElement(permute, a0);
89 cuSwap(tmp.m_data[i], tmp.m_data[permute]);
93 for (
int j = i + 1; j < 3; ++j)
95 const ndCudaVector scale(tmp.m_data[j].GetElement(i) / tmp.m_data[i].GetElement(i));
96 tmp.m_data[j] = tmp.m_data[j] - tmp.m_data[i] * scale;
97 ret.SetElement(j, ret.GetElement(j) - ret.GetElement(i) * scale.x);
98 tmp.m_data[j].SetElement(i, 0.0f);
102 for (
int i = 2; i >= 0; --i)
105 ret.SetElement(i, (ret.GetElement(i) - pivot.AddHorizontal() + tmp.m_data[i].GetElement(i) * ret.GetElement(i)) / tmp.m_data[i].GetElement(i));