externals
box2d
include
box2d
b2_weld_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_WELD_JOINT_H
24
#define B2_WELD_JOINT_H
25
26
#include "
b2_api.h
"
27
#include "
b2_joint.h
"
28
32
struct
B2_API
b2WeldJointDef
:
public
b2JointDef
33
{
34
b2WeldJointDef
()
35
{
36
type
=
e_weldJoint
;
37
localAnchorA.Set(0.0
f
, 0.0
f
);
38
localAnchorB.Set(0.0
f
, 0.0
f
);
39
referenceAngle = 0.0f;
40
stiffness = 0.0f;
41
damping = 0.0f;
42
}
43
48
void
Initialize
(
b2Body
* bodyA,
b2Body
* bodyB,
const
b2Vec2
& anchor);
49
51
b2Vec2
localAnchorA
;
52
54
b2Vec2
localAnchorB
;
55
57
float
referenceAngle
;
58
61
float
stiffness
;
62
64
float
damping
;
65
};
66
69
class
B2_API
b2WeldJoint
:
public
b2Joint
70
{
71
public
:
72
b2Vec2
GetAnchorA
()
const override
;
73
b2Vec2
GetAnchorB
()
const override
;
74
75
b2Vec2
GetReactionForce
(
float
inv_dt)
const override
;
76
float
GetReactionTorque
(
float
inv_dt)
const override
;
77
79
const
b2Vec2
&
GetLocalAnchorA
()
const
{
return
m_localAnchorA; }
80
82
const
b2Vec2
&
GetLocalAnchorB
()
const
{
return
m_localAnchorB; }
83
85
float
GetReferenceAngle
()
const
{
return
m_referenceAngle; }
86
88
void
SetStiffness
(
float
hz) { m_stiffness = hz; }
89
float
GetStiffness
()
const
{
return
m_stiffness; }
90
92
void
SetDamping
(
float
damping) { m_damping = damping; }
93
float
GetDamping
()
const
{
return
m_damping; }
94
96
void
Dump
()
override
;
97
98
protected
:
99
100
friend
class
b2Joint
;
101
102
b2WeldJoint
(
const
b2WeldJointDef
* def);
103
104
void
InitVelocityConstraints
(
const
b2SolverData
& data)
override
;
105
void
SolveVelocityConstraints
(
const
b2SolverData
& data)
override
;
106
bool
SolvePositionConstraints
(
const
b2SolverData
& data)
override
;
107
108
float
m_stiffness
;
109
float
m_damping
;
110
float
m_bias
;
111
112
// Solver shared
113
b2Vec2
m_localAnchorA
;
114
b2Vec2
m_localAnchorB
;
115
float
m_referenceAngle
;
116
float
m_gamma
;
117
b2Vec3
m_impulse
;
118
119
// Solver temp
120
int32
m_indexA
;
121
int32
m_indexB
;
122
b2Vec2
m_rA
;
123
b2Vec2
m_rB
;
124
b2Vec2
m_localCenterA
;
125
b2Vec2
m_localCenterB
;
126
float
m_invMassA
;
127
float
m_invMassB
;
128
float
m_invIA
;
129
float
m_invIB
;
130
b2Mat33
m_mass
;
131
};
132
133
#endif
b2WeldJoint::m_invMassB
float m_invMassB
Definition:
b2_weld_joint.h:127
b2WeldJoint::m_bias
float m_bias
Definition:
b2_weld_joint.h:110
b2WeldJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2_weld_joint.h:114
b2_api.h
b2Joint::GetReactionTorque
virtual float GetReactionTorque(float inv_dt) const =0
Get the reaction torque on bodyB in N*m.
b2WeldJoint::m_referenceAngle
float m_referenceAngle
Definition:
b2_weld_joint.h:115
b2WeldJoint::m_invIA
float m_invIA
Definition:
b2_weld_joint.h:128
b2WeldJoint::m_localCenterA
b2Vec2 m_localCenterA
Definition:
b2_weld_joint.h:124
b2WeldJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition:
b2_weld_joint.h:51
b2WeldJointDef
Definition:
b2_weld_joint.h:32
b2Joint::SolvePositionConstraints
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2WeldJoint::m_damping
float m_damping
Definition:
b2_weld_joint.h:109
b2SolverData
Solver Data.
Definition:
b2_time_step.h:67
b2_joint.h
b2WeldJoint::m_indexB
int32 m_indexB
Definition:
b2_weld_joint.h:121
b2WeldJoint::SetStiffness
void SetStiffness(float hz)
Set/get stiffness in N*m.
Definition:
b2_weld_joint.h:88
b2Vec3
A 2D column vector with 3 elements.
Definition:
b2_math.h:132
b2WeldJointDef::b2WeldJointDef
b2WeldJointDef()
Definition:
b2_weld_joint.h:34
b2Joint::InitVelocityConstraints
virtual void InitVelocityConstraints(const b2SolverData &data)=0
b2WeldJoint
Definition:
b2_weld_joint.h:69
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2_body.h:128
B2_API
#define B2_API
Definition:
b2_api.h:49
b2WeldJoint::m_impulse
b2Vec3 m_impulse
Definition:
b2_weld_joint.h:117
b2Vec2
A 2D column vector.
Definition:
b2_math.h:41
b2Joint::Dump
virtual void Dump()
Dump this joint to the log file.
Definition:
b2_joint.h:151
b2WeldJoint::m_indexA
int32 m_indexA
Definition:
b2_weld_joint.h:120
f
f
b2Joint::SolveVelocityConstraints
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2WeldJoint::GetStiffness
float GetStiffness() const
Definition:
b2_weld_joint.h:89
b2Joint::GetAnchorA
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
b2Joint
Definition:
b2_joint.h:110
b2WeldJoint::m_mass
b2Mat33 m_mass
Definition:
b2_weld_joint.h:130
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2_joint.h:72
b2WeldJoint::m_invMassA
float m_invMassA
Definition:
b2_weld_joint.h:126
b2WeldJoint::GetReferenceAngle
float GetReferenceAngle() const
Get the reference angle.
Definition:
b2_weld_joint.h:85
b2WeldJoint::m_gamma
float m_gamma
Definition:
b2_weld_joint.h:116
b2WeldJointDef::damping
float damping
The rotational damping in N*m*s.
Definition:
b2_weld_joint.h:64
b2WeldJoint::GetDamping
float GetDamping() const
Definition:
b2_weld_joint.h:93
b2WeldJointDef::stiffness
float stiffness
Definition:
b2_weld_joint.h:61
e_weldJoint
@ e_weldJoint
Definition:
b2_joint.h:45
b2WeldJoint::m_stiffness
float m_stiffness
Definition:
b2_weld_joint.h:108
b2WeldJoint::m_localCenterB
b2Vec2 m_localCenterB
Definition:
b2_weld_joint.h:125
b2WeldJoint::m_rA
b2Vec2 m_rA
Definition:
b2_weld_joint.h:122
ImGui::Initialize
IMGUI_API void Initialize(ImGuiContext *context)
Definition:
imgui.cpp:3473
b2WeldJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2_weld_joint.h:113
int32
signed int int32
Definition:
b2_types.h:28
b2WeldJoint::GetLocalAnchorB
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition:
b2_weld_joint.h:82
b2WeldJoint::m_rB
b2Vec2 m_rB
Definition:
b2_weld_joint.h:123
b2Mat33
A 3-by-3 matrix. Stored in column-major order.
Definition:
b2_math.h:245
type
GLenum type
Definition:
gl.h:1033
b2Joint::GetAnchorB
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
b2WeldJoint::GetLocalAnchorA
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition:
b2_weld_joint.h:79
b2WeldJoint::SetDamping
void SetDamping(float damping)
Set/get damping in N*m*s.
Definition:
b2_weld_joint.h:92
b2WeldJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition:
b2_weld_joint.h:54
b2WeldJointDef::referenceAngle
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition:
b2_weld_joint.h:57
b2WeldJoint::m_invIB
float m_invIB
Definition:
b2_weld_joint.h:129
b2Joint::GetReactionForce
virtual b2Vec2 GetReactionForce(float inv_dt) const =0
Get the reaction force on bodyB at the joint anchor in Newtons.
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07