Newton Dynamics  4.00
ndJointDoubleHinge.h
1 /* Copyright (c) <2003-2022> <Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely
10 */
11 
12 #ifndef __ND_JOINT_DOUBLE_HINGE_H__
13 #define __ND_JOINT_DOUBLE_HINGE_H__
14 
15 #include "ndNewtonStdafx.h"
16 #include "ndJointBilateralConstraint.h"
17 
18 #define D_MAX_DOUBLE_HINGE_RECOVERY_SPEED ndFloat32 (0.25f)
19 #define D_MAX_DOUBLE_HINGE_PENETRATION (ndFloat32 (4.0f) * ndDegreeToRad)
20 
22 {
23  public:
25  {
26  public:
27  ndAxisParam();
28  void Load(const nd::TiXmlElement* const xmlNode);
29  void Save(nd::TiXmlElement* const xmlNode) const;
30 
31  ndFloat32 m_angle;
32  ndFloat32 m_omega;
33  ndFloat32 m_springK;
34  ndFloat32 m_damperC;
35  ndFloat32 m_minLimit;
36  ndFloat32 m_maxLimit;
37  ndFloat32 m_offsetAngle;
38  ndFloat32 m_springDamperRegularizer;
39  };
40 
41  D_CLASS_REFLECTION(ndJointDoubleHinge);
42  D_NEWTON_API ndJointDoubleHinge(const ndLoadSaveBase::ndLoadDescriptor& desc);
43  D_NEWTON_API ndJointDoubleHinge(const ndMatrix& pinAndPivotFrame, ndBodyKinematic* const child, ndBodyKinematic* const parent);
44  D_NEWTON_API virtual ~ndJointDoubleHinge();
45 
46  D_NEWTON_API ndFloat32 GetAngle0() const;
47  D_NEWTON_API ndFloat32 GetOmega0() const;
48  D_NEWTON_API ndFloat32 GetOffsetAngle0() const;
49  D_NEWTON_API void SetOffsetAngle0(ndFloat32 angle);
50  D_NEWTON_API void SetLimits0(ndFloat32 minLimit, ndFloat32 maxLimit);
51  D_NEWTON_API void GetLimits0(ndFloat32& minLimit, ndFloat32& maxLimit);
52  D_NEWTON_API void SetAsSpringDamper0(ndFloat32 regularizer, ndFloat32 spring, ndFloat32 damper);
53 
54  D_NEWTON_API ndFloat32 GetAngle1() const;
55  D_NEWTON_API ndFloat32 GetOmega1() const;
56  D_NEWTON_API ndFloat32 GetOffsetAngle1() const;
57  D_NEWTON_API void SetOffsetAngle1(ndFloat32 angle);
58  D_NEWTON_API void SetLimits1(ndFloat32 minLimit, ndFloat32 maxLimit);
59  D_NEWTON_API void GetLimits1(ndFloat32& minLimit, ndFloat32& maxLimit);
60  D_NEWTON_API void SetAsSpringDamper1(ndFloat32 regularizer, ndFloat32 spring, ndFloat32 damper);
61 
62  protected:
63  D_NEWTON_API void JacobianDerivative(ndConstraintDescritor& desc);
64  D_NEWTON_API ndFloat32 PenetrationOmega(ndFloat32 penetartion) const;
65  D_NEWTON_API void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
66  D_NEWTON_API void DebugJoint(ndConstraintDebugCallback& debugCallback) const;
67  D_NEWTON_API void ApplyBaseRows(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
68 
69  D_NEWTON_API void SubmitLimits(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
70  D_NEWTON_API void SubmitSpringDamper0(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
71  D_NEWTON_API void SubmitSpringDamper1(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
72 
73  ndAxisParam m_axis0;
74  ndAxisParam m_axis1;
75 };
76 
77 #endif
78 
ndConstraintDescritor
Definition: ndConstraint.h:179
ndJointBilateralConstraint
Definition: ndJointBilateralConstraint.h:53
ndConstraintDebugCallback
Definition: ndConstraint.h:42
nd::TiXmlElement
The element is a container class.
Definition: tinyxml.h:962
ndBodyKinematic
Definition: ndBodyKinematic.h:40
ndMatrix
Definition: ndMatrix.h:42
ndJointDoubleHinge
Definition: ndJointDoubleHinge.h:22
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndJointDoubleHinge::ndAxisParam
Definition: ndJointDoubleHinge.h:25