Trans.hh 2.73 KB
Newer Older
Bill Lorensen's avatar
Bill Lorensen committed
1
2
3
4
5
/*=========================================================================

  Program:   Visualization Library
  Module:    Trans.hh
  Language:  C++
Will Schroeder's avatar
Will Schroeder committed
6
7
  Date:      $Date$
  Version:   $Revision$
Bill Lorensen's avatar
Bill Lorensen committed
8

Will Schroeder's avatar
Will Schroeder committed
9
10
11
12
13
Description:
---------------------------------------------------------------------------
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Bill Lorensen's avatar
Bill Lorensen committed
14

Will Schroeder's avatar
Will Schroeder committed
15
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994 
Bill Lorensen's avatar
Bill Lorensen committed
16
17

=========================================================================*/
Will Schroeder's avatar
Will Schroeder committed
18
19
20
21
22
23
24
25
26
27
28

// .NAME vlTransform - a general matrix transformation class
// .SECTION Description
// vlTransform maintains a stack of 4x4 transformation matrices.  A
// variety of methods are provided to manipulate the translation,
// scale, and rotation components of the matrix.  Methods operate on
// the transformation at the top of the stack.
// .SECTION Caveats
// By default the initial matrix is the identity matrix.
// .EXAMPLE XFormSph.cc

Bill Lorensen's avatar
Bill Lorensen committed
29
30
31
32
33
#ifndef __vlTransform_hh
#define __vlTransform_hh

#include "Object.hh"
#include "Mat4x4.hh"
Will Schroeder's avatar
Will Schroeder committed
34
35
36
#include "Points.hh"
#include "Normals.hh"
#include "Vectors.hh"
Bill Lorensen's avatar
Bill Lorensen committed
37
38
39
40
41

class vlTransform : public vlObject
{
 public:
  vlTransform ();
42
  vlTransform (const vlTransform& t);
Bill Lorensen's avatar
Bill Lorensen committed
43
  ~vlTransform ();
Will Schroeder's avatar
Will Schroeder committed
44
45
  char *GetClassName () {return "vlTransform";};
  void PrintSelf (ostream& os, vlIndent indent);
Bill Lorensen's avatar
Bill Lorensen committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  void Identity ();
  void Pop ();
  void PostMultiply ();
  void PreMultiply ();
  void Push ();
  void RotateX ( float angle);
  void RotateY ( float angle);
  void RotateZ (float angle);
  void RotateWXYZ ( float angle, float x, float y, float z);
  void Scale ( float x, float y, float z);
  void Translate ( float x, float y, float z);
  void Transpose ();
  void GetTranspose (vlMatrix4x4& (transpose));
  void Inverse ();
  void GetInverse ( vlMatrix4x4& inverse);
Ken Martin's avatar
Ken Martin committed
61
  float *GetOrientation();
Bill Lorensen's avatar
Bill Lorensen committed
62
63
64
65
66
67
  void GetPosition (float & x,float & y,float & z);
  void GetScale ( float & x, float & y, float & z);
  vlMatrix4x4 & GetMatrix ();
  void GetMatrix (vlMatrix4x4 & ctm);
  void Concatenate (vlMatrix4x4 & matrix);
  void Multiply4x4 ( vlMatrix4x4 & a, vlMatrix4x4 & b, vlMatrix4x4 & c);
Will Schroeder's avatar
Will Schroeder committed
68
  void PointMultiply (float in[4],float out[4]);
Will Schroeder's avatar
Will Schroeder committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  void MultiplyPoints(vlPoints *inPts, vlPoints *outPts);
  void MultiplyVectors(vlVectors *inVectors, vlVectors *outVectors);
  void MultiplyNormals(vlNormals *inNormals, vlNormals *outNormals);
  vlSetVector4Macro(Point,float);
  float *GetPoint();

 private:
  int PreMultiplyFlag;
  int StackSize;
  vlMatrix4x4 ** Stack;
  vlMatrix4x4 ** StackBottom;
  float Point[4];
  float Orientation[3];

Bill Lorensen's avatar
Bill Lorensen committed
83
84
};

Will Schroeder's avatar
Will Schroeder committed
85
86
87
88
89
inline void vlTransform::PointMultiply (float in[4],float out[4]) 
{
  this->Stack[0]->PointMultiply(in,out);
}

Bill Lorensen's avatar
Bill Lorensen committed
90
#endif