externals
box2d
include
box2d
b2_gear_joint.h
Go to the documentation of this file.
1
// MIT License
2
3
// Copyright (c) 2019 Erin Catto
4
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef B2_GEAR_JOINT_H
24
#define B2_GEAR_JOINT_H
25
26
#include "
b2_joint.h
"
27
31
struct
B2_API
b2GearJointDef
:
public
b2JointDef
32
{
33
b2GearJointDef
()
34
{
35
type
=
e_gearJoint
;
36
joint1 =
nullptr
;
37
joint2 =
nullptr
;
38
ratio = 1.0f;
39
}
40
42
b2Joint
*
joint1
;
43
45
b2Joint
*
joint2
;
46
49
float
ratio
;
50
};
51
61
class
B2_API
b2GearJoint
:
public
b2Joint
62
{
63
public
:
64
b2Vec2
GetAnchorA
()
const override
;
65
b2Vec2
GetAnchorB
()
const override
;
66
67
b2Vec2
GetReactionForce
(
float
inv_dt)
const override
;
68
float
GetReactionTorque
(
float
inv_dt)
const override
;
69
71
b2Joint
*
GetJoint1
() {
return
m_joint1; }
72
74
b2Joint
*
GetJoint2
() {
return
m_joint2; }
75
77
void
SetRatio(
float
ratio);
78
float
GetRatio()
const
;
79
81
void
Dump
()
override
;
82
83
protected
:
84
85
friend
class
b2Joint
;
86
b2GearJoint
(
const
b2GearJointDef
* data);
87
88
void
InitVelocityConstraints
(
const
b2SolverData
& data)
override
;
89
void
SolveVelocityConstraints
(
const
b2SolverData
& data)
override
;
90
bool
SolvePositionConstraints
(
const
b2SolverData
& data)
override
;
91
92
b2Joint
*
m_joint1
;
93
b2Joint
*
m_joint2
;
94
95
b2JointType
m_typeA
;
96
b2JointType
m_typeB
;
97
98
// Body A is connected to body C
99
// Body B is connected to body D
100
b2Body
*
m_bodyC
;
101
b2Body
*
m_bodyD
;
102
103
// Solver shared
104
b2Vec2
m_localAnchorA
;
105
b2Vec2
m_localAnchorB
;
106
b2Vec2
m_localAnchorC
;
107
b2Vec2
m_localAnchorD
;
108
109
b2Vec2
m_localAxisC
;
110
b2Vec2
m_localAxisD
;
111
112
float
m_referenceAngleA
;
113
float
m_referenceAngleB
;
114
115
float
m_constant
;
116
float
m_ratio
;
117
118
float
m_impulse
;
119
120
// Solver temp
121
int32
m_indexA, m_indexB, m_indexC,
m_indexD
;
122
b2Vec2
m_lcA, m_lcB, m_lcC,
m_lcD
;
123
float
m_mA, m_mB, m_mC,
m_mD
;
124
float
m_iA, m_iB, m_iC,
m_iD
;
125
b2Vec2
m_JvAC,
m_JvBD
;
126
float
m_JwA, m_JwB, m_JwC,
m_JwD
;
127
float
m_mass
;
128
};
129
130
#endif
b2GearJoint::m_ratio
float m_ratio
Definition:
b2_gear_joint.h:116
b2GearJoint::m_localAxisD
b2Vec2 m_localAxisD
Definition:
b2_gear_joint.h:110
b2GearJoint::m_JvBD
b2Vec2 m_JvBD
Definition:
b2_gear_joint.h:125
e_gearJoint
Definition:
b2_joint.h:43
b2Joint::SolveVelocityConstraints
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2GearJointDef::joint2
b2Joint * joint2
The second revolute/prismatic joint attached to the gear joint.
Definition:
b2_gear_joint.h:45
b2GearJoint::m_joint2
b2Joint * m_joint2
Definition:
b2_gear_joint.h:93
b2GearJoint::m_mass
float m_mass
Definition:
b2_gear_joint.h:127
b2Joint::GetReactionForce
virtual b2Vec2 GetReactionForce(float inv_dt) const =0
Get the reaction force on bodyB at the joint anchor in Newtons.
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2_joint.h:72
B2_API
#define B2_API
Definition:
b2_api.h:49
b2GearJoint::m_iD
float m_iD
Definition:
b2_gear_joint.h:124
b2GearJoint::m_bodyD
b2Body * m_bodyD
Definition:
b2_gear_joint.h:101
b2GearJoint::m_indexD
int32 m_indexD
Definition:
b2_gear_joint.h:121
b2GearJoint::GetJoint2
b2Joint * GetJoint2()
Get the second joint.
Definition:
b2_gear_joint.h:74
b2GearJointDef
Definition:
b2_gear_joint.h:31
b2GearJoint
Definition:
b2_gear_joint.h:61
b2GearJoint::m_typeA
b2JointType m_typeA
Definition:
b2_gear_joint.h:95
b2GearJointDef::ratio
float ratio
Definition:
b2_gear_joint.h:49
b2SolverData
Solver Data.
Definition:
b2_time_step.h:67
b2Vec2
A 2D column vector.
Definition:
b2_math.h:41
int32
signed int int32
Definition:
b2_types.h:28
b2Joint::GetReactionTorque
virtual float GetReactionTorque(float inv_dt) const =0
Get the reaction torque on bodyB in N*m.
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2_body.h:128
b2GearJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2_gear_joint.h:105
b2GearJoint::m_bodyC
b2Body * m_bodyC
Definition:
b2_gear_joint.h:100
b2Joint::GetAnchorA
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
b2GearJoint::m_joint1
b2Joint * m_joint1
Definition:
b2_gear_joint.h:92
b2GearJoint::m_localAnchorC
b2Vec2 m_localAnchorC
Definition:
b2_gear_joint.h:106
b2Joint::InitVelocityConstraints
virtual void InitVelocityConstraints(const b2SolverData &data)=0
b2GearJoint::m_mD
float m_mD
Definition:
b2_gear_joint.h:123
b2Joint::SolvePositionConstraints
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2GearJointDef::joint1
b2Joint * joint1
The first revolute/prismatic joint attached to the gear joint.
Definition:
b2_gear_joint.h:42
b2GearJoint::m_referenceAngleA
float m_referenceAngleA
Definition:
b2_gear_joint.h:112
b2GearJoint::m_constant
float m_constant
Definition:
b2_gear_joint.h:115
b2GearJoint::GetJoint1
b2Joint * GetJoint1()
Get the first joint.
Definition:
b2_gear_joint.h:71
b2GearJoint::m_referenceAngleB
float m_referenceAngleB
Definition:
b2_gear_joint.h:113
b2Joint::Dump
virtual void Dump()
Dump this joint to the log file.
Definition:
b2_joint.h:151
b2GearJoint::m_JwD
float m_JwD
Definition:
b2_gear_joint.h:126
b2_joint.h
b2GearJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2_gear_joint.h:104
b2Joint
Definition:
b2_joint.h:110
b2Joint::GetAnchorB
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
b2GearJointDef::b2GearJointDef
b2GearJointDef()
Definition:
b2_gear_joint.h:33
b2GearJoint::m_impulse
float m_impulse
Definition:
b2_gear_joint.h:118
b2GearJoint::m_localAxisC
b2Vec2 m_localAxisC
Definition:
b2_gear_joint.h:109
b2GearJoint::m_typeB
b2JointType m_typeB
Definition:
b2_gear_joint.h:96
b2Joint::b2GearJoint
friend class b2GearJoint
Definition:
b2_joint.h:163
b2GearJoint::m_localAnchorD
b2Vec2 m_localAnchorD
Definition:
b2_gear_joint.h:107
b2JointType
b2JointType
Definition:
b2_joint.h:35
b2GearJoint::m_lcD
b2Vec2 m_lcD
Definition:
b2_gear_joint.h:122
type
GLenum type
Definition:
gl.h:1033
mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19