HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_CoordSpace.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_CoordSpace.h (UT Library, C++)
7  *
8  * COMMENTS:
9  * A 3D system of coordinates.
10  *
11  */
12 
13 #ifndef __UT_CoordSpace_h__
14 #define __UT_CoordSpace_h__
15 
16 #include "UT_API.h"
17 #include "UT_Axis.h"
18 #include "UT_Plane.h"
19 #include "UT_VectorTypes.h"
20 #include "UT_XformOrder.h"
21 #include <SYS/SYS_Deprecated.h>
22 
23 template <typename T>
25 {
26 public:
27  // Several constructors that define a plane as (X - point)*zaxis = 0
30  const UT_Vector3T<T> &point,
31  const UT_Vector3T<T> &axaxis,
32  const UT_Vector3T<T> &ayaxis,
33  const UT_Vector3T<T> *azaxis,
34  bool norm = true);
36  const UT_Vector3T<T> &p0,
37  const UT_Vector3T<T> &p1,
38  const UT_Vector3T<T> &p2);
39 
41 
42  // Flip the z axis by 180 degrees:
43  void negate();
44 
45  // Orient one axis and rotate the others accordingly, or set them all:
46  void xaxis(const UT_Vector3T<T> &x, bool norm = true,
47  bool allow_flip = true);
48  void yaxis(const UT_Vector3T<T> &y, bool norm = true,
49  bool allow_flip = true);
50  void zaxis(const UT_Vector3T<T> &z, bool norm = true,
51  bool allow_flip = true);
52  void setAxes(
53  const UT_Vector3T<T> &x,
54  const UT_Vector3T<T> &y,
55  const UT_Vector3T<T> &z,
56  bool norm = true);
57 
58  // Query the axes:
59  const UT_Vector3T<T> & xaxis() const { return myXAxis; }
60  const UT_Vector3T<T> & yaxis() const { return myYAxis; }
61  const UT_Vector3T<T> & zaxis() const { return myPlane.normal(); }
62 
63  // Set or query the origin:
64  const UT_Vector3T<T> & origin() const { return myPlane.point(); }
65  void setOrigin(const UT_Vector3T<T> &o)
66  { myPlane.setPoint(o); }
67 
68  // Rotate by a given angle, expressed in radians:
69  void rotate(
70  UT_Vector3T<T> &axis,
71  T theta,
72  bool norm = true);
73  void rotate(
75  T theta);
76 
77  // Assume we're given a rotation matrix
78  // Rotate about our own origin.
79  void rotate(const UT_Matrix3T<T> &rotmatx);
80 
81  // Apply an invertible transformation to the plane: the method that takes
82  // a non-const matrix returns the inverted and transposed matrix but will
83  // be removed in the future. Use transformAndReturnNormalXform() if that
84  // is really what you want, otherwise cast to a const reference.
85  void transform(const UT_Matrix4F &matx);
86  SYS_DEPRECATED(17.0)
87  void transform( UT_Matrix4F &matx);
88  void transform(const UT_Matrix4D &matx);
89  SYS_DEPRECATED(17.0)
90  void transform( UT_Matrix4D &matx);
91 
92  // Apply an invertible transformation to the space and return the inverted
93  // and transposed matrix in the non-const argument.
96 
97  // Set the transformation for this space to the identity matrix.
98  void identity();
99 
100  void getTransformMatrix(UT_Matrix4T<T> &matx) const;
101 
102  // This version of getTransformMatrix is consistent with the transform
103  // method: calling identity(), then transform(matrix), then
104  // getTransformMatrixPreservingOrigin() will return the value of "matrix".
105  // Doing the same but calling getTransformMatrix() will not return the
106  // value of "matrix".
108  UT_Matrix4T<T> &matx) const;
109 
110  void shiftOffset(T by_factor)
111  {
112  myPlane.shiftOffset(by_factor);
113  }
114 
116  {
117  myPlane.translate(offset);
118  }
119 
120  // Compute rotation from world space to us or vice-versa.
121  // Return the same value "crack()" does.
122  int fromWorldRotation(
123  T &rx, T &ry, T &rz,
124  const UT_XformOrder &order) const;
125  int toWorldRotation(
126  T &rx, T &ry, T &rz,
127  const UT_XformOrder &order) const;
128 
129  void convertToWorld(
130  UT_Vector3T<T> &rel) const;
132  UT_Vector3T<T> &rel) const;
133 
134  // Allow const operations on the underlying plane.
135  const UT_PlaneT<T> & plane() const { return myPlane; }
136 
137 private:
138  template <typename MATX>
139  inline void changeSpace(MATX &matx) const;
140 
141  UT_PlaneT<T> myPlane; // Use the plane's normal as the zaxis
142  UT_Vector3T<T> myXAxis; // Define the two other axes
143  UT_Vector3T<T> myYAxis;
144 };
145 
149 typedef UT_CoordSpaceT<float> UT_CoordSpace; // deprecated
150 
151 #include "UT_CoordSpaceImpl.h"
152 
153 #endif // __UT_CoordSpace_h__
void setOrigin(const UT_Vector3T< T > &o)
Definition: UT_CoordSpace.h:65
void getTransformMatrixPreservingOrigin(UT_Matrix4T< T > &matx) const
const UT_Vector3T< T > & yaxis() const
Definition: UT_CoordSpace.h:60
#define SYS_DEPRECATED(__V__)
void convertToWorld(UT_Vector3T< T > &rel) const
void convertToWorldNoOriginAdj(UT_Vector3T< T > &rel) const
UT_CoordSpaceT< fpreal > UT_CoordSpaceR
int fromWorldRotation(T &rx, T &ry, T &rz, const UT_XformOrder &order) const
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
void shiftOffset(T by_factor)
const UT_Vector3T< T > & origin() const
Definition: UT_CoordSpace.h:64
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
GLint y
Definition: glcorearb.h:102
void getTransformMatrix(UT_Matrix4T< T > &matx) const
3D Vector class.
void translate(const UT_Vector3T< T > &offset)
UT_CoordSpaceT< fpreal32 > UT_CoordSpaceF
void transformAndReturnNormalXform(UT_Matrix4F &matx)
const UT_Vector3T< T > & zaxis() const
Definition: UT_CoordSpace.h:61
GLintptr offset
Definition: glcorearb.h:664
void transform(const UT_Matrix4F &matx)
int toWorldRotation(T &rx, T &ry, T &rz, const UT_XformOrder &order) const
void rotate(UT_Vector3T< T > &axis, T theta, bool norm=true)
UT_CoordSpaceT< float > UT_CoordSpace
const UT_Vector3T< T > & xaxis() const
Definition: UT_CoordSpace.h:59
UT_PlaneType
Definition: UT_Plane.h:26
GLint GLenum GLint x
Definition: glcorearb.h:408
UT_CoordSpaceT(UT_PlaneType p=UT_PLANE_XY)
void setAxes(const UT_Vector3T< T > &x, const UT_Vector3T< T > &y, const UT_Vector3T< T > &z, bool norm=true)
#define const
Definition: zconf.h:214
UT_CoordSpaceT< fpreal64 > UT_CoordSpaceD
const UT_PlaneT< T > & plane() const