PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
PrismaticJoint.cpp

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

/*
* Copyright (c) 2020 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/Dynamics/Joints/PrismaticJointConf.hpp>
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Dynamics/World.hpp>
#include <PlayRho/Dynamics/WorldJoint.hpp>
#include <PlayRho/Dynamics/WorldBody.hpp>
#include <PlayRho/Dynamics/WorldFixture.hpp>
#include <PlayRho/Dynamics/WorldMisc.hpp> // for Step
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
using namespace playrho;
using namespace playrho::d2;
TEST(PrismaticJointConf, ByteSize)
{
// Check size at test runtime instead of compile-time via static_assert to avoid stopping
// builds and to report actual size rather than just reporting that expected size is wrong.
switch (sizeof(Real)) {
case 4:
EXPECT_EQ(sizeof(PrismaticJointConf), std::size_t(160));
break;
case 8:
EXPECT_EQ(sizeof(PrismaticJointConf), std::size_t(312));
break;
case 16:
EXPECT_EQ(sizeof(PrismaticJointConf), std::size_t(624));
break;
default:
FAIL();
break;
}
}
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_EQ(GetLimitState(joint), LimitState::e_inactiveLimit);
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);
}
{
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);
}
{
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));
}
{
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));
}
{
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);
}
{
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);
}
{
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));
}
{
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)
{
const auto circle = DiskShapeConf{}.UseRadius(0.2_m);
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{}.UseType(BodyType::Dynamic).UseLocation(p1));
const auto b2 = CreateBody(world, BodyConf{}.UseType(BodyType::Dynamic).UseLocation(p2));
CreateFixture(world, b1, Shape{circle});
CreateFixture(world, b2, Shape{circle});
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(GetLimitState(conf), LimitState::e_inactiveLimit);
ASSERT_EQ(GetLinearLowerLimit(conf), 0_m);
ASSERT_EQ(GetLinearUpperLimit(conf), 0_m);
}
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_EQ(GetLimitState(conf), LimitState::e_atLowerLimit);
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_EQ(GetLimitState(conf), LimitState::e_atUpperLimit);
}
EXPECT_NO_THROW(EnableMotor(world, joint, true));
EXPECT_NO_THROW(Step(world, 1_s));
EXPECT_EQ(GetLinearMotorImpulse(world, joint), Momentum(0));
}
TEST(PrismaticJointConf, EqualsOperator)
{
{
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{};
EXPECT_FALSE(conf != conf);
EXPECT_TRUE(PrismaticJointConf() != conf);
}
// TODO: test remaining fields.
}
{
EXPECT_STREQ(GetName(GetTypeID<PrismaticJointConf>()), "d2::PrismaticJointConf");
}
{
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);
}
playrho::d2::GetMaxForce
constexpr auto GetMaxForce(const FrictionJointConf &object) noexcept
Free function for getting the max force value of the given configuration.
Definition: FrictionJointConf.hpp:177
playrho::BodyType::Static
@ Static
Static body type.
playrho::d2::CreateBody
BodyID CreateBody(World &world, const BodyConf &def)
Creates a rigid body with the given configuration.
Definition: WorldBody.cpp:58
playrho::d2::BodyConf::UseType
constexpr BodyConf & UseType(BodyType t) noexcept
Use the given type.
Definition: BodyConf.hpp:166
playrho::Length
PLAYRHO_QUANTITY(boost::units::si::length) Length
Length quantity.
Definition: Units.hpp:158
playrho::d2
Name space for 2-dimensionally related PlayRho names.
Definition: AABB.cpp:34
playrho::d2::JointConf::bodyA
BodyID bodyA
1st attached body.
Definition: JointConf.hpp:36
playrho::d2::GetLocalYAxisA
UnitVec GetLocalYAxisA(const Joint &object)
Gets the given joint's local Y axis A if its type supports that.
Definition: Joint.cpp:242
playrho::d2::UnitVec::GetRight
static constexpr UnitVec GetRight() noexcept
Gets the right-ward oriented unit vector.
Definition: UnitVec.hpp:74
playrho::d2::IsLimitEnabled
bool IsLimitEnabled(const Joint &object)
Gets the specified joint's limit property if it supports one.
Definition: Joint.cpp:534
playrho::InvalidJointID
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:33
playrho::d2::SetFrequency
constexpr void SetFrequency(DistanceJointConf &object, NonNegative< Frequency > value) noexcept
Free function for setting the frequency value of the given configuration.
Definition: DistanceJointConf.hpp:205
playrho::d2::GetAngularUpperLimit
Angle GetAngularUpperLimit(const Joint &object)
Gets the upper joint limit.
Definition: Joint.cpp:515
playrho::d2::GetAngularMotorImpulse
AngularMomentum GetAngularMotorImpulse(const Joint &object)
Gets the angular motor impulse of the joint if it has this property.
Definition: Joint.cpp:447
playrho::d2::GetName
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:788
playrho::Newton
constexpr auto Newton
Newton unit of force.
Definition: Units.hpp:403
playrho::d2::SetAngularOffset
void SetAngularOffset(Joint &object, Angle value)
Sets the angular offset property of the specified joint if its type has one.
Definition: Joint.cpp:621
playrho::GetX
constexpr auto & GetX(T &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: Math.hpp:66
playrho
Name space for all PlayRho related names.
Definition: AABB.cpp:33
playrho::d2::GetJoint
const Joint & GetJoint(const WorldImpl &world, JointID id)
Gets the identified joint's value.
Definition: WorldImplJoint.cpp:57
playrho::d2::GetLocalAnchorA
Length2 GetLocalAnchorA(const Joint &object)
Get the anchor point on body-A in local coordinates.
Definition: Joint.cpp:62
playrho::d2::SetLinearOffset
void SetLinearOffset(Joint &object, Length2 value)
Sets the linear offset property of the specified joint if its type has one.
Definition: Joint.cpp:602
playrho::d2::GetJointTranslation
Length GetJointTranslation(const World &world, JointID id)
Gets the current joint translation.
Definition: WorldJoint.cpp:229
playrho::RadianPerSecond
constexpr auto RadianPerSecond
Radian per second unit of angular velocity.
Definition: Units.hpp:384
playrho::d2::World
Definition of an independent and simulatable "world".
Definition: World.hpp:129
playrho::d2::GetAnchorB
Length2 GetAnchorB(const World &world, JointID id)
Get the anchor point on body-B in world coordinates.
Definition: WorldJoint.cpp:216
playrho::d2::PrismaticJointConf::UseEnableLimit
constexpr auto & UseEnableLimit(bool v) noexcept
Uses the given enable limit state value.
Definition: PrismaticJointConf.hpp:74
playrho::d2::EnableMotor
void EnableMotor(Joint &object, bool value)
Enables the specified joint's motor property if it supports one.
Definition: Joint.cpp:575
playrho::d2::ShiftOrigin
constexpr bool ShiftOrigin(DistanceJointConf &, Length2) noexcept
Shifts the origin notion of the given configuration.
Definition: DistanceJointConf.hpp:177
playrho::d2::GetMotorForce
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:272
playrho::d2::PrismaticJointConf::enableLimit
bool enableLimit
Enable/disable the joint limit.
Definition: PrismaticJointConf.hpp:135
playrho::d2::GetBodyB
BodyID GetBodyB(const Contact &contact) noexcept
Gets the body B ID of the given contact.
Definition: Contact.hpp:588
playrho::d2::SetMaxMotorForce
void SetMaxMotorForce(Joint &object, Force value)
Sets the given joint's max motor force if its type supports that.
Definition: Joint.cpp:341
playrho::d2::GetBodyA
BodyID GetBodyA(const Contact &contact) noexcept
Gets the body A ID of the given contact.
Definition: Contact.hpp:581
playrho::d2::GetReferenceAngle
Angle GetReferenceAngle(const Joint &object)
Gets the reference angle of the joint if it has one.
Definition: Joint.cpp:215
playrho::d2::BodyConf::UseLocation
constexpr BodyConf & UseLocation(Length2 l) noexcept
Use the given location.
Definition: BodyConf.hpp:172
playrho::d2::GetLimitState
LimitState GetLimitState(const Joint &object)
Definition: Joint.cpp:631
playrho::d2::IsMotorEnabled
bool IsMotorEnabled(const Joint &object)
Gets the specified joint's motor property value if it supports one.
Definition: Joint.cpp:560
playrho::Meter
constexpr auto Meter
Meter unit of Length.
Definition: Units.hpp:337
playrho::d2::GetLinearUpperLimit
Length GetLinearUpperLimit(const Joint &object)
Gets the upper linear joint limit.
Definition: Joint.cpp:487
playrho::d2::GetLocalXAxisA
UnitVec GetLocalXAxisA(const Joint &object)
Gets the given joint's local X axis A if its type supports that.
Definition: Joint.cpp:230
playrho::d2::SetLinearLimits
void SetLinearLimits(Joint &object, Length lower, Length upper)
Sets the joint limits.
Definition: Joint.cpp:496
playrho::d2::GetMaxMotorTorque
Torque GetMaxMotorTorque(const Joint &object)
Gets the given joint's max motor torque if its type supports that.
Definition: Joint.cpp:351
playrho::d2::CreateJoint
JointID CreateJoint(WorldImpl &world, const Joint &def)
Creates a new joint.
Definition: WorldImplJoint.cpp:47
playrho::d2::GetLinearMotorImpulse
Momentum GetLinearMotorImpulse(const Joint &object)
Definition: Joint.cpp:664
playrho::d2::SetJoint
void SetJoint(WorldImpl &world, JointID id, const Joint &def)
Sets the identified joint's new value.
Definition: WorldImplJoint.cpp:62
playrho::d2::GetAngularLowerLimit
Angle GetAngularLowerLimit(const Joint &object)
Gets the lower joint limit.
Definition: Joint.cpp:506
playrho::d2::GetLocalAnchorB
Length2 GetLocalAnchorB(const Joint &object)
Get the anchor point on body-B in local coordinates.
Definition: Joint.cpp:96
playrho::d2::GetAngle
Angle GetAngle(const UnitVec value)
Gets the angle of the given unit vector.
Definition: Math.hpp:718
playrho::Momentum
PLAYRHO_QUANTITY(boost::units::si::momentum) Momentum
Momentum quantity.
Definition: Units.hpp:293
playrho::d2::GetTarget
Length2 GetTarget(const Joint &object)
Gets the given joint's target property if it has one.
Definition: Joint.cpp:459
playrho::d2::GetLinearOffset
Length2 GetLinearOffset(const Joint &object)
Gets the linear offset property of the specified joint if its type has one.
Definition: Joint.cpp:593
playrho::d2::GetRevPerpendicular
constexpr UnitVec GetRevPerpendicular(const UnitVec vector) noexcept
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to the given vector.
Definition: UnitVec.hpp:330
playrho::AngularMomentum
PLAYRHO_QUANTITY(boost::units::si::angular_momentum) AngularMomentum
Angular momentum quantity.
Definition: Units.hpp:304
playrho::d2::GetMotorSpeed
AngularVelocity GetMotorSpeed(const Joint &object)
Gets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:254
playrho::d2::GetAngularOffset
Angle GetAngularOffset(const Joint &object)
Gets the angular offset property of the specified joint if its type has one.
Definition: Joint.cpp:612
playrho::d2::GetRatio
constexpr auto GetRatio(const GearJointConf &object) noexcept
Free function for getting the ratio value of the given configuration.
Definition: GearJointConf.hpp:205
playrho::d2::GetFrequency
Frequency GetFrequency(const Joint &object)
Gets the frequency of the joint if it has this property.
Definition: Joint.cpp:407
playrho::d2::GetAngularMass
RotInertia GetAngularMass(const Joint &object)
Gets the given joint's angular mass.
Definition: Joint.cpp:287
playrho::d2::GetGroundAnchorB
Length2 GetGroundAnchorB(const Joint &object)
Definition: Joint.cpp:655
playrho::d2::GetAngularReaction
constexpr AngularMomentum GetAngularReaction(const DistanceJointConf &) noexcept
Gets the current angular reaction for the given configuration.
Definition: DistanceJointConf.hpp:170
playrho::d2::CreateFixture
FixtureID CreateFixture(World &world, FixtureConf def, bool resetMassData)
Creates a fixture within the specified world.
Definition: WorldFixture.cpp:48
playrho::Real
float Real
Real-number type.
Definition: Real.hpp:69
playrho::d2::DiskShapeConf::UseRadius
constexpr DiskShapeConf & UseRadius(NonNegative< Length > r) noexcept
Uses the given value as the radius.
Definition: DiskShapeConf.hpp:65
playrho::d2::GetMaxMotorForce
Force GetMaxMotorForce(const Joint &object)
Gets the given joint's max motor force if its type supports that.
Definition: Joint.cpp:332
playrho::d2::BodyConf
Configuration for a body.
Definition: BodyConf.hpp:50
playrho::d2::GetLocation
constexpr Length2 GetLocation(const Transformation &value) noexcept
Gets the location information from the given transformation.
Definition: Transformation.hpp:69
playrho::d2::SetTarget
void SetTarget(Joint &object, Length2 value)
Sets the given joint's target property if it has one.
Definition: Joint.cpp:468
playrho::d2::GetLength
constexpr auto GetLength(const DistanceJointConf &object) noexcept
Free function for getting the length value of the given configuration.
Definition: DistanceJointConf.hpp:219
playrho::d2::PrismaticJointConf
Prismatic joint definition.
Definition: PrismaticJointConf.hpp:57
playrho::d2::GetDampingRatio
Real GetDampingRatio(const Joint &object)
Gets the given joint's damping ratio property if it has one.
Definition: Joint.cpp:389
playrho::d2::SetMotorSpeed
void SetMotorSpeed(Joint &object, AngularVelocity value)
Sets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:269
playrho::d2::GetMaxTorque
constexpr auto GetMaxTorque(const FrictionJointConf &object) noexcept
Free function for getting the max torque value of the given configuration.
Definition: FrictionJointConf.hpp:191
playrho::Vector
Vector.
Definition: Vector.hpp:49
playrho::d2::GetAnchorA
Length2 GetAnchorA(const World &world, JointID id)
Get the anchor point on body-A in world coordinates.
Definition: WorldJoint.cpp:208
playrho::d2::GetLinearReaction
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:163
playrho::detail::IndexingNamedType< BodyCounter, struct BodyIdentifier >
playrho::d2::Joint
A joint-like constraint on one or more bodies.
Definition: Joint.hpp:144
playrho::d2::Shape
Shape.
Definition: Shape.hpp:183
playrho::d2::GetLinearVelocity
LinearVelocity2 GetLinearVelocity(const Body &body) noexcept
Gets the linear velocity of the center of mass.
Definition: Body.hpp:1168
playrho::GetY
constexpr auto & GetY(T &value)
Gets the "Y" element of the given value - i.e. the second element.
Definition: Math.hpp:73
playrho::Length2
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:43
playrho::d2::GetGroundAnchorA
Length2 GetGroundAnchorA(const Joint &object)
Definition: Joint.cpp:646
playrho::d2::PrismaticJointConf::localAnchorB
Length2 localAnchorB
The local anchor point relative to body B's origin.
Definition: PrismaticJointConf.hpp:119
playrho::d2::Step
StepStats Step(WorldImpl &world, const StepConf &conf)
Steps the given world the specified amount.
Definition: WorldImplMisc.cpp:85
playrho::d2::GetLinearLowerLimit
Length GetLinearLowerLimit(const Joint &object)
Gets the lower linear joint limit.
Definition: Joint.cpp:478
playrho::d2::EnableLimit
void EnableLimit(Joint &object, bool value)
Enables the specified joint's limit property if it supports one.
Definition: Joint.cpp:546
playrho::d2::GetPrismaticJointConf
PrismaticJointConf GetPrismaticJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: PrismaticJointConf.cpp:126
playrho::LinearVelocity
PLAYRHO_QUANTITY(boost::units::si::velocity) LinearVelocity
Linear velocity quantity.
Definition: Units.hpp:167
playrho::d2::PrismaticJointConf::localAnchorA
Length2 localAnchorA
The local anchor point relative to body A's origin.
Definition: PrismaticJointConf.hpp:116
playrho::d2::LimitState::e_inactiveLimit
@ e_inactiveLimit
Inactive limit.
playrho::d2::PrismaticJointConf::referenceAngle
Angle referenceAngle
The constrained angle between the bodies: body B's angle minus body A's angle.
Definition: PrismaticJointConf.hpp:128
playrho::d2::DiskShapeConf
Disk shape configuration.
Definition: DiskShapeConf.hpp:42