PlayRho  2.0.0
An interactive physics engine & library.
PrismaticJoint.cpp

This is the googletest based unit testing file for the interfaces to playrho::d2::PrismaticJointConf.

/*
* Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include "UnitTests.hpp"
#include <playrho/d2/WorldMisc.hpp> // for Step
using namespace playrho;
using namespace playrho::d2;
TEST(PrismaticJointConf, Construction)
{
auto world = World{};
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = Joint{jd};
EXPECT_EQ(GetBodyA(joint), b0);
EXPECT_EQ(GetBodyB(joint), b1);
EXPECT_EQ(GetLocalAnchorA(joint), jd.localAnchorA);
EXPECT_EQ(GetLocalAnchorB(joint), jd.localAnchorB);
EXPECT_EQ(GetLinearReaction(joint), Momentum2{});
EXPECT_EQ(GetAngularReaction(joint), AngularMomentum{0});
EXPECT_EQ(GetReferenceAngle(joint), 0_deg);
EXPECT_EQ(GetLocalXAxisA(joint), UnitVec::GetRight());
EXPECT_THROW(GetAngularMass(joint), std::invalid_argument);
EXPECT_THROW(GetMaxForce(joint), std::invalid_argument);
EXPECT_THROW(GetMaxTorque(joint), std::invalid_argument);
EXPECT_THROW(GetMaxMotorTorque(joint), std::invalid_argument);
EXPECT_THROW(GetRatio(joint), std::invalid_argument);
EXPECT_THROW(GetDampingRatio(joint), std::invalid_argument);
EXPECT_THROW(GetFrequency(joint), std::invalid_argument);
EXPECT_THROW(SetFrequency(joint, 2_Hz), std::invalid_argument);
EXPECT_THROW(GetAngularMotorImpulse(joint), std::invalid_argument);
EXPECT_THROW(GetTarget(joint), std::invalid_argument);
EXPECT_THROW(SetTarget(joint, Length2{1_m, 1_m}), std::invalid_argument);
EXPECT_THROW(GetAngularLowerLimit(joint), std::invalid_argument);
EXPECT_THROW(GetAngularUpperLimit(joint), std::invalid_argument);
EXPECT_THROW(GetLinearOffset(joint), std::invalid_argument);
EXPECT_THROW(SetLinearOffset(joint, Length2{1_m, 1_m}), std::invalid_argument);
EXPECT_THROW(GetAngularOffset(joint), std::invalid_argument);
EXPECT_THROW(SetAngularOffset(joint, 10_deg), std::invalid_argument);
EXPECT_THROW(GetGroundAnchorA(joint), std::invalid_argument);
EXPECT_THROW(GetGroundAnchorB(joint), std::invalid_argument);
EXPECT_THROW(GetLength(joint), std::invalid_argument);
}
TEST(PrismaticJointConf, EnableLimit)
{
auto world = World{};
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = Joint{jd};
EXPECT_FALSE(IsLimitEnabled(joint));
EnableLimit(joint, false);
EXPECT_FALSE(IsLimitEnabled(joint));
EnableLimit(joint, true);
EXPECT_TRUE(IsLimitEnabled(joint));
EXPECT_EQ(GetLinearMotorImpulse(joint), 0_Ns);
const auto id = CreateJoint(world, joint);
EXPECT_EQ(GetMotorForce(world, id, 1_Hz), 0 * Newton);
}
TEST(PrismaticJointConf, ShiftOrigin)
{
auto world = World{};
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = Joint{jd};
const auto newOrigin = Length2{1_m, 1_m};
EXPECT_FALSE(ShiftOrigin(joint, newOrigin));
}
TEST(PrismaticJointConf, EnableMotor)
{
World world;
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = Joint{jd};
EXPECT_FALSE(IsMotorEnabled(joint));
EnableMotor(joint, false);
EXPECT_FALSE(IsMotorEnabled(joint));
EnableMotor(joint, true);
EXPECT_TRUE(IsMotorEnabled(joint));
}
TEST(PrismaticJointConf, SetMaxMotorForce)
{
World world;
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = Joint{jd};
ASSERT_EQ(GetMaxMotorForce(joint), 0_N);
SetMaxMotorForce(joint, 2_N);
EXPECT_EQ(GetMaxMotorForce(joint), 2_N);
}
TEST(PrismaticJointConf, MotorSpeed)
{
World world;
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
const auto newValue = Real(5) * RadianPerSecond;
auto joint = Joint{jd};
ASSERT_NE(GetMotorSpeed(joint), newValue);
EXPECT_EQ(GetMotorSpeed(joint), jd.motorSpeed);
SetMotorSpeed(joint, newValue);
EXPECT_EQ(GetMotorSpeed(joint), newValue);
}
TEST(PrismaticJointConf, SetLinearLimits)
{
World world;
const auto b0 = CreateBody(world);
const auto b1 = CreateBody(world);
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
const auto upperValue = +5_m;
const auto lowerValue = -8_m;
auto joint = Joint{jd};
ASSERT_NE(GetLinearUpperLimit(joint), upperValue);
ASSERT_NE(GetLinearLowerLimit(joint), lowerValue);
SetLinearLimits(joint, lowerValue, upperValue);
EXPECT_EQ(GetLinearUpperLimit(joint), upperValue);
EXPECT_EQ(GetLinearLowerLimit(joint), lowerValue);
}
TEST(PrismaticJointConf, GetAnchorAandB)
{
World world;
const auto loc0 = Length2{+1_m, -3_m};
const auto loc1 = Length2{-2_m, Real(+1.2f) * Meter};
const auto b0 = CreateBody(world, BodyConf{}.UseLocation(loc0));
const auto b1 = CreateBody(world, BodyConf{}.UseLocation(loc1));
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(4_m, 5_m);
jd.localAnchorB = Length2(6_m, 7_m);
auto joint = CreateJoint(world, Joint{jd});
ASSERT_EQ(GetLocalAnchorA(world, joint), jd.localAnchorA);
ASSERT_EQ(GetLocalAnchorB(world, joint), jd.localAnchorB);
EXPECT_EQ(GetAnchorA(world, joint), loc0 + jd.localAnchorA);
EXPECT_EQ(GetAnchorB(world, joint), loc1 + jd.localAnchorB);
}
TEST(PrismaticJointConf, GetJointTranslation)
{
World world;
const auto loc0 = Length2{+1_m, -3_m};
const auto loc1 = Length2{+1_m, +3_m};
const auto b0 = CreateBody(world, BodyConf{}.UseLocation(loc0));
const auto b1 = CreateBody(world, BodyConf{}.UseLocation(loc1));
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(-1_m, 5_m);
jd.localAnchorB = Length2(+1_m, 5_m);
auto joint = CreateJoint(world, Joint{jd});
EXPECT_EQ(GetJointTranslation(world, joint), Length(2_m));
}
TEST(PrismaticJointConf, GetLinearVelocity)
{
World world;
const auto loc0 = Length2{+1_m, -3_m};
const auto loc1 = Length2{+1_m, +3_m};
const auto b0 = CreateBody(world, BodyConf{}.UseLocation(loc0));
const auto b1 = CreateBody(world, BodyConf{}.UseLocation(loc1));
auto jd = PrismaticJointConf{};
jd.bodyA = b0;
jd.bodyB = b1;
jd.localAnchorA = Length2(-1_m, 5_m);
jd.localAnchorB = Length2(+1_m, 5_m);
EXPECT_EQ(GetLinearVelocity(world, jd), LinearVelocity(0));
}
TEST(PrismaticJointConf, WithDynamicCirclesAndLimitEnabled)
{
auto world = World{};
const auto p1 = Length2{-1_m, 0_m};
const auto p2 = Length2{+1_m, 0_m};
const auto b1 = CreateBody(world, BodyConf{}.Use(BodyType::Dynamic).UseLocation(p1));
const auto b2 = CreateBody(world, BodyConf{}.Use(BodyType::Dynamic).UseLocation(p2));
const auto shapeId = CreateShape(world, DiskShapeConf{}.UseRadius(0.2_m));
Attach(world, b1, shapeId);
Attach(world, b2, shapeId);
const auto anchor = Length2(2_m, 1_m);
const auto jd =
GetPrismaticJointConf(world, b1, b2, anchor, UnitVec::GetRight()).UseEnableLimit(true);
const auto joint = CreateJoint(world, Joint{jd});
ASSERT_NE(joint, InvalidJointID);
{
const auto conf = TypeCast<PrismaticJointConf>(GetJoint(world, joint));
ASSERT_EQ(GetLinearLowerLimit(conf), 0_m);
ASSERT_EQ(GetLinearUpperLimit(conf), 0_m);
}
EXPECT_NO_THROW(Step(world, 1_s));
EXPECT_NEAR(double(Real{GetX(GetLocation(world, b1)) / Meter}), -1.0, 0.001);
EXPECT_NEAR(double(Real{GetY(GetLocation(world, b1)) / Meter}), 0.0, 0.001);
EXPECT_NEAR(double(Real{GetX(GetLocation(world, b2)) / Meter}), +1.0, 0.01);
EXPECT_NEAR(double(Real{GetY(GetLocation(world, b2)) / Meter}), 0.0, 0.01);
EXPECT_EQ(GetAngle(world, b1), 0_deg);
EXPECT_EQ(GetAngle(world, b2), 0_deg);
{
auto conf = TypeCast<PrismaticJointConf>(GetJoint(world, joint));
EXPECT_EQ(GetLinearLowerLimit(conf), 0_m);
EXPECT_EQ(GetLinearUpperLimit(conf), 0_m);
EXPECT_NO_THROW(SetLinearLimits(conf, 0_m, 2_m));
EXPECT_NO_THROW(SetJoint(world, joint, conf));
}
EXPECT_NO_THROW(Step(world, 1_s));
{
auto conf = TypeCast<PrismaticJointConf>(GetJoint(world, joint));
EXPECT_EQ(GetLinearLowerLimit(conf), 0_m);
EXPECT_EQ(GetLinearUpperLimit(conf), 2_m);
EXPECT_NO_THROW(SetLinearLimits(conf, -2_m, 0_m));
EXPECT_NO_THROW(SetJoint(world, joint, conf));
}
EXPECT_NO_THROW(Step(world, 1_s));
{
auto conf = TypeCast<PrismaticJointConf>(GetJoint(world, joint));
EXPECT_EQ(GetLinearLowerLimit(conf), -2_m);
EXPECT_EQ(GetLinearUpperLimit(conf), 0_m);
}
EXPECT_NO_THROW(EnableMotor(world, joint, true));
EXPECT_NO_THROW(Step(world, 1_s));
EXPECT_EQ(GetLinearMotorImpulse(world, joint), Momentum(0));
}
TEST(PrismaticJointConf, EqualsOperator)
{
EXPECT_TRUE(PrismaticJointConf() == PrismaticJointConf());
{
auto conf = PrismaticJointConf{};
conf.localAnchorA = Length2{1.2_m, -3_m};
EXPECT_TRUE(conf == conf);
EXPECT_FALSE(PrismaticJointConf() == conf);
}
{
auto conf = PrismaticJointConf{};
conf.localAnchorB = Length2{1.2_m, -3_m};
EXPECT_TRUE(conf == conf);
EXPECT_FALSE(PrismaticJointConf() == conf);
}
{
auto conf = PrismaticJointConf{};
conf.referenceAngle = 33_deg;
EXPECT_TRUE(conf == conf);
EXPECT_FALSE(PrismaticJointConf() == conf);
}
// TODO: test remaining fields.
}
TEST(PrismaticJointConf, NotEqualsOperator)
{
EXPECT_FALSE(PrismaticJointConf() != PrismaticJointConf());
{
auto conf = PrismaticJointConf{};
conf.enableLimit = !PrismaticJointConf{}.enableLimit;
EXPECT_FALSE(conf != conf);
EXPECT_TRUE(PrismaticJointConf() != conf);
}
// TODO: test remaining fields.
}
TEST(PrismaticJointConf, GetName)
{
EXPECT_STREQ(GetName(GetTypeID<PrismaticJointConf>()), "d2::PrismaticJointConf");
}
TEST(PrismaticJointConf, GetPrismaticJointConf)
{
auto conf = PrismaticJointConf{};
conf.bodyA = BodyID{21u};
conf.bodyB = BodyID{39u};
conf.localAnchorA = Length2(4_m, 5_m);
conf.localAnchorB = Length2(6_m, 7_m);
conf.enableLimit = true;
conf.lowerTranslation = 3_m;
conf.upperTranslation = 44_m;
auto result = PrismaticJointConf{};
EXPECT_NO_THROW(result = GetPrismaticJointConf(Joint{conf}));
EXPECT_EQ(conf.bodyA, result.bodyA);
EXPECT_EQ(conf.bodyB, result.bodyB);
EXPECT_EQ(conf.collideConnected, result.collideConnected);
EXPECT_EQ(conf.enableLimit, result.enableLimit);
}
TEST(PrismaticJointConf, InitVelocity)
{
auto conf = PrismaticJointConf{};
std::vector<BodyConstraint> bodies;
EXPECT_NO_THROW(InitVelocity(conf, bodies, StepConf{}, ConstraintSolverConf{}));
conf.bodyA = BodyID(0);
conf.bodyB = BodyID(0);
EXPECT_THROW(InitVelocity(conf, bodies, StepConf{}, ConstraintSolverConf{}), std::out_of_range);
const auto posA = Position{Length2{-5_m, 0_m}, 0_deg};
bodies.push_back(BodyConstraint{Real(1) / 4_kg, InvRotInertia{}, Length2{}, posA, Velocity{}});
EXPECT_NO_THROW(InitVelocity(conf, bodies, StepConf{}, ConstraintSolverConf{}));
}
TEST(PrismaticJointConf, SolveVelocity)
{
auto conf = PrismaticJointConf{};
std::vector<BodyConstraint> bodies;
auto result = false;
EXPECT_NO_THROW(result = SolveVelocity(conf, bodies, StepConf{}));
EXPECT_TRUE(result);
conf.bodyA = BodyID(0);
conf.bodyB = BodyID(0);
EXPECT_THROW(SolveVelocity(conf, bodies, StepConf{}), std::out_of_range);
const auto posA = Position{Length2{-5_m, 0_m}, 0_deg};
bodies.push_back(BodyConstraint{Real(1) / 4_kg, InvRotInertia{}, Length2{}, posA, Velocity{}});
EXPECT_NO_THROW(result = SolveVelocity(conf, bodies, StepConf{}));
}
TEST(PrismaticJointConf, SolvePosition)
{
auto conf = PrismaticJointConf{};
std::vector<BodyConstraint> bodies;
auto result = false;
EXPECT_NO_THROW(result = SolvePosition(conf, bodies, ConstraintSolverConf{}));
EXPECT_TRUE(result);
conf.bodyA = BodyID(0);
conf.bodyB = BodyID(0);
EXPECT_THROW(SolvePosition(conf, bodies, ConstraintSolverConf{}), std::out_of_range);
const auto posA = Position{Length2{-5_m, 0_m}, 0_deg};
bodies.push_back(BodyConstraint{Real(1) / 4_kg, InvRotInertia{}, Length2{}, posA, Velocity{}});
EXPECT_NO_THROW(result = SolvePosition(conf, bodies, ConstraintSolverConf{}));
}
Definition of the BodyConstraint class and closely related code.
Definition of the ConstraintSolverConf class and closely related code.
Definition of the DiskShapeConf class and closely related code.
Definition of the Joint class and closely related code.
Definition of the PrismaticJointConf class and closely related code.
Declarations of free functions of World for bodies identified by BodyID.
Declarations of free functions of World for joints identified by JointID.
Declarations of free functions of World for unidentified information.
Declarations of free functions of World for shapes identified by ShapeID.
Definitions of the World class and closely related code.
static constexpr UnitVec GetRight() noexcept
Gets the right-ward oriented unit vector.
Definition: UnitVec.hpp:122
detail::angular_momentum AngularMomentum
Angular momentum quantity.
Definition: Units.hpp:390
detail::length Length
Length quantity.
Definition: Units.hpp:244
detail::inverse_moment_of_inertia InvRotInertia
Inverse rotational inertia quantity.
Definition: Units.hpp:368
detail::momentum Momentum
Momentum quantity.
Definition: Units.hpp:379
detail::velocity LinearVelocity
Linear velocity quantity.
Definition: Units.hpp:253
constexpr auto RadianPerSecond
Radian per second unit of angular velocity.
Definition: Units.hpp:468
constexpr auto Meter
Meter unit of Length.
Definition: Units.hpp:423
constexpr auto Newton
Newton unit of force.
Definition: Units.hpp:487
Definition: AABB.hpp:48
constexpr auto GetMaxTorque(const FrictionJointConf &object) noexcept
Free function for getting the max torque value of the given configuration.
Definition: FrictionJointConf.hpp:227
bool SolveVelocity(DistanceJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
Solves velocity constraint.
Definition: DistanceJointConf.cpp:169
bool IsMotorEnabled(const Joint &object)
Gets the specified joint's motor property value if it supports one.
Definition: Joint.cpp:563
void SetLinearLimits(Joint &object, Length lower, Length upper)
Definition: Joint.cpp:499
Angle GetAngularOffset(const Joint &object)
Gets the angular offset property of the specified joint if its type has one.
Definition: Joint.cpp:615
constexpr auto GetY(const UnitVec &value) -> decltype(get< 1 >(value))
Gets the "Y" element of the given value - i.e. the second element.
Definition: UnitVec.hpp:499
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:175
Length2 GetLocalAnchorB(const GearJointConf &conf)
Gets the local anchor B property of the given joint.
Definition: GearJointConf.cpp:510
Length2 GetGroundAnchorB(const Joint &object)
Definition: Joint.cpp:658
constexpr UnitVec GetRevPerpendicular(const UnitVec &vector) noexcept
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to the given vector.
Definition: UnitVec.hpp:437
Angle GetAngle(const Body &body) noexcept
Gets the body's angle.
Definition: Body.cpp:280
Frequency GetFrequency(const Joint &object)
Gets the frequency of the joint if it has this property.
Definition: Joint.cpp:410
BodyID CreateBody(AabbTreeWorld &world, Body body=Body{})
Creates a rigid body that's a copy of the given one.
Definition: AabbTreeWorld.cpp:1019
BodyID GetBodyB(const Joint &object) noexcept
Gets the second body attached to this joint.
Definition: Joint.hpp:295
LinearVelocity2 GetLinearVelocity(const Body &body) noexcept
Gets the linear velocity of the center of mass.
Definition: Body.hpp:1312
Angle GetReferenceAngle(const Joint &object)
Gets the reference angle of the joint if it has one.
Definition: Joint.cpp:218
Momentum GetLinearMotorImpulse(const Joint &object)
Definition: Joint.cpp:667
Force GetMotorForce(const World &world, JointID id, Frequency inv_dt)
Gets the current motor force for the given joint, given the inverse time step.
Definition: WorldJoint.hpp:230
Angle GetAngularLowerLimit(const Joint &object)
Definition: Joint.cpp:509
Length2 GetTarget(const Joint &object)
Gets the given joint's target property if it has one.
Definition: Joint.cpp:462
void ShiftOrigin(AabbTreeWorld &world, const Length2 &newOrigin)
Shifts the world origin.
Definition: AabbTreeWorld.cpp:2221
bool SolvePosition(const DistanceJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
Solves the position constraint.
Definition: DistanceJointConf.cpp:203
ShapeID CreateShape(AabbTreeWorld &world, Shape def)
Creates an identifiable copy of the given shape within this world.
Definition: AabbTreeWorld.cpp:1234
PrismaticJointConf GetPrismaticJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: PrismaticJointConf.cpp:127
Real GetDampingRatio(const Joint &object)
Gets the given joint's damping ratio property if it has one.
Definition: Joint.cpp:392
void SetLinearOffset(Joint &object, const Length2 &value)
Sets the linear offset property of the specified joint if its type has one.
Definition: Joint.cpp:605
const Joint & GetJoint(const AabbTreeWorld &world, JointID id)
Gets the identified joint.
Definition: AabbTreeWorld.cpp:2855
Length GetLinearLowerLimit(const Joint &object)
Definition: Joint.cpp:481
Angle GetAngularUpperLimit(const Joint &object)
Gets the upper joint limit.
Definition: Joint.cpp:518
BodyID GetBodyA(const Joint &object) noexcept
Gets the first body attached to this joint.
Definition: Joint.hpp:290
void Attach(AabbTreeWorld &world, BodyID id, ShapeID shapeID)
Associates a validly identified shape with the validly identified body.
Definition: AabbTreeWorld.cpp:2896
void SetTarget(Joint &object, const Length2 &value)
Sets the given joint's target property if it has one.
Definition: Joint.cpp:471
Length2 GetLocation(const Body &body) noexcept
Gets the body's origin location.
Definition: Body.hpp:930
Length2 GetGroundAnchorA(const Joint &object)
Definition: Joint.cpp:649
void SetMaxMotorForce(Joint &object, Force value)
Sets the given joint's max motor force if its type supports that.
Definition: Joint.cpp:344
void SetMotorSpeed(Joint &object, AngularVelocity value)
Sets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:272
Length GetJointTranslation(const World &world, JointID id)
Gets the current joint translation.
Definition: WorldJoint.cpp:192
UnitVec GetLocalYAxisA(const Joint &object)
Gets the given joint's local Y axis A if its type supports that.
Definition: Joint.cpp:245
constexpr auto GetLength(const DistanceJointConf &object) noexcept
Free function for getting the length value of the given configuration.
Definition: DistanceJointConf.hpp:250
UnitVec GetLocalXAxisA(const Joint &object)
Gets the given joint's local X axis A if its type supports that.
Definition: Joint.cpp:233
Length2 GetLinearOffset(const Joint &object)
Gets the linear offset property of the specified joint if its type has one.
Definition: Joint.cpp:596
LimitState GetLimitState(const Joint &object)
Definition: Joint.cpp:634
constexpr auto GetMaxForce(const FrictionJointConf &object) noexcept
Free function for getting the max force value of the given configuration.
Definition: FrictionJointConf.hpp:213
Torque GetMaxMotorTorque(const Joint &object)
Gets the given joint's max motor torque if its type supports that.
Definition: Joint.cpp:354
Length2 GetAnchorB(const World &world, JointID id)
Definition: WorldJoint.cpp:179
void SetAngularOffset(Joint &object, Angle value)
Sets the angular offset property of the specified joint if its type has one.
Definition: Joint.cpp:624
bool IsLimitEnabled(const Joint &object)
Gets the specified joint's limit property if it supports one.
Definition: Joint.cpp:537
RotInertia GetAngularMass(const Joint &object)
Gets the given joint's angular mass.
Definition: Joint.cpp:290
JointID CreateJoint(AabbTreeWorld &world, Joint def)
Creates a joint to constrain one or more bodies.
Definition: AabbTreeWorld.cpp:1132
Length2 GetAnchorA(const World &world, JointID id)
Definition: WorldJoint.cpp:171
Length2 GetLocalAnchorA(const GearJointConf &conf)
Gets the local anchor A property of the given joint.
Definition: GearJointConf.cpp:502
constexpr auto GetRatio(const GearJointConf &object) noexcept
Free function for getting the ratio value of the given configuration.
Definition: GearJointConf.hpp:263
constexpr auto GetX(const UnitVec &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: UnitVec.hpp:493
void EnableMotor(Joint &object, bool value)
Enables the specified joint's motor property if it supports one.
Definition: Joint.cpp:578
constexpr void SetFrequency(DistanceJointConf &object, NonNegative< Frequency > value) noexcept
Free function for setting the frequency value of the given configuration.
Definition: DistanceJointConf.hpp:236
Force GetMaxMotorForce(const Joint &object)
Gets the given joint's max motor force if its type supports that.
Definition: Joint.cpp:335
void SetJoint(AabbTreeWorld &world, JointID id, Joint def)
Sets the identified joint.
Definition: AabbTreeWorld.cpp:1108
Length GetLinearUpperLimit(const Joint &object)
Definition: Joint.cpp:490
void EnableLimit(Joint &object, bool value)
Enables the specified joint's limit property if it supports one.
Definition: Joint.cpp:549
StepStats Step(AabbTreeWorld &world, const StepConf &conf)
Steps the world simulation according to the given configuration.
Definition: AabbTreeWorld.cpp:2144
constexpr AngularMomentum GetAngularReaction(const DistanceJointConf &) noexcept
Gets the current angular reaction for the given configuration.
Definition: DistanceJointConf.hpp:182
AngularMomentum GetAngularMotorImpulse(const Joint &object)
Gets the angular motor impulse of the joint if it has this property.
Definition: Joint.cpp:450
AngularVelocity GetMotorSpeed(const Joint &object)
Gets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:257
void InitVelocity(DistanceJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
Initializes velocity constraint data based on the given solver data.
Definition: DistanceJointConf.cpp:81
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:633
Definition: ArrayList.hpp:43
Vector2< Momentum > Momentum2
2-element vector of Momentum quantities.
Definition: Vector2.hpp:76
float Real
Real-number type.
Definition: Real.hpp:69
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:50
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:51
@ e_inactiveLimit
Inactive limit.
@ e_equalLimits
Equal limit.
@ e_atUpperLimit
At-upper limit.
@ e_atLowerLimit
At-lower limit.
detail::IndexingNamedType< BodyCounter, struct BodyIdentifier > BodyID
Body identifier.
Definition: BodyID.hpp:44
constexpr auto & UseEnableLimit(bool v) noexcept
Uses the given enable limit state value.
Definition: PrismaticJointConf.hpp:83