PulleyJointConf.cpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright (c) 2007 Erin Catto http://www.box2d.org
3  * Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 
25 
26 namespace playrho {
27 namespace d2 {
28 
30  const Length2 groundA, const Length2 groundB,
31  const Length2 anchorA, const Length2 anchorB):
32  super{super{JointType::Pulley}.UseBodyA(bA).UseBodyB(bB).UseCollideConnected(true)},
33  groundAnchorA{groundA},
34  groundAnchorB{groundB},
35  localAnchorA{GetLocalPoint(*bA, anchorA)},
36  localAnchorB{GetLocalPoint(*bB, anchorB)},
37  lengthA{GetMagnitude(anchorA - groundA)},
38  lengthB{GetMagnitude(anchorB - groundB)}
39 {
40  // Intentionally empty.
41 }
42 
44 {
45  auto def = PulleyJointConf{};
46 
47  Set(def, joint);
48 
49  def.groundAnchorA = joint.GetGroundAnchorA();
50  def.groundAnchorB = joint.GetGroundAnchorB();
51  def.localAnchorA = joint.GetLocalAnchorA();
52  def.localAnchorB = joint.GetGroundAnchorB();
53  def.lengthA = joint.GetLengthA();
54  def.lengthB = joint.GetLengthB();
55  def.ratio = joint.GetRatio();
56 
57  return def;
58 }
59 
60 } // namespace d2
61 } // namespace playrho