Newton Dynamics  4.00
ndJointSpherical.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_SPHERICAL_H__
13 #define __ND_JOINT_SPHERICAL_H__
14 
15 #include "ndNewtonStdafx.h"
16 #include "ndJointBilateralConstraint.h"
17 
18 #define D_MAX_SPHERICAL_RECOVERY_SPEED ndFloat32 (0.25f)
19 #define D_MAX_SPHERICAL_PENETRATION (ndFloat32 (4.0f) * ndDegreeToRad)
20 #define D_MAX_SPHERICAL_CONE_ANGLE (ndFloat32 (150.0f) * ndDegreeToRad)
21 
23 {
24  public:
25  D_CLASS_REFLECTION(ndJointSpherical);
26  D_NEWTON_API ndJointSpherical(const ndLoadSaveBase::ndLoadDescriptor& desc);
27  D_NEWTON_API ndJointSpherical(const ndMatrix& pinAndPivotFrame, ndBodyKinematic* const child, ndBodyKinematic* const parent);
28  D_NEWTON_API virtual ~ndJointSpherical();
29 
30  D_NEWTON_API ndFloat32 GetConeLimit() const;
31  D_NEWTON_API ndMatrix GetOffsetRotation() const;
32  D_NEWTON_API void SetConeLimit(ndFloat32 maxConeAngle);
33  D_NEWTON_API void SetOffsetRotation(const ndMatrix& rotation);
34  D_NEWTON_API void SetTwistLimits(ndFloat32 minAngle, ndFloat32 maxAngle);
35  D_NEWTON_API void GetTwistLimits(ndFloat32& minAngle, ndFloat32& maxAngle) const;
36  D_NEWTON_API void SetAsSpringDamper(ndFloat32 regularizer, ndFloat32 spring, ndFloat32 damper);
37  D_NEWTON_API void GetSpringDamper(ndFloat32& regularizer, ndFloat32& spring, ndFloat32& damper) const;
38 
39  protected:
40  D_NEWTON_API void JacobianDerivative(ndConstraintDescritor& desc);
41  D_NEWTON_API void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
42  D_NEWTON_API void DebugJoint(ndConstraintDebugCallback& debugCallback) const;
43 
44  D_NEWTON_API ndFloat32 PenetrationOmega(ndFloat32 penetartion) const;
45  D_NEWTON_API void ApplyBaseRows(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
46  D_NEWTON_API void SubmitSpringDamper(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
47  D_NEWTON_API void SubmitAngularAxis(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
48  D_NEWTON_API void SubmitTwistAngle(const ndVector& pin, ndFloat32 angle, ndConstraintDescritor& desc);
49  D_NEWTON_API void SubmitLimits(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
50  D_NEWTON_API void SubmitAngularAxisCartesianApproximation(const ndMatrix& matrix0, const ndMatrix& matrix1, ndConstraintDescritor& desc);
51 
52  ndMatrix m_rotation;
53  ndFloat32 m_springK;
54  ndFloat32 m_damperC;
55  ndFloat32 m_maxConeAngle;
56  ndFloat32 m_minTwistAngle;
57  ndFloat32 m_maxTwistAngle;
58  ndFloat32 m_springDamperRegularizer;
59 };
60 
61 #endif
62 
ndJointSpherical
Definition: ndJointSpherical.h:23
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
ndVector
Definition: ndVectorArmNeon.h:41