00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Jeff Lait 00008 * Side Effects Software Inc 00009 * 123 Front Street West, Suite 1401 00010 * Toronto, Ontario 00011 * Canada M5J 2M2 00012 * 416-504-9876 00013 */ 00014 00015 #ifndef __SIM_ConAnchorRotational_h__ 00016 #define __SIM_ConAnchorRotational_h__ 00017 00018 #include "SIM_API.h" 00019 #include "SIM_ConAnchor.h" 00020 #include <UT/UT_Quaternion.h> 00021 #include <UT/UT_Vector3.h> 00022 00023 /// Rotational constraints are a bit odd. 00024 /// We categorize constraints by the shape created by sweeping the 00025 /// possible rotation axes through unconstrained space. 00026 /// The numerical representation is thus the number of degrees that 00027 /// have been constrained. "DOF" stands for "degrees of freedom". 00028 class SIM_API SIM_ConAnchorRotational : public SIM_ConAnchor 00029 { 00030 public: 00031 GETSET_DATA_FUNCS_V3(SIM_NAME_ROTATION, RotationInput); 00032 00033 /// We need better names for these. 00034 enum SIM_DOFType { 00035 /// DOF_FREE is a complete absence of any restrictions on 00036 /// orientation. Any orientation is valid. 00037 DOF_FREE = 0, 00038 /// DOF_PLANEJOINT provides the mobility of a thick wire system. 00039 /// The plane's axis can be made to look in any direction, but can't 00040 /// be rotated freely. 00041 /// Only rotations whose axes lie in a given plane are allowed. 00042 DOF_PLANEJOINT = 1, 00043 /// DOF_HINGE allows any orientation around a specific axis. 00044 /// A specific axis is locked, rotating around that is allowed. 00045 DOF_HINGE = 2, 00046 /// DOF_ORIENT provides no free orientation. 00047 /// Orientation completely locked down. 00048 DOF_ORIENT = 3 00049 }; 00050 00051 GETSET_DATA_FUNCS_E(SIM_NAME_CONDOF, DOFTypeInput, SIM_DOFType); 00052 /// All constraints are represented by a vector which is interpreted 00053 /// differently depending on how many DOF will be constrained. 00054 /// 00055 /// If O is the orientation to constrain, and Q the rest orientation, 00056 /// and V the vector: 00057 /// Free constraint: 00058 /// O = O 00059 /// No constraint occurs. 00060 /// 00061 /// Plane constraint: 00062 /// (O / Q) . V = 0 00063 /// The rotation which maps from Q to O should not have any 00064 /// component of V in it. This allows all orientations which 00065 /// can be reached from Q by rotating around a vector perpendicular 00066 /// to V. 00067 /// 00068 /// Hinge constraint: 00069 /// (O / Q) = s V, for some s 00070 /// There is one degree of freedom. The set of valid orientations 00071 /// are those that can be reached from Q by rotating around V. 00072 /// 00073 /// Orient constraint: 00074 /// O = Q 00075 /// The quaternion is fully constrained. 00076 /// 00077 /// Through further abuse of notation, we can define the UnconDOFFilter 00078 /// which when applied to an angular velocity will cause it to fulfill 00079 /// those conditions. We can then clamp a quaternion O into the desired 00080 /// value Q according to the filter uF with: 00081 /// O' = ((uF) * (O / Q)) * Q 00082 /// 00083 /// (Note that uF is symmetric and O/Q a vector, 00084 /// so we don't have to worry which side we multiply it on.) 00085 /// 00086 /// This vector is defined in *object* space. 00087 /// (Ie, a value of (1, 0, 0) means that the X axis of the object should 00088 /// point in the fashion that the X axis of O does) 00089 GETSET_DATA_FUNCS_V3(SIM_NAME_CONDIR, DOFVectorInput); 00090 00091 /// Overridable get/set for Rotation and DOF of constraint 00092 const UT_Vector3 getRotation() const; 00093 void setRotation(const UT_Vector3 &rotation); 00094 SIM_DOFType getDOFType() const; 00095 void setDOFType(const SIM_DOFType type); 00096 const UT_Vector3 getDOFVector() const; 00097 void setDOFVector(const UT_Vector3 &vector); 00098 00099 /// Retrieve the world-space position for the guide geometry 00100 UT_Vector3 getGuidePosition(const SIM_Time &t) const; 00101 00102 /// Retrieve the world-space orientation to constrain to. 00103 UT_Quaternion getOrientation(const SIM_Time &time) const; 00104 UT_Vector3 getAngularVelocity(const SIM_Time &time) const; 00105 00106 /// Retrieve number of constrained degrees of freedom. 00107 int getNumConDOFs() const; 00108 00109 /// Returns a matrix that, when multiplied by a angular velocity, gives 00110 /// only the components of the angular velocity that are constrained. 00111 void getConDOFFilter(UT_Matrix3 &result, 00112 const SIM_Time &time) const; 00113 00114 /// Opposite of getConDOFFilter(). 00115 /// getUnconDOFFilter() = identity - getConDOFFilter() 00116 void getUnconDOFFilter(UT_Matrix3 &result, 00117 const SIM_Time &time) const; 00118 00119 protected: 00120 explicit SIM_ConAnchorRotational(const SIM_DataFactory *f); 00121 virtual ~SIM_ConAnchorRotational(); 00122 00123 virtual void buildAnchorGuideGeometrySubclass( 00124 const SIM_Options &options, 00125 const GU_DetailHandle &gdh, 00126 const SIM_Relationship &rel, 00127 const SIM_Time &t) const; 00128 00129 virtual UT_Vector3 getGuidePositionSubclass( 00130 const SIM_Time &time) const; 00131 00132 virtual UT_Quaternion getOrientationSubclass( 00133 const SIM_Time &time) const = 0; 00134 virtual UT_Vector3 getAngularVelocitySubclass( 00135 const SIM_Time &time) const = 0; 00136 00137 virtual const UT_Vector3 getRotationSubclass() const; 00138 virtual SIM_DOFType getDOFTypeSubclass() const; 00139 virtual const UT_Vector3 getDOFVectorSubclass() const; 00140 00141 private: 00142 DECLARE_STANDARD_GETCASTTOTYPE(); 00143 DECLARE_CLASSNAME(SIM_ConAnchorRotational, SIM_ConAnchor); 00144 }; 00145 00146 #endif 00147
1.5.9