Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SceneCoordinateFrame.cpp
1 #include <GLviewer/Scenes/SceneCoordinateFrame.hh>
2 #include <GLviewer/GLProjectionParametersInterface.hh>
3 
4 using namespace BIAS;
5 
8  const BIAS::RMatrix &orientation, const double scale)
9 {
10  SetCoordinateFrame(origin, orientation, scale);
11 }
12 
14 {
15 }
16 
19  const BIAS::RMatrix &orientation, const double scale)
20 {
21  // Set origin and calculate axes
22  origin_.Set(origin[0], origin[1], origin[2]);
23  for (unsigned int i = 0; i < 3; i++) {
24  axisX_[i] = orientation[i][0] * scale;
25  axisY_[i] = orientation[i][1] * scale;
26  axisZ_[i] = orientation[i][2] * scale;
27  }
28 
29  // Make a bounding box to fit the coordinate frame for any rotation
30  boundingBoxMin_ = origin;
31  boundingBoxMax_ = origin;
32  const double extent = fabs(scale) * sqrt(3.0);
33  for (unsigned int i = 0; i < 3; i++) {
34  boundingBoxMin_[i] -= extent;
35  boundingBoxMax_[i] += extent;
36  }
37 }
38 
41 {
42  minVal = boundingBoxMin_;
43  maxVal = boundingBoxMax_;
44 }
45 
47 {
48  // Disable lighting
49  glPushAttrib(GL_LIGHTING);
50  glDisable(GL_LIGHTING);
51 
52  // Draw x, y and z axes at origin
53  glBegin(GL_LINES);
54  glColor3f(1.0f, 0.0f, 0.0f);
55  glVertex3f(origin_[0], origin_[1], origin_[2]);
56  glVertex3f(origin_[0] + axisX_[0], origin_[1] + axisX_[1], origin_[2] + axisX_[2]);
57  glColor3f(0.0f, 1.0f, 0.0f);
58  glVertex3f(origin_[0], origin_[1], origin_[2]);
59  glVertex3f(origin_[0] + axisY_[0], origin_[1] + axisY_[1], origin_[2] + axisY_[2]);
60  glColor3f(0.0f, 0.0f, 1.0f);
61  glVertex3f(origin_[0], origin_[1], origin_[2]);
62  glVertex3f(origin_[0] + axisZ_[0], origin_[1] + axisZ_[1], origin_[2] + axisZ_[2]);
63  glEnd();
64 
65  // Draw points at origin and axis ends
66  GLfloat pointSize;
67  glGetFloatv(GL_POINT_SIZE, &pointSize);
68  glPointSize(8.0f);
69  glBegin(GL_POINTS);
70  glColor3f(0.0f, 0.0f, 0.0f);
71  glVertex3f(origin_[0], origin_[1], origin_[2]);
72  glColor3f(1.0f, 0.0f, 0.0f);
73  glVertex3f(origin_[0] + axisX_[0], origin_[1] + axisX_[1], origin_[2] + axisX_[2]);
74  glColor3f(0.0f, 1.0f, 0.0f);
75  glVertex3f(origin_[0] + axisY_[0], origin_[1] + axisY_[1], origin_[2] + axisY_[2]);
76  glColor3f(0.0f, 0.0f, 1.0f);
77  glVertex3f(origin_[0] + axisZ_[0], origin_[1] + axisZ_[1], origin_[2] + axisZ_[2]);
78  glEnd();
79  glPointSize(pointSize);
80 
81  glPopAttrib(); // GL_LIGHTING
82 }
void Set(const T *pv)
copy the array of vectorsize beginning at *T to this-&gt;data_
Definition: Vector3.hh:532
BIAS::Vector3< double > boundingBoxMin_
virtual void Draw()
Implementation of the SceneBase Draw method.
BIAS::Vector3< double > boundingBoxMax_
3D rotation matrix
Definition: RMatrix.hh:49
SceneCoordinateFrame(const BIAS::Vector3< double > &origin=BIAS::Vector3< double >(0, 0, 0), const BIAS::RMatrix &orientation=BIAS::RMatrix(BIAS::MatrixIdentity), const double scale=1.0)
Create a coordinate frame with the given origin, orientation, and scale.
void SetCoordinateFrame(const BIAS::Vector3< double > &origin, const BIAS::RMatrix &orientation, const double scale=1.0)
Set origin, orientation and scale of coordinate frame.
virtual void GetBoundingBox(BIAS::Vector3< double > &minVal, BIAS::Vector3< double > &maxVal)
Implementation of the SceneBase GetBoundingBox method.
BIAS::Vector3< float > axisZ_
BIAS::Vector3< float > axisY_
BIAS::Vector3< float > axisX_
BIAS::Vector3< float > origin_