22 #ifndef __ND_TEMPLATE_VECTOR_H__
23 #define __ND_TEMPLATE_VECTOR_H__
25 #include "ndCoreStdafx.h"
27 #include "ndClassAlloc.h"
38 :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (ptr[3])
44 :m_x(copy.m_x), m_y(copy.m_y), m_z(copy.m_z), m_w (copy.m_w)
50 :m_x(x), m_y(y), m_z(z), m_w (w)
54 T& operator[] (ndInt32 i)
61 const T& operator[] (ndInt32 i)
const
110 T val(m_x + m_y + m_z + m_w);
116 return *
this + A * B;
121 return *
this - A * B;
128 m_z * B.m_x - m_x * B.m_z,
129 m_x * B.m_y - m_y * B.m_x, m_w);
138 for (ndInt32 i = 0; i < 4; ++i) {
142 array[3][i] = T(1.0f);
147 for (ndInt32 i = 0; i < 4; ++i)
149 for (ndInt32 j = 0; j < 3; ++j)
152 for (ndInt32 k = 0; k < 4; ++k)
156 cofactor[j][k0] = array[j][k];
161 T x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]);
162 T y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]);
163 T z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]);
166 normal[i] = sign * det;
176 T val (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w);
183 return ndMax(ndMax(m_x, m_y), ndMax(m_z, m_w));
188 return ndTemplateVector<T>((m_x > data.m_x) ? m_x : data.m_x, (m_y > data.m_y) ? m_y : data.m_y, (m_z > data.m_z) ? m_z : data.m_z, (m_w > data.m_w) ? m_w : data.m_w);
193 return ndTemplateVector<T>((m_x < data.m_x) ? m_x : data.m_x, (m_y < data.m_y) ? m_y : data.m_y, (m_z < data.m_z) ? m_z : data.m_z, (m_w < data.m_w) ? m_w : data.m_w);
198 void Trace (
char*
const name)
const
200 ndTrace ((
"%s %f %f %f %f\n", name, m_x, m_y, m_z, m_w));