#include <iostream>
#include <iomanip>
int main()
{
constexpr auto boxX = +0_m;
constexpr auto boxY = -10_m;
constexpr auto boxWidth = 50_m;
constexpr auto bodyHeight = 10_m;
constexpr auto maxSteps = 60;
constexpr auto textWidth = 5;
constexpr auto fixedPrecision = 2;
constexpr
auto ballStart =
Length2{0_m, 4_m};
auto world = World{};
const auto box =
CreateShape(world, PolygonShapeConf{}.SetAsBox(boxWidth, bodyHeight));
const auto diskShape =
CreateShape(world, DiskShapeConf{}.UseRadius(1_m));
.Use(diskShape)
.UseLocation(ballStart)
std::cout << std::fixed << std::setprecision(fixedPrecision);
for (auto i = 0; i < maxSteps; ++i) {
const auto angle =
GetAngle(transformation);
std::cout << std::setw(textWidth) <<
GetX(location);
std::cout << std::setw(textWidth) <<
GetY(location);
std::cout << std::setw(textWidth) << angle;
std::cout << '\n';
}
return 0;
}
Basic API include file to pull in at once most headers used.
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
Angle GetAngle(const Body &body) noexcept
Gets the body's angle.
Definition: Body.cpp:280
BodyID CreateBody(AabbTreeWorld &world, Body body=Body{})
Creates a rigid body that's a copy of the given one.
Definition: AabbTreeWorld.cpp:1019
ShapeID CreateShape(AabbTreeWorld &world, Shape def)
Creates an identifiable copy of the given shape within this world.
Definition: AabbTreeWorld.cpp:1234
const Transformation & GetTransformation(const Body &body) noexcept
Gets the body's transformation.
Definition: Body.hpp:1014
Length2 GetLocation(const Body &body) noexcept
Gets the body's origin location.
Definition: Body.hpp:930
constexpr auto EarthlyGravity
Earthly gravity in 2-dimensions.
Definition: Vector2.hpp:128
constexpr auto GetX(const UnitVec &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: UnitVec.hpp:493
StepStats Step(AabbTreeWorld &world, const StepConf &conf)
Steps the world simulation according to the given configuration.
Definition: AabbTreeWorld.cpp:2144
Definition: ArrayList.hpp:43
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:51