Newton Dynamics  4.00
ndJointHinge.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_HINGE_H__
13 #define __ND_JOINT_HINGE_H__
14 
15 #include "ndNewtonStdafx.h"
16 #include "ndJointBilateralConstraint.h"
17 
19 {
20  public:
21  D_CLASS_REFLECTION(ndJointHinge);
22  D_NEWTON_API ndJointHinge(const ndLoadSaveBase::ndLoadDescriptor& desc);
23  D_NEWTON_API ndJointHinge(const ndMatrix& pinAndPivotFrame, ndBodyKinematic* const child, ndBodyKinematic* const parent);
24  D_NEWTON_API ndJointHinge(const ndMatrix& pinAndPivotInChild, const ndMatrix& pinAndPivotInParent, ndBodyKinematic* const child, ndBodyKinematic* const parent);
25  D_NEWTON_API virtual ~ndJointHinge();
26 
27  D_NEWTON_API ndFloat32 GetAngle() const;
28  D_NEWTON_API ndFloat32 GetOmega() const;
29  D_NEWTON_API ndFloat32 GetOffsetAngle() const;
30  D_NEWTON_API void SetOffsetAngle(ndFloat32 angle);
31  D_NEWTON_API bool GetLimitState() const;
32  D_NEWTON_API void SetLimitState(bool state);
33  D_NEWTON_API void SetLimits(ndFloat32 minLimit, ndFloat32 maxLimit);
34  D_NEWTON_API void GetLimits(ndFloat32& minLimit, ndFloat32& maxLimit);
35  D_NEWTON_API void SetAsSpringDamper(ndFloat32 regularizer, ndFloat32 spring, ndFloat32 damper);
36  D_NEWTON_API void GetSpringDamper(ndFloat32& regularizer, ndFloat32& spring, ndFloat32& damper) const;
37 
38  protected:
39  D_NEWTON_API ndFloat32 PenetrationOmega(ndFloat32 penetartion) const;
40  D_NEWTON_API void SubmitLimits(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
41  D_NEWTON_API void SubmitSpringDamper(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
42 
43  D_NEWTON_API void JacobianDerivative(ndConstraintDescritor& desc);
44  D_NEWTON_API void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
45  D_NEWTON_API void DebugJoint(ndConstraintDebugCallback& debugCallback) const;
46  D_NEWTON_API void ApplyBaseRows(ndConstraintDescritor& desc, const ndMatrix& matrix0, const ndMatrix& matrix1);
47 
48  ndFloat32 m_angle;
49  ndFloat32 m_omega;
50  ndFloat32 m_springK;
51  ndFloat32 m_damperC;
52  ndFloat32 m_minLimit;
53  ndFloat32 m_maxLimit;
54  ndFloat32 m_offsetAngle;
55  ndFloat32 m_springDamperRegularizer;
56  ndInt8 m_limitState;
57 };
58 
59 #endif
60 
ndConstraintDescritor
Definition: ndConstraint.h:179
ndJointBilateralConstraint
Definition: ndJointBilateralConstraint.h:53
ndConstraintDebugCallback
Definition: ndConstraint.h:42
ndBodyKinematic
Definition: ndBodyKinematic.h:40
ndMatrix
Definition: ndMatrix.h:42
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndJointHinge
Definition: ndJointHinge.h:19