OpenCOVER
vruiMatrix.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8#ifndef VRUI_MATRIX_H
9#define VRUI_MATRIX_H
10
11#include <util/coTypes.h>
12#include <util/coVector.h>
13
14namespace vrui
15{
16
17using covise::coVector;
18
19class OPENVRUIEXPORT vruiMatrix
20{
21
22public:
24 {
25 }
26 virtual ~vruiMatrix();
27
28 virtual vruiMatrix *makeIdentity() = 0;
29 virtual vruiMatrix *makeEuler(double h, double p, double r) = 0;
30 virtual vruiMatrix *makeRotate(double degrees, double xAxis, double yAxis, double zAxis) = 0;
31 virtual vruiMatrix *makeScale(double x, double y, double z) = 0;
32 virtual vruiMatrix *makeTranslate(double x, double y, double z) = 0;
33 virtual vruiMatrix *makeInverse(const vruiMatrix *source) = 0;
34
35 virtual vruiMatrix *setTranslation(double x, double y, double z)
36 {
37 (*this)(3, 0) = x;
38 (*this)(3, 1) = y;
39 (*this)(3, 2) = z;
40 return this;
41 }
42
43 virtual vruiMatrix *preTranslated(double x, double y, double z, vruiMatrix *matrix) = 0;
44 virtual vruiMatrix *mult(const vruiMatrix *matrix) = 0;
45
46 virtual double &operator()(int row, int column) = 0;
47 virtual double operator()(int row, int column) const = 0;
48
49 virtual coVector getFullXformPt(const coVector &point) const = 0;
50
51 virtual coVector getTranslate() const
52 {
53 coVector rv;
54 rv[0] = (*this)(3, 0);
55 rv[1] = (*this)(3, 1);
56 rv[2] = (*this)(3, 2);
57 return rv;
58 }
59
60 virtual coVector getHPR() const = 0;
61
62 bool isIdentity() const;
63};
64
65class OPENVRUIEXPORT vruiCoord
66{
67
68public:
70 {
71 }
72 vruiCoord(const vruiMatrix *right)
73 {
74 hpr = right->getHPR();
75 xyz = right->getTranslate();
76 }
77
78 inline vruiCoord &operator=(const vruiMatrix *right)
79 {
80 hpr = right->getHPR();
81 xyz = right->getTranslate();
82 return *this;
83 }
84
85 inline void makeCoordMatrix(vruiMatrix *right)
86 {
87 right->makeEuler(hpr[0], hpr[1], hpr[2]);
88 right->setTranslation(xyz[0], xyz[1], xyz[2]);
89 }
90
91 coVector hpr;
92 coVector xyz;
93};
94}
95#endif
collaborative interface manager
Definition: coVRCommunication.h:41
Definition: vruiMatrix.h:20
virtual vruiMatrix * mult(const vruiMatrix *matrix)=0
virtual vruiMatrix * makeIdentity()=0
vruiMatrix()
Definition: vruiMatrix.h:23
virtual coVector getHPR() const =0
virtual vruiMatrix * makeInverse(const vruiMatrix *source)=0
virtual double operator()(int row, int column) const =0
virtual coVector getTranslate() const
Definition: vruiMatrix.h:51
virtual coVector getFullXformPt(const coVector &point) const =0
virtual vruiMatrix * setTranslation(double x, double y, double z)
Definition: vruiMatrix.h:35
virtual vruiMatrix * makeScale(double x, double y, double z)=0
virtual vruiMatrix * makeTranslate(double x, double y, double z)=0
virtual double & operator()(int row, int column)=0
bool isIdentity() const
virtual ~vruiMatrix()
virtual vruiMatrix * makeRotate(double degrees, double xAxis, double yAxis, double zAxis)=0
virtual vruiMatrix * makeEuler(double h, double p, double r)=0
virtual vruiMatrix * preTranslated(double x, double y, double z, vruiMatrix *matrix)=0
Definition: vruiMatrix.h:66
coVector hpr
Definition: vruiMatrix.h:91
coVector xyz
Definition: vruiMatrix.h:92
vruiCoord()
Definition: vruiMatrix.h:69
vruiCoord(const vruiMatrix *right)
Definition: vruiMatrix.h:72
void makeCoordMatrix(vruiMatrix *right)
Definition: vruiMatrix.h:85
vruiCoord & operator=(const vruiMatrix *right)
Definition: vruiMatrix.h:78