Triton
Visual simulation library for ocean rendering.
Matrix3.h
Go to the documentation of this file.
1// Copyright (c) 2004-2011 Sundog Software, LLC. All rights reserved worldwide.
2
7#ifdef SWIG
8%module TritonMatrix3
9%include "Vector3.h"
10#define TRITONAPI
11%{
12#include "Matrix3.h"
13using namespace Triton;
14%}
15#endif
16
17#ifndef TRITON_MATRIX3_H
18#define TRITON_MATRIX3_H
19
20#include "MemAlloc.h"
21#include "Vector3.h"
22
23#pragma pack(push)
24#pragma pack(8)
25
26namespace Triton
27{
29class Matrix3 : public MemObject
30{
31public:
32 static Matrix3 Identity;
33
36 }
37
39 Matrix3(double e11, double e12, double e13,
40 double e21, double e22, double e23,
41 double e31, double e32, double e33) {
42 elem[0][0] = e11;
43 elem[0][1] = e12;
44 elem[0][2] = e13;
45 elem[1][0] = e21;
46 elem[1][1] = e22, elem[1][2] = e23;
47 elem[2][0] = e31, elem[2][1] = e32, elem[2][2] = e33;
48 }
49
51 Matrix3(double *m) {
52 int i = 0;
53 for (int row = 0; row < 3; row++) {
54 for (int col = 0; col < 3; col++) {
55 elem[row][col] = m[i++];
56 }
57 }
58 }
59
62 }
63
65 void TRITONAPI ToFloatArray(float val[9]) const {
66 int i = 0;
67 for (int row = 0; row < 3; row++) {
68 for (int col = 0; col < 3; col++) {
69 val[i++] = (float)elem[row][col];
70 }
71 }
72 }
73
76 void TRITONAPI FromRx(double rad);
77
80 void TRITONAPI FromRy(double rad);
81
84 void TRITONAPI FromRz(double rad);
85
88 void TRITONAPI FromXYZ(double Rx, double Ry, double Rz);
89
91 Matrix3 TRITONAPI operator * (const Matrix3& mat);
92
94 Vector3 TRITONAPI operator* (const Vector3& rkVector) const;
95
97 friend Vector3 TRITONAPI operator * (const Vector3& vec, const Matrix3& mat);
98
100 Matrix3 TRITONAPI Transpose() const;
101
103 double elem[3][3];
104};
105}
106
107#pragma pack(pop)
108
109#endif
Implements a 3x3 matrix and its operations.
Memory allocation interface for SilverLining.
A 3D Vector class and its operations.
A simple 3x3 matrix class and its operations.
Definition: Matrix3.h:30
void TRITONAPI ToFloatArray(float val[9]) const
Returns a static 3x3 float array in row major order.
Definition: Matrix3.h:65
Matrix3(double *m)
Constructor that takes an array of 9 doubles in row-major order.
Definition: Matrix3.h:51
void TRITONAPI FromXYZ(double Rx, double Ry, double Rz)
Populates the matrix as a series of rotations about the X, Y, and Z axes (in that order) by specified...
void TRITONAPI FromRz(double rad)
Populates the matrix to model a rotation about the Z axis by a give amount, in radians.
Matrix3()
Default contructor; performs no initialization for efficiency.
Definition: Matrix3.h:35
void TRITONAPI FromRy(double rad)
Populates the matrix to model a rotation about the Y axis by a given amount, in radians.
Matrix3 TRITONAPI Transpose() const
Caculate the inverse of the matrix.
void TRITONAPI FromRx(double rad)
Populates the matrix to model a rotation about the X axis by a given amount, in radians.
double elem[3][3]
The data members are public for convenience.
Definition: Matrix3.h:103
~Matrix3()
Destructor.
Definition: Matrix3.h:61
friend Vector3 TRITONAPI operator*(const Vector3 &vec, const Matrix3 &mat)
Multiplies a 1x3 vector by a matrix, yielding a 1x3 vector.
Matrix3(double e11, double e12, double e13, double e21, double e22, double e23, double e31, double e32, double e33)
Constructor that instantiates the 3x3 matrix with initial values.
Definition: Matrix3.h:39
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36