PlayRho
1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
|
|
This is the googletest
based unit testing file for the interfaces to playrho::d2::GearJointConf
.
#include "UnitTests.hpp"
#include <PlayRho/Dynamics/Joints/GearJointConf.hpp>
#include <PlayRho/Dynamics/Joints/DistanceJointConf.hpp>
#include <PlayRho/Dynamics/Joints/RevoluteJointConf.hpp>
#include <PlayRho/Dynamics/Joints/PrismaticJointConf.hpp>
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Dynamics/BodyConf.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>
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
#include <type_traits>
{
case 4:
#if defined(_WIN32)
#if defined(_WIN64)
#else
#endif
#else
#endif
break;
case 8:
break;
case 16:
break;
default:
FAIL();
break;
}
}
#if 0
{
}
TEST(GearJoint, IsOkay)
{
}
#endif
TEST(GearJoint, Creation)
{
ASSERT_EQ(def.type1, GetTypeID<RevoluteJointConf>());
ASSERT_EQ(def.type2, GetTypeID<RevoluteJointConf>());
EXPECT_EQ(
GetType(world, joint), GetTypeID<GearJointConf>());
EXPECT_EQ(
GetBodyA(world, joint), def.bodyA);
EXPECT_EQ(
GetBodyB(world, joint), def.bodyB);
EXPECT_EQ(
GetRatio(world, joint), def.ratio);
}
{
const auto newOrigin =
Length2{1_m, 1_m};
}
{
auto conf = TypeCast<GearJointConf>(
GetJoint(world, joint));
EXPECT_NO_THROW(
SetJoint(world, joint, conf));
}
{
ASSERT_EQ(
GetType(world, joint), GetTypeID<GearJointConf>());
ASSERT_EQ(
GetBodyA(world, joint), def.bodyA);
ASSERT_EQ(
GetBodyB(world, joint), def.bodyB);
auto conf = TypeCast<GearJointConf>(
GetJoint(world, joint));
ASSERT_EQ(
GetRatio(world, joint), def.ratio);
EXPECT_EQ(cdef.bodyA, def.bodyA);
EXPECT_EQ(cdef.bodyB, def.bodyB);
EXPECT_EQ(cdef.collideConnected, false);
EXPECT_EQ(cdef.type1,
GetTypeID<decltype(rdef1)>());
EXPECT_EQ(cdef.type2,
GetTypeID<decltype(rdef2)>());
EXPECT_EQ(cdef.ratio,
Real(1));
}
TEST(GearJoint, WithDynamicCirclesAndRevoluteJoints)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto p3 =
Length2{+2_m, 0_m};
const auto p4 =
Length2{+3_m, 0_m};
const auto def =
}
TEST(GearJoint, WithDynamicCirclesAndPrismaticJoints)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto p3 =
Length2{+2_m, 0_m};
const auto p4 =
Length2{+3_m, 0_m};
world,
}
TEST(GearJoint, GetAnchorAandB)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto p3 =
Length2{+2_m, 0_m};
const auto p4 =
Length2{+3_m, 0_m};
const auto def =
const auto anchorA =
const auto anchorB =
}
{
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
}
{
{
EXPECT_FALSE(conf != conf);
}
}
{
EXPECT_STREQ(
GetName(GetTypeID<GearJointConf>()),
"d2::GearJointConf");
}
@ Static
Static body type.
Length2 localAnchorA
Local anchor A.
Definition: GearJointConf.hpp:85
BodyID CreateBody(World &world, const BodyConf &def)
Creates a rigid body with the given configuration.
Definition: WorldBody.cpp:58
constexpr BodyConf & UseType(BodyType t) noexcept
Use the given type.
Definition: BodyConf.hpp:166
static constexpr UnitVec GetTop() noexcept
Gets the top-ward oriented unit vector.
Definition: UnitVec.hpp:80
Name space for 2-dimensionally related PlayRho names.
Definition: AABB.cpp:34
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:33
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:788
constexpr auto & GetX(T &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: Math.hpp:66
Name space for all PlayRho related names.
Definition: AABB.cpp:33
const Joint & GetJoint(const WorldImpl &world, JointID id)
Gets the identified joint's value.
Definition: WorldImplJoint.cpp:57
Length2 GetLocalAnchorA(const Joint &object)
Get the anchor point on body-A in local coordinates.
Definition: Joint.cpp:62
Definition of an independent and simulatable "world".
Definition: World.hpp:129
Length2 GetAnchorB(const World &world, JointID id)
Get the anchor point on body-B in world coordinates.
Definition: WorldJoint.cpp:216
constexpr bool ShiftOrigin(DistanceJointConf &, Length2) noexcept
Shifts the origin notion of the given configuration.
Definition: DistanceJointConf.hpp:177
Gear joint definition.
Definition: GearJointConf.hpp:55
constexpr auto GetType1(const GearJointConf &object) noexcept
Free function for getting joint 1 type value of the given configuration.
Definition: GearJointConf.hpp:226
Angle referenceAngle2
Reference angle of joint 2. Used when type2 is Revolute.
Definition: GearJointConf.hpp:94
BodyID GetBodyB(const Contact &contact) noexcept
Gets the body B ID of the given contact.
Definition: Contact.hpp:588
bool GetCollideConnected(const Joint &object) noexcept
Gets collide connected.
Definition: Joint.hpp:293
Length2 localAnchorB
Local anchor B.
Definition: GearJointConf.hpp:86
BodyID GetBodyA(const Contact &contact) noexcept
Gets the body A ID of the given contact.
Definition: Contact.hpp:581
constexpr auto Meter
Meter unit of Length.
Definition: Units.hpp:337
Angle referenceAngle1
Reference angle of joint 1. Used when type1 is Revolute.
Definition: GearJointConf.hpp:93
JointID CreateJoint(WorldImpl &world, const Joint &def)
Creates a new joint.
Definition: WorldImplJoint.cpp:47
void SetJoint(WorldImpl &world, JointID id, const Joint &def)
Sets the identified joint's new value.
Definition: WorldImplJoint.cpp:62
Length2 GetLocalAnchorB(const Joint &object)
Get the anchor point on body-B in local coordinates.
Definition: Joint.cpp:96
Angle GetAngle(const UnitVec value)
Gets the angle of the given unit vector.
Definition: Math.hpp:718
Length2 GetWorldPoint(const Body &body, const Length2 localPoint) noexcept
Gets the world coordinates of a point given in coordinates relative to the body's origin.
Definition: Body.hpp:1208
constexpr auto GetType2(const GearJointConf &object) noexcept
Free function for getting joint 2 type value of the given configuration.
Definition: GearJointConf.hpp:233
PLAYRHO_QUANTITY(boost::units::si::angular_momentum) AngularMomentum
Angular momentum quantity.
Definition: Units.hpp:304
constexpr auto GetRatio(const GearJointConf &object) noexcept
Free function for getting the ratio value of the given configuration.
Definition: GearJointConf.hpp:205
constexpr TypeID GetTypeID()
Gets the type ID for the template parameter type.
Definition: TypeInfo.hpp:113
Invalid argument logic error.
Definition: InvalidArgument.hpp:33
constexpr AngularMomentum GetAngularReaction(const DistanceJointConf &) noexcept
Gets the current angular reaction for the given configuration.
Definition: DistanceJointConf.hpp:170
FixtureID CreateFixture(World &world, FixtureConf def, bool resetMassData)
Creates a fixture within the specified world.
Definition: WorldFixture.cpp:48
float Real
Real-number type.
Definition: Real.hpp:69
constexpr DiskShapeConf & UseRadius(NonNegative< Length > r) noexcept
Uses the given value as the radius.
Definition: DiskShapeConf.hpp:65
Configuration for a body.
Definition: BodyConf.hpp:50
constexpr Length2 GetLocation(const Transformation &value) noexcept
Gets the location information from the given transformation.
Definition: Transformation.hpp:69
Real mass
Either linear mass or angular mass.
Definition: GearJointConf.hpp:113
Distance joint definition.
Definition: DistanceJointConf.hpp:52
Vector.
Definition: Vector.hpp:49
Length2 GetAnchorA(const World &world, JointID id)
Get the anchor point on body-A in world coordinates.
Definition: WorldJoint.cpp:208
TypeID GetType(const Shape &shape) noexcept
Gets the type info of the use of the given shape.
Definition: Shape.hpp:329
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:163
constexpr auto SetRatio(GearJointConf &object, Real value) noexcept
Free function for setting the ratio value of the given configuration.
Definition: GearJointConf.hpp:212
RevoluteJointConf GetRevoluteJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: RevoluteJointConf.cpp:102
Shape.
Definition: Shape.hpp:183
constexpr auto & GetY(T &value)
Gets the "Y" element of the given value - i.e. the second element.
Definition: Math.hpp:73
std::enable_if_t< std::is_pointer< T >::value, CheckedValue< T, NonZeroChecker< T > >> NonNull
Non-null constrained value type.
Definition: NonZero.hpp:55
StepStats Step(WorldImpl &world, const StepConf &conf)
Steps the given world the specified amount.
Definition: WorldImplMisc.cpp:85
GearJointConf GetGearJointConf(const Joint &joint) noexcept
Gets the definition data for the given joint.
Definition: GearJointConf.cpp:74
PrismaticJointConf GetPrismaticJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: PrismaticJointConf.cpp:126
Disk shape configuration.
Definition: DiskShapeConf.hpp:42