1/**
2 * Copyright (c) 2006-2023 LOVE Development Team
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 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20
21#ifndef LOVE_PHYSICS_BOX2D_GEAR_JOINT_H
22#define LOVE_PHYSICS_BOX2D_GEAR_JOINT_H
23
24// Module
25#include "Joint.h"
26
27namespace love
28{
29namespace physics
30{
31namespace box2d
32{
33
34/**
35 * A gear joint is used to connect two joints together. Either joint
36 * can be a revolute or prismatic joint. You specify a gear ratio
37 * to bind the motions together:
38 * coordinate1 + ratio * coordinate2 = constant
39 *
40 * The ratio can be negative or positive. If one joint is a revolute joint
41 * and the other joint is a prismatic joint, then the ratio will have units
42 * of length or units of 1/length.
43 * Warning: The revolute and prismatic joints must be attached to
44 * fixed bodies (which must be body1 on those joints).
45 **/
46class GearJoint : public Joint
47{
48public:
49
50 static love::Type type;
51
52 /**
53 * Creates a GearJoint connecting joint1 to joint2.
54 **/
55 GearJoint(Joint *joint1, Joint *joint2, float ratio, bool collideConnected);
56
57 virtual ~GearJoint();
58
59 /**
60 * Sets the ratio.
61 **/
62 void setRatio(float ratio);
63
64 /**
65 * Gets the ratio.
66 **/
67 float getRatio() const;
68
69 Joint *getJointA() const;
70 Joint *getJointB() const;
71
72private:
73 // The Box2D GearJoint object.
74 b2GearJoint *joint;
75};
76
77} // box2d
78} // physics
79} // love
80
81#endif // LOVE_PHYSICS_BOX2D_GEAR_JOINT_H
82