b2PrismaticJoint.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
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, subject to the following restrictions:
10 * 1. The origin of this software must not be misrepresented; you must not
11 * claim that you wrote the original software. If you use this software
12 * in a product, an acknowledgment in the product documentation would be
13 * appreciated but is not required.
14 * 2. Altered source versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software.
16 * 3. This notice may not be removed or altered from any source distribution.
17 */
18 
20 #include <Box2D/Dynamics/b2Body.h>
22 
23 // Linear constraint (point-to-line)
24 // d = p2 - p1 = x2 + r2 - x1 - r1
25 // C = dot(perp, d)
26 // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1))
27 // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2)
28 // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]
29 //
30 // Angular constraint
31 // C = a2 - a1 + a_initial
32 // Cdot = w2 - w1
33 // J = [0 0 -1 0 0 1]
34 //
35 // K = J * invM * JT
36 //
37 // J = [-a -s1 a s2]
38 // [0 -1 0 1]
39 // a = perp
40 // s1 = cross(d + r1, a) = cross(p2 - x1, a)
41 // s2 = cross(r2, a) = cross(p2 - x2, a)
42 
43 
44 // Motor/Limit linear constraint
45 // C = dot(ax1, d)
46 // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2)
47 // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]
48 
49 // Block Solver
50 // We develop a block solver that includes the joint limit. This makes the limit stiff (inelastic) even
51 // when the mass has poor distribution (leading to large torques about the joint anchor points).
52 //
53 // The Jacobian has 3 rows:
54 // J = [-uT -s1 uT s2] // linear
55 // [0 -1 0 1] // angular
56 // [-vT -a1 vT a2] // limit
57 //
58 // u = perp
59 // v = axis
60 // s1 = cross(d + r1, u), s2 = cross(r2, u)
61 // a1 = cross(d + r1, v), a2 = cross(r2, v)
62 
63 // M * (v2 - v1) = JT * df
64 // J * v2 = bias
65 //
66 // v2 = v1 + invM * JT * df
67 // J * (v1 + invM * JT * df) = bias
68 // K * df = bias - J * v1 = -Cdot
69 // K = J * invM * JT
70 // Cdot = J * v1 - bias
71 //
72 // Now solve for f2.
73 // df = f2 - f1
74 // K * (f2 - f1) = -Cdot
75 // f2 = invK * (-Cdot) + f1
76 //
77 // Clamp accumulated limit impulse.
78 // lower: f2(3) = max(f2(3), 0)
79 // upper: f2(3) = min(f2(3), 0)
80 //
81 // Solve for correct f2(1:2)
82 // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1
83 // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)
84 // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) + K(1:2,1:2) * f1(1:2)
85 // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2)
86 //
87 // Now compute impulse to be applied:
88 // df = f2 - f1
89 
90 void b2PrismaticJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor, const b2Vec2& axis)
91 {
92  bodyA = bA;
93  bodyB = bB;
94  localAnchorA = bodyA->GetLocalPoint(anchor);
95  localAnchorB = bodyB->GetLocalPoint(anchor);
98 }
99 
101 : b2Joint(def)
102 {
105  m_localXAxisA = def->localAxisA;
109 
110  m_impulse.SetZero();
111  m_motorMass = 0.0f;
112  m_motorImpulse = 0.0f;
113 
117  m_motorSpeed = def->motorSpeed;
118  m_enableLimit = def->enableLimit;
119  m_enableMotor = def->enableMotor;
121 
122  m_axis.SetZero();
123  m_perp.SetZero();
124 }
125 
127 {
136 
137  b2Vec2 cA = data.positions[m_indexA].c;
138  float32 aA = data.positions[m_indexA].a;
139  b2Vec2 vA = data.velocities[m_indexA].v;
140  float32 wA = data.velocities[m_indexA].w;
141 
142  b2Vec2 cB = data.positions[m_indexB].c;
143  float32 aB = data.positions[m_indexB].a;
144  b2Vec2 vB = data.velocities[m_indexB].v;
145  float32 wB = data.velocities[m_indexB].w;
146 
147  b2Rot qA(aA), qB(aB);
148 
149  // Compute the effective masses.
152  b2Vec2 d = (cB - cA) + rB - rA;
153 
154  float32 mA = m_invMassA, mB = m_invMassB;
155  float32 iA = m_invIA, iB = m_invIB;
156 
157  // Compute motor Jacobian and effective mass.
158  {
159  m_axis = b2Mul(qA, m_localXAxisA);
160  m_a1 = b2Cross(d + rA, m_axis);
161  m_a2 = b2Cross(rB, m_axis);
162 
163  m_motorMass = mA + mB + iA * m_a1 * m_a1 + iB * m_a2 * m_a2;
164  if (m_motorMass > 0.0f)
165  {
166  m_motorMass = 1.0f / m_motorMass;
167  }
168  }
169 
170  // Prismatic constraint.
171  {
172  m_perp = b2Mul(qA, m_localYAxisA);
173 
174  m_s1 = b2Cross(d + rA, m_perp);
175  m_s2 = b2Cross(rB, m_perp);
176 
177  float32 s1test;
178  s1test = b2Cross(rA, m_perp);
179 
180  float32 k11 = mA + mB + iA * m_s1 * m_s1 + iB * m_s2 * m_s2;
181  float32 k12 = iA * m_s1 + iB * m_s2;
182  float32 k13 = iA * m_s1 * m_a1 + iB * m_s2 * m_a2;
183  float32 k22 = iA + iB;
184  if (k22 == 0.0f)
185  {
186  // For bodies with fixed rotation.
187  k22 = 1.0f;
188  }
189  float32 k23 = iA * m_a1 + iB * m_a2;
190  float32 k33 = mA + mB + iA * m_a1 * m_a1 + iB * m_a2 * m_a2;
191 
192  m_K.ex.Set(k11, k12, k13);
193  m_K.ey.Set(k12, k22, k23);
194  m_K.ez.Set(k13, k23, k33);
195  }
196 
197  // Compute motor and limit terms.
198  if (m_enableLimit)
199  {
200  float32 jointTranslation = b2Dot(m_axis, d);
202  {
204  }
205  else if (jointTranslation <= m_lowerTranslation)
206  {
208  {
210  m_impulse.z = 0.0f;
211  }
212  }
213  else if (jointTranslation >= m_upperTranslation)
214  {
216  {
218  m_impulse.z = 0.0f;
219  }
220  }
221  else
222  {
224  m_impulse.z = 0.0f;
225  }
226  }
227  else
228  {
230  m_impulse.z = 0.0f;
231  }
232 
233  if (m_enableMotor == false)
234  {
235  m_motorImpulse = 0.0f;
236  }
237 
238  if (data.step.warmStarting)
239  {
240  // Account for variable time step.
241  m_impulse *= data.step.dtRatio;
242  m_motorImpulse *= data.step.dtRatio;
243 
247 
248  vA -= mA * P;
249  wA -= iA * LA;
250 
251  vB += mB * P;
252  wB += iB * LB;
253  }
254  else
255  {
256  m_impulse.SetZero();
257  m_motorImpulse = 0.0f;
258  }
259 
260  data.velocities[m_indexA].v = vA;
261  data.velocities[m_indexA].w = wA;
262  data.velocities[m_indexB].v = vB;
263  data.velocities[m_indexB].w = wB;
264 }
265 
267 {
268  b2Vec2 vA = data.velocities[m_indexA].v;
269  float32 wA = data.velocities[m_indexA].w;
270  b2Vec2 vB = data.velocities[m_indexB].v;
271  float32 wB = data.velocities[m_indexB].w;
272 
273  float32 mA = m_invMassA, mB = m_invMassB;
274  float32 iA = m_invIA, iB = m_invIB;
275 
276  // Solve linear motor constraint.
278  {
279  float32 Cdot = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA;
280  float32 impulse = m_motorMass * (m_motorSpeed - Cdot);
281  float32 oldImpulse = m_motorImpulse;
282  float32 maxImpulse = data.step.dt * m_maxMotorForce;
283  m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse);
284  impulse = m_motorImpulse - oldImpulse;
285 
286  b2Vec2 P = impulse * m_axis;
287  float32 LA = impulse * m_a1;
288  float32 LB = impulse * m_a2;
289 
290  vA -= mA * P;
291  wA -= iA * LA;
292 
293  vB += mB * P;
294  wB += iB * LB;
295  }
296 
297  b2Vec2 Cdot1;
298  Cdot1.x = b2Dot(m_perp, vB - vA) + m_s2 * wB - m_s1 * wA;
299  Cdot1.y = wB - wA;
300 
302  {
303  // Solve prismatic and limit constraint in block form.
304  float32 Cdot2;
305  Cdot2 = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA;
306  b2Vec3 Cdot(Cdot1.x, Cdot1.y, Cdot2);
307 
308  b2Vec3 f1 = m_impulse;
309  b2Vec3 df = m_K.Solve33(-Cdot);
310  m_impulse += df;
311 
313  {
314  m_impulse.z = b2Max(m_impulse.z, 0.0f);
315  }
316  else if (m_limitState == e_atUpperLimit)
317  {
318  m_impulse.z = b2Min(m_impulse.z, 0.0f);
319  }
320 
321  // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2)
322  b2Vec2 b = -Cdot1 - (m_impulse.z - f1.z) * b2Vec2(m_K.ez.x, m_K.ez.y);
323  b2Vec2 f2r = m_K.Solve22(b) + b2Vec2(f1.x, f1.y);
324  m_impulse.x = f2r.x;
325  m_impulse.y = f2r.y;
326 
327  df = m_impulse - f1;
328 
329  b2Vec2 P = df.x * m_perp + df.z * m_axis;
330  float32 LA = df.x * m_s1 + df.y + df.z * m_a1;
331  float32 LB = df.x * m_s2 + df.y + df.z * m_a2;
332 
333  vA -= mA * P;
334  wA -= iA * LA;
335 
336  vB += mB * P;
337  wB += iB * LB;
338  }
339  else
340  {
341  // Limit is inactive, just solve the prismatic constraint in block form.
342  b2Vec2 df = m_K.Solve22(-Cdot1);
343  m_impulse.x += df.x;
344  m_impulse.y += df.y;
345 
346  b2Vec2 P = df.x * m_perp;
347  float32 LA = df.x * m_s1 + df.y;
348  float32 LB = df.x * m_s2 + df.y;
349 
350  vA -= mA * P;
351  wA -= iA * LA;
352 
353  vB += mB * P;
354  wB += iB * LB;
355  }
356 
357  data.velocities[m_indexA].v = vA;
358  data.velocities[m_indexA].w = wA;
359  data.velocities[m_indexB].v = vB;
360  data.velocities[m_indexB].w = wB;
361 }
362 
364 {
365  b2Vec2 cA = data.positions[m_indexA].c;
366  float32 aA = data.positions[m_indexA].a;
367  b2Vec2 cB = data.positions[m_indexB].c;
368  float32 aB = data.positions[m_indexB].a;
369 
370  b2Rot qA(aA), qB(aB);
371 
372  float32 mA = m_invMassA, mB = m_invMassB;
373  float32 iA = m_invIA, iB = m_invIB;
374 
375  // Compute fresh Jacobians
378  b2Vec2 d = cB + rB - cA - rA;
379 
380  b2Vec2 axis = b2Mul(qA, m_localXAxisA);
381  float32 a1 = b2Cross(d + rA, axis);
382  float32 a2 = b2Cross(rB, axis);
383  b2Vec2 perp = b2Mul(qA, m_localYAxisA);
384 
385  float32 s1 = b2Cross(d + rA, perp);
386  float32 s2 = b2Cross(rB, perp);
387 
388  b2Vec3 impulse;
389  b2Vec2 C1;
390  C1.x = b2Dot(perp, d);
391  C1.y = aB - aA - m_referenceAngle;
392 
393  float32 linearError = b2Abs(C1.x);
394  float32 angularError = b2Abs(C1.y);
395 
396  bool active = false;
397  float32 C2 = 0.0f;
398  if (m_enableLimit)
399  {
400  float32 translation = b2Dot(axis, d);
402  {
403  // Prevent large angular corrections
405  linearError = b2Max(linearError, b2Abs(translation));
406  active = true;
407  }
408  else if (translation <= m_lowerTranslation)
409  {
410  // Prevent large linear corrections and allow some slop.
411  C2 = b2Clamp(translation - m_lowerTranslation + b2_linearSlop, -b2_maxLinearCorrection, 0.0f);
412  linearError = b2Max(linearError, m_lowerTranslation - translation);
413  active = true;
414  }
415  else if (translation >= m_upperTranslation)
416  {
417  // Prevent large linear corrections and allow some slop.
418  C2 = b2Clamp(translation - m_upperTranslation - b2_linearSlop, 0.0f, b2_maxLinearCorrection);
419  linearError = b2Max(linearError, translation - m_upperTranslation);
420  active = true;
421  }
422  }
423 
424  if (active)
425  {
426  float32 k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;
427  float32 k12 = iA * s1 + iB * s2;
428  float32 k13 = iA * s1 * a1 + iB * s2 * a2;
429  float32 k22 = iA + iB;
430  if (k22 == 0.0f)
431  {
432  // For fixed rotation
433  k22 = 1.0f;
434  }
435  float32 k23 = iA * a1 + iB * a2;
436  float32 k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;
437 
438  b2Mat33 K;
439  K.ex.Set(k11, k12, k13);
440  K.ey.Set(k12, k22, k23);
441  K.ez.Set(k13, k23, k33);
442 
443  b2Vec3 C;
444  C.x = C1.x;
445  C.y = C1.y;
446  C.z = C2;
447 
448  impulse = K.Solve33(-C);
449  }
450  else
451  {
452  float32 k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;
453  float32 k12 = iA * s1 + iB * s2;
454  float32 k22 = iA + iB;
455  if (k22 == 0.0f)
456  {
457  k22 = 1.0f;
458  }
459 
460  b2Mat22 K;
461  K.ex.Set(k11, k12);
462  K.ey.Set(k12, k22);
463 
464  b2Vec2 impulse1 = K.Solve(-C1);
465  impulse.x = impulse1.x;
466  impulse.y = impulse1.y;
467  impulse.z = 0.0f;
468  }
469 
470  b2Vec2 P = impulse.x * perp + impulse.z * axis;
471  float32 LA = impulse.x * s1 + impulse.y + impulse.z * a1;
472  float32 LB = impulse.x * s2 + impulse.y + impulse.z * a2;
473 
474  cA -= mA * P;
475  aA -= iA * LA;
476  cB += mB * P;
477  aB += iB * LB;
478 
479  data.positions[m_indexA].c = cA;
480  data.positions[m_indexA].a = aA;
481  data.positions[m_indexB].c = cB;
482  data.positions[m_indexB].a = aB;
483 
484  return linearError <= b2_linearSlop && angularError <= b2_angularSlop;
485 }
486 
488 {
490 }
491 
493 {
495 }
496 
498 {
499  return inv_dt * (m_impulse.x * m_perp + (m_motorImpulse + m_impulse.z) * m_axis);
500 }
501 
503 {
504  return inv_dt * m_impulse.y;
505 }
506 
508 {
511  b2Vec2 d = pB - pA;
513 
514  float32 translation = b2Dot(d, axis);
515  return translation;
516 }
517 
519 {
520  b2Body* bA = m_bodyA;
521  b2Body* bB = m_bodyB;
522 
525  b2Vec2 p1 = bA->m_sweep.c + rA;
526  b2Vec2 p2 = bB->m_sweep.c + rB;
527  b2Vec2 d = p2 - p1;
528  b2Vec2 axis = b2Mul(bA->m_xf.q, m_localXAxisA);
529 
530  b2Vec2 vA = bA->m_linearVelocity;
531  b2Vec2 vB = bB->m_linearVelocity;
532  float32 wA = bA->m_angularVelocity;
533  float32 wB = bB->m_angularVelocity;
534 
535  float32 speed = b2Dot(d, b2Cross(wA, axis)) + b2Dot(axis, vB + b2Cross(wB, rB) - vA - b2Cross(wA, rA));
536  return speed;
537 }
538 
540 {
541  return m_enableLimit;
542 }
543 
545 {
546  if (flag != m_enableLimit)
547  {
548  m_bodyA->SetAwake(true);
549  m_bodyB->SetAwake(true);
550  m_enableLimit = flag;
551  m_impulse.z = 0.0f;
552  }
553 }
554 
556 {
557  return m_lowerTranslation;
558 }
559 
561 {
562  return m_upperTranslation;
563 }
564 
566 {
567  b2Assert(lower <= upper);
568  if (lower != m_lowerTranslation || upper != m_upperTranslation)
569  {
570  m_bodyA->SetAwake(true);
571  m_bodyB->SetAwake(true);
572  m_lowerTranslation = lower;
573  m_upperTranslation = upper;
574  m_impulse.z = 0.0f;
575  }
576 }
577 
579 {
580  return m_enableMotor;
581 }
582 
584 {
585  m_bodyA->SetAwake(true);
586  m_bodyB->SetAwake(true);
587  m_enableMotor = flag;
588 }
589 
591 {
592  m_bodyA->SetAwake(true);
593  m_bodyB->SetAwake(true);
594  m_motorSpeed = speed;
595 }
596 
598 {
599  m_bodyA->SetAwake(true);
600  m_bodyB->SetAwake(true);
601  m_maxMotorForce = force;
602 }
603 
605 {
606  return inv_dt * m_motorImpulse;
607 }
608 
610 {
611  int32 indexA = m_bodyA->m_islandIndex;
612  int32 indexB = m_bodyB->m_islandIndex;
613 
614  b2Log(" b2PrismaticJointDef jd;\n");
615  b2Log(" jd.bodyA = bodies[%d];\n", indexA);
616  b2Log(" jd.bodyB = bodies[%d];\n", indexB);
617  b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected);
618  b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y);
619  b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y);
620  b2Log(" jd.localAxisA.Set(%.15lef, %.15lef);\n", m_localXAxisA.x, m_localXAxisA.y);
621  b2Log(" jd.referenceAngle = %.15lef;\n", m_referenceAngle);
622  b2Log(" jd.enableLimit = bool(%d);\n", m_enableLimit);
623  b2Log(" jd.lowerTranslation = %.15lef;\n", m_lowerTranslation);
624  b2Log(" jd.upperTranslation = %.15lef;\n", m_upperTranslation);
625  b2Log(" jd.enableMotor = bool(%d);\n", m_enableMotor);
626  b2Log(" jd.motorSpeed = %.15lef;\n", m_motorSpeed);
627  b2Log(" jd.maxMotorForce = %.15lef;\n", m_maxMotorForce);
628  b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
629 }
d
float32 b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
Definition: b2Math.h:405
b2Velocity * velocities
Definition: b2TimeStep.h:67
float32 m_invMass
Definition: b2Body.h:455
int32 m_islandIndex
Definition: b2Body.h:434
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
Definition: b2Math.h:432
b2Vec2 GetReactionForce(float32 inv_dt) const
Get the reaction force on bodyB at the joint anchor in Newtons.
s1
void b2Log(const char *string,...)
Logging function.
Definition: b2Settings.cpp:38
b2Vec3 ex
Definition: b2Math.h:294
float32 a
Definition: b2TimeStep.h:52
#define b2_linearSlop
Definition: b2Settings.h:68
void SetMotorSpeed(float32 speed)
Set the motor speed, usually in meters per second.
float32 referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
b2Rot q
Definition: b2Math.h:372
bool SolvePositionConstraints(const b2SolverData &data)
b2TimeStep step
Definition: b2TimeStep.h:65
b2Vec2 m_linearVelocity
Definition: b2Body.h:439
b2Vec2 c
Definition: b2TimeStep.h:51
float32 w
Definition: b2TimeStep.h:59
bool m_collideConnected
Definition: b2Joint.h:181
float32 dtRatio
Definition: b2TimeStep.h:42
float32 GetReactionTorque(float32 inv_dt) const
Get the reaction torque on bodyB in N*m.
float32 y
Definition: b2Math.h:178
float32 upperTranslation
The upper translation limit, usually in meters.
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
Definition: b2Body.h:556
b2Vec2 localAxisA
The local translation unit axis in bodyA.
T b2Max(T a, T b)
Definition: b2Math.h:642
float32 GetAngle() const
Definition: b2Body.h:484
b2Vec3 ez
Definition: b2Math.h:294
float32 GetUpperLimit() const
Get the upper joint limit, usually in meters.
Solver Data.
Definition: b2TimeStep.h:63
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:61
double a2
int32 m_index
Definition: b2Joint.h:178
A 2D column vector.
Definition: b2Math.h:52
b2Vec2 ey
Definition: b2Math.h:252
float32 GetLowerLimit() const
Get the lower joint limit, usually in meters.
b2Vec2 c
center world positions
Definition: b2Math.h:393
#define b2_maxLinearCorrection
Definition: b2Settings.h:94
s2
signed int int32
Definition: b2Settings.h:31
float32 GetJointSpeed() const
Get the current joint translation speed, usually in meters per second.
b2Vec2 localCenter
local center of mass position
Definition: b2Math.h:392
float32 b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
Definition: b2Math.h:411
void SolveVelocityConstraints(const b2SolverData &data)
A 2D column vector with 3 elements.
Definition: b2Math.h:143
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:152
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
b2Vec3 ey
Definition: b2Math.h:294
b2Vec2 v
Definition: b2TimeStep.h:58
float32 GetJointTranslation() const
Get the current joint translation, usually in meters.
void InitVelocityConstraints(const b2SolverData &data)
void SetLimits(float32 lower, float32 upper)
Set the joint limits, usually in meters.
b2Vec2 localAnchorB
The local anchor point relative to bodyB&#39;s origin.
float32 x
Definition: b2Math.h:178
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
Definition: b2Body.h:561
bool IsMotorEnabled() const
Is the joint motor enabled?
float32 m_invI
Definition: b2Body.h:458
bool enableLimit
Enable/disable the joint limit.
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor, const b2Vec2 &axis)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
b2Body * m_bodyA
Definition: b2Joint.h:175
b2PrismaticJoint(const b2PrismaticJointDef *def)
b2Vec2 Solve(const b2Vec2 &b) const
Definition: b2Math.h:238
#define b2_angularSlop
Definition: b2Settings.h:72
void EnableLimit(bool flag)
Enable/disable the joint limit.
void Dump()
Dump to b2Log.
A 3-by-3 matrix. Stored in column-major order.
Definition: b2Math.h:256
float32 y
Definition: b2Math.h:139
b2Vec2 GetLocalPoint(const b2Vec2 &worldPoint) const
Definition: b2Body.h:566
bool IsLimitEnabled() const
Is the joint limit enabled?
void SetMaxMotorForce(float32 force)
Set the maximum motor force, usually in N.
b2Vec2 GetLocalVector(const b2Vec2 &worldVector) const
Definition: b2Body.h:571
b2Position * positions
Definition: b2TimeStep.h:66
b2Vec2 GetAnchorA() const
Get the anchor point on bodyA in world coordinates.
b2Vec2 Solve22(const b2Vec2 &b) const
Definition: b2Math.cpp:41
#define b2Assert(A)
Definition: b2Settings.h:27
b2Vec3 Solve33(const b2Vec3 &b) const
Definition: b2Math.cpp:25
b2Vec2 GetAnchorB() const
Get the anchor point on bodyB in world coordinates.
T b2Clamp(T a, T low, T high)
Definition: b2Math.h:653
float32 motorSpeed
The desired motor speed in radians per second.
bool enableMotor
Enable/disable the joint motor.
b2Vec2 ex
Definition: b2Math.h:252
T b2Abs(T a)
Definition: b2Math.h:615
b2Vec2 localAnchorA
The local anchor point relative to bodyA&#39;s origin.
A 2-by-2 matrix. Stored in column-major order.
Definition: b2Math.h:182
void EnableMotor(bool flag)
Enable/disable the joint motor.
b2Transform m_xf
Definition: b2Body.h:436
float32 m_angularVelocity
Definition: b2Body.h:440
b2LimitState m_limitState
bool warmStarting
Definition: b2TimeStep.h:45
Rotation.
Definition: b2Math.h:298
void Set(float32 x_, float32 y_, float32 z_)
Set this vector to some specified coordinates.
Definition: b2Math.h:155
const T1 & f1
T b2Min(T a, T b)
Definition: b2Math.h:631
GLdouble GLdouble GLdouble b
float32 z
Definition: b2Math.h:178
float32 x
Definition: b2Math.h:139
double a1
b2Body * bodyA
The first attached body.
Definition: b2Joint.h:92
float32 Normalize()
Convert this vector into a unit vector. Returns the length.
Definition: b2Math.h:113
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:64
float32 dt
Definition: b2TimeStep.h:40
float32 GetMotorForce(float32 inv_dt) const
Get the current motor force given the inverse time step, usually in N.
float32 lowerTranslation
The lower translation limit, usually in meters.
void SetAwake(bool flag)
Definition: b2Body.h:633
b2Body * bodyB
The second attached body.
Definition: b2Joint.h:95
b2Body * m_bodyB
Definition: b2Joint.h:176
b2Sweep m_sweep
Definition: b2Body.h:437
float float32
Definition: b2Settings.h:35
CArrayDouble< 6 > C
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f
float32 maxMotorForce
The maximum motor torque, usually in N-m.


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51