43 _FORCE_INLINE_
const Vector3& operator[](
int axis)
const {
45 return elements[axis];
47 _FORCE_INLINE_
Vector3& operator[](
int axis) {
49 return elements[axis];
58 _FORCE_INLINE_
float determinant()
const;
60 void from_z(
const Vector3& p_z);
62 _FORCE_INLINE_
Vector3 get_axis(
int p_axis)
const {
64 return Vector3( elements[0][p_axis], elements[1][p_axis], elements[2][p_axis] );
66 _FORCE_INLINE_
void set_axis(
int p_axis,
const Vector3& p_value) {
68 elements[0][p_axis]=p_value.x;
69 elements[1][p_axis]=p_value.y;
70 elements[2][p_axis]=p_value.z;
73 void rotate(
const Vector3& p_axis, real_t p_phi);
76 void scale(
const Vector3& p_scale );
81 void set_euler(
const Vector3& p_euler);
84 _FORCE_INLINE_ real_t tdotx(
const Vector3& v)
const {
85 return elements[0][0] * v[0] + elements[1][0] * v[1] + elements[2][0] * v[2];
87 _FORCE_INLINE_ real_t tdoty(
const Vector3& v)
const {
88 return elements[0][1] * v[0] + elements[1][1] * v[1] + elements[2][1] * v[2];
90 _FORCE_INLINE_ real_t tdotz(
const Vector3& v)
const {
91 return elements[0][2] * v[0] + elements[1][2] * v[1] + elements[2][2] * v[2];
94 bool operator==(
const Matrix3& p_matrix)
const;
95 bool operator!=(
const Matrix3& p_matrix)
const;
99 _FORCE_INLINE_
void operator*=(
const Matrix3& p_matrix);
102 int get_orthogonal_index()
const;
103 void set_orthogonal_index(
int p_index);
107 void get_axis_and_angle(
Vector3 &r_axis,real_t& r_angle)
const;
112 _FORCE_INLINE_
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
124 _FORCE_INLINE_
Vector3 get_column(
int i)
const {
126 return Vector3(elements[0][i],elements[1][i],elements[2][i]);
129 _FORCE_INLINE_
Vector3 get_row(
int i)
const {
131 return Vector3(elements[i][0],elements[i][1],elements[i][2]);
133 _FORCE_INLINE_
void set_row(
int i,
const Vector3& p_row) {
134 elements[i][0]=p_row.x;
135 elements[i][1]=p_row.y;
136 elements[i][2]=p_row.z;
139 _FORCE_INLINE_
void set_zero() {
148 elements[0].x * m[0].x + elements[1].x * m[1].x + elements[2].x * m[2].x,
149 elements[0].x * m[0].y + elements[1].x * m[1].y + elements[2].x * m[2].y,
150 elements[0].x * m[0].z + elements[1].x * m[1].z + elements[2].x * m[2].z,
151 elements[0].y * m[0].x + elements[1].y * m[1].x + elements[2].y * m[2].x,
152 elements[0].y * m[0].y + elements[1].y * m[1].y + elements[2].y * m[2].y,
153 elements[0].y * m[0].z + elements[1].y * m[1].z + elements[2].y * m[2].z,
154 elements[0].z * m[0].x + elements[1].z * m[1].x + elements[2].z * m[2].x,
155 elements[0].z * m[0].y + elements[1].z * m[1].y + elements[2].z * m[2].y,
156 elements[0].z * m[0].z + elements[1].z * m[1].z + elements[2].z * m[2].z);
158 Matrix3(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
160 set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
163 void orthonormalize();
164 Matrix3 orthonormalized()
const;
166 operator Quat()
const;
188 _FORCE_INLINE_
void Matrix3::operator*=(
const Matrix3& p_matrix) {
191 p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
192 p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]),
193 p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2]));
197 _FORCE_INLINE_
Matrix3 Matrix3::operator*(
const Matrix3& p_matrix)
const {
200 p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
201 p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]),
202 p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2]) );
209 elements[0].dot(p_vector),
210 elements[1].dot(p_vector),
211 elements[2].dot(p_vector)
218 (elements[0][0]*p_vector.x ) + ( elements[1][0]*p_vector.y ) + ( elements[2][0]*p_vector.z ),
219 (elements[0][1]*p_vector.x ) + ( elements[1][1]*p_vector.y ) + ( elements[2][1]*p_vector.z ),
220 (elements[0][2]*p_vector.x ) + ( elements[1][2]*p_vector.y ) + ( elements[2][2]*p_vector.z )
224 float Matrix3::determinant()
const {
226 return elements[0][0]*(elements[1][1]*elements[2][2] - elements[2][1]*elements[1][2]) -
227 elements[1][0]*(elements[0][1]*elements[2][2] - elements[2][1]*elements[0][2]) +
228 elements[2][0]*(elements[0][1]*elements[1][2] - elements[1][1]*elements[0][2]);