00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __UT_CoordSpace_h__
00022 #define __UT_CoordSpace_h__
00023
00024 #include "UT_API.h"
00025 #include "UT_Plane.h"
00026
00027 class UT_Matrix3;
00028 class UT_XformOrder;
00029
00030 class UT_API UT_CoordSpace : public UT_Plane
00031 {
00032 public:
00033
00034 UT_CoordSpace(UT_Plane::UT_PlaneType p = UT_Plane::UT_PLANE_XY);
00035 UT_CoordSpace(const UT_Vector3 &point, const UT_Vector3 &axaxis,
00036 const UT_Vector3 &ayaxis, const UT_Vector3 *azaxis,
00037 int norm=1);
00038 UT_CoordSpace(const UT_Vector3 &p0, const UT_Vector3 &p1,
00039 const UT_Vector3 &p2);
00040 UT_CoordSpace(const UT_CoordSpace &p);
00041
00042 virtual ~UT_CoordSpace(void);
00043
00044
00045 virtual void negate(void);
00046
00047
00048 void xaxis(const UT_Vector3 &x, int norm = 1);
00049 void yaxis(const UT_Vector3 &y, int norm = 1);
00050 void zaxis(const UT_Vector3 &z, int norm = 1);
00051 void setAxes(const UT_Vector3 &x, const UT_Vector3 &y,
00052 const UT_Vector3 &z, int norm = 1);
00053
00054
00055 UT_Vector3 &xaxis(void) { return theXAxis; }
00056 const UT_Vector3 &xaxis(void) const { return theXAxis; }
00057 UT_Vector3 &yaxis(void) { return theYAxis; }
00058 const UT_Vector3 &yaxis(void) const { return theYAxis; }
00059 UT_Vector3 &zaxis(void) { return normal(); }
00060 const UT_Vector3 &zaxis(void) const { return normal(); }
00061
00062
00063 void origin(const UT_Vector3 &o) { point() = o; }
00064 UT_Vector3 &origin(void) { return point(); }
00065 const UT_Vector3 &origin(void) const { return point(); }
00066
00067
00068
00069 virtual void rotate(UT_Vector3 &axis, fpreal theta, int norm=1);
00070 virtual void rotate(UT_Axis3::axis a, fpreal theta);
00071
00072
00073
00074 void rotate(const UT_Matrix3 &rotmatx);
00075
00076
00077
00078 virtual void transform(const UT_Matrix4 &matx);
00079 virtual void transform( UT_Matrix4 &matx);
00080 virtual void transform(const UT_DMatrix4 &matx);
00081 virtual void transform( UT_DMatrix4 &matx);
00082
00083 void getTransformMatrix(UT_Matrix4 &matx) const;
00084
00085
00086
00087 int fromWorldRotation(float &rx, float &ry, float &rz,
00088 const UT_XformOrder &order) const;
00089 int toWorldRotation(float &rx, float &ry, float &rz,
00090 const UT_XformOrder &order) const;
00091
00092
00093 UT_CoordSpace &operator=(const UT_CoordSpace &p)
00094 {
00095 if (this != &p)
00096 {
00097 UT_Plane::operator=(p);
00098 theXAxis = p.theXAxis;
00099 theYAxis = p.theYAxis;
00100 }
00101 return *this;
00102 }
00103
00104
00105 const char *className() const;
00106
00107 void convertToWorld( UT_Vector3 &rel ) const
00108 {
00109 UT_Vector3 r;
00110 r.x() = rel.x()*xaxis().x()+rel.y()*yaxis().x()+rel.z()*zaxis().x();
00111 r.y() = rel.x()*xaxis().y()+rel.y()*yaxis().y()+rel.z()*zaxis().y();
00112 r.z() = rel.x()*xaxis().z()+rel.y()*yaxis().z()+rel.z()*zaxis().z();
00113 r += origin();
00114 rel = r;
00115 }
00116 void convertToWorldNoOriginAdj( UT_Vector3 &rel ) const
00117 {
00118 UT_Vector3 r;
00119 r.x() = rel.x()*xaxis().x()+rel.y()*yaxis().x()+rel.z()*zaxis().x();
00120 r.y() = rel.x()*xaxis().y()+rel.y()*yaxis().y()+rel.z()*zaxis().y();
00121 r.z() = rel.x()*xaxis().z()+rel.y()*yaxis().z()+rel.z()*zaxis().z();
00122 rel = r;
00123 }
00124
00125 protected:
00126 private:
00127
00128 UT_Vector3 theXAxis;
00129 UT_Vector3 theYAxis;
00130 };
00131
00132 #endif