PlayRho  2.0.0
An interactive physics engine & library.
Additional Math Functions

Additional functions for common mathematical operations. More...

Functions

template<typename T >
constexpr auto playrho::AlmostEqual (T a, T b, int ulp=4) -> std::enable_if_t< IsArithmeticV< T >, bool >
 Determines whether the given two values are "almost equal". More...
 
template<typename T >
constexpr auto playrho::AlmostZero (const T &value) -> decltype(abs(value)< std::numeric_limits< T >::min())
 Gets whether a given value is almost zero. More...
 
template<typename T >
auto playrho::Atan2 (T y, T x)
 Computes the arc-tangent of the given y and x values. More...
 
template<typename T >
auto playrho::Average (const T &span)
 Computes the average of the given values.
 
template<typename T >
constexpr auto playrho::Bisect (const T &a1, const T &a2) -> decltype((a1+a2)/2)
 Bisection method. More...
 
template<class T >
constexpr auto playrho::cfloor (T v) noexcept
 Constant expression enhanced floor function. More...
 
Length2 playrho::ComputeCentroid (const Span< const Length2 > &vertices)
 Computes the centroid of a counter-clockwise array of 3 or more vertices. More...
 
template<class T1 , class T2 , std::enable_if_t< std::tuple_size_v< T1 >==2 &&std::tuple_size_v< T2 >==2, int > = 0>
constexpr auto playrho::Cross (const T1 &a, const T2 &b) noexcept
 Performs the 2-element analog of the cross product of two vectors. More...
 
template<class T >
constexpr auto playrho::ctrunc (T v) noexcept
 Constant expression enhanced truncate function. More...
 
template<typename T1 , typename T2 >
constexpr auto playrho::Dot (const T1 &a, const T2 &b) noexcept
 Performs the dot product on two vectors (A and B). More...
 
template<class T >
Angle playrho::GetAngle (const Vector2< T > &value)
 Gets the angle. More...
 
NonNegativeFF< Areaplayrho::GetAreaOfCircle (Length radius)
 Gets the area of a circle.
 
NonNegativeFF< Areaplayrho::GetAreaOfPolygon (const Span< const Length2 > &vertices)
 Gets the area of a polygon. More...
 
std::vector< Length2playrho::GetCircleVertices (Length radius, std::size_t slices, Angle start=0_deg, Real turns=Real(1))
 Gets the vertices for a circle described by the given parameters.
 
constexpr Angle playrho::GetFwdRotationalAngle (const Angle &a1, const Angle &a2) noexcept
 Gets the forward/clockwise rotational angle to go from angle 1 to angle 2. More...
 
constexpr auto playrho::GetInverse22 (const Mat33 &value) noexcept -> Mat33
 Gets the inverse of the given matrix as a 2-by-2. More...
 
template<typename T >
auto playrho::GetMagnitude (const T &value) noexcept(noexcept(sqrt(GetMagnitudeSquared(value)))) -> decltype(sqrt(GetMagnitudeSquared(value)))
 Gets the magnitude of the given value. More...
 
template<typename T >
constexpr auto playrho::GetMagnitudeSquared (const T &value) noexcept
 Gets the square of the magnitude of the given iterable value. More...
 
template<typename T >
constexpr auto playrho::GetModuloNext (T value, const T count) noexcept -> decltype(++value,(value< count)? value:static_cast< T >(0), T())
 Gets the modulo next value. More...
 
template<typename T >
constexpr auto playrho::GetModuloPrev (const T value, const T count) noexcept -> decltype((value ? value :count) - static_cast< T >(1), T())
 Gets the modulo previous value. More...
 
Angle playrho::GetNormalized (Angle value) noexcept
 Gets the "normalized" value of the given angle. More...
 
SecondMomentOfArea playrho::GetPolarMoment (const Span< const Length2 > &vertices)
 Gets the polar moment of the area enclosed by the given vertices. More...
 
constexpr Angle playrho::GetRevRotationalAngle (const Angle &a1, const Angle &a2) noexcept
 Gets the reverse (counter) clockwise rotational angle to go from angle 1 to angle 2. More...
 
Angle playrho::GetShortestDelta (Angle a0, Angle a1) noexcept
 Gets the shortest angular distance to go from angle 0 to angle 1. More...
 
constexpr auto playrho::GetSymInverse33 (const Mat33 &value) noexcept -> Mat33
 Gets the symmetric inverse of this matrix as a 3-by-3. More...
 
constexpr Vec2 playrho::InverseTransform (const Vec2 &v, const Mat22 &A) noexcept
 
template<class IN_TYPE >
constexpr auto playrho::Invert (const Matrix22< IN_TYPE > &value) noexcept
 Inverts the given value.
 
template<typename T >
constexpr auto playrho::IsOdd (const T &val) -> decltype((val % 2) !=T{})
 Is-odd. More...
 
template<typename T >
constexpr auto playrho::IsPowerOfTwo (const T &n) -> decltype(n &&!(n &(n - 1)))
 Reports whether or not the given value is a power of two.
 
template<typename T >
auto playrho::ModuloViaFmod (T dividend, T divisor)
 Modulo operation using std::fmod. More...
 
template<typename T >
auto playrho::ModuloViaTrunc (T dividend, T divisor) noexcept
 Modulo operation using std::trunc. More...
 
constexpr Mat22 playrho::MulT (const Mat22 &A, const Mat22 &B) noexcept
 Computes A^T * B.
 
template<typename T >
constexpr auto playrho::NextPowerOfTwo (T x) -> decltype((x|(x >> 1u)), T(++x))
 Gets the next largest power of 2. More...
 
Real playrho::Normalize (Vec2 &vector)
 Converts the given vector into a unit vector and returns its original length.
 
template<typename T >
auto playrho::RoundOff (const T &value, unsigned precision=DefaultRoundOffPrecission) -> decltype(round(value *static_cast< T >(precision))/static_cast< T >(precision))
 Computes the rounded value of the given value.
 
auto playrho::RoundOff (const Vec2 &value, std::uint32_t precision=DefaultRoundOffPrecission) -> Vec2
 Computes the rounded value of the given value. More...
 
template<typename T , typename U >
constexpr auto playrho::Secant (const T &target, const U &a1, const T &s1, const U &a2, const T &s2) -> decltype(a1+(target - s1) *(a2 - a1)/(s2 - s1))
 Secant method. More...
 
template<typename T , typename U >
constexpr auto playrho::Solve (const Matrix22< U > &mat, const Vector2< T > &b) noexcept
 Solves A * x = b, where b is a column vector. More...
 
template<typename T >
constexpr auto playrho::Solve22 (const Mat33 &mat, const Vector2< T > &b) noexcept -> Vector2< T >
 Solves A * x = b, where b is a column vector. More...
 
template<typename T >
constexpr auto playrho::Solve33 (const Mat33 &mat, const Vector3< T > &b) noexcept -> Vector3< T >
 Solves A * x = b, where b is a column vector. More...
 
template<class T >
constexpr auto playrho::Square (T t) noexcept(noexcept(t *t)) -> decltype(t *t)
 Squares the given value.
 
template<class T >
constexpr auto playrho::ToSigned (const T &value) -> decltype(static_cast< std::make_signed_t< T >>(value))
 Converts the given value to its closest signed equivalent.
 
constexpr Vec2 playrho::Transform (const Vec2 &v, const Mat33 &A) noexcept
 Multiplies a vector by a matrix.
 
template<std::size_t M, typename T1 , std::size_t N, typename T2 >
constexpr auto playrho::Transform (const Vector< T1, M > &v, const Matrix< T2, M, N > &m) noexcept
 Multiplies an M-element vector by an M-by-N matrix. More...
 

Variables

constexpr auto playrho::DefaultRoundOffPrecission = unsigned{100000}
 Default round-off precision.
 

Detailed Description

Additional functions for common mathematical operations.

These are non-member non-friend functions for mathematical operations especially those with mixed input and output types.

Function Documentation

◆ AlmostEqual()

template<typename T >
constexpr auto playrho::AlmostEqual ( a,
b,
int  ulp = 4 
) -> std::enable_if_t<IsArithmeticV<T>, bool>
constexpr

Determines whether the given two values are "almost equal".

Note
A default ULP of 4 is what googletest uses in its kMaxUlps setting for its AlmostEquals function found in its gtest/internal/gtest-internal.h file.
See also
https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-internal.h
Examples
World.cpp.

Referenced by playrho::GaussSeidel::SolvePositionConstraint().

◆ AlmostZero()

template<typename T >
constexpr auto playrho::AlmostZero ( const T &  value) -> decltype(abs(value) < std::numeric_limits<T>::min())
constexpr

Gets whether a given value is almost zero.

An almost zero value is "subnormal". Dividing by these values can lead to odd results like a divide by zero trap occurring.

Returns
true if the given value is almost zero, false otherwise.

Referenced by playrho::ComputeCentroid(), playrho::d2::DistanceProxy::Distance(), playrho::d2::GetMassData(), playrho::ToiOutput::GetToiViaSat(), playrho::Invert(), playrho::Normalize(), playrho::d2::DistanceProxy::RayCast(), playrho::d2::RayCast(), and playrho::Solve().

◆ Atan2()

template<typename T >
auto playrho::Atan2 ( y,
x 
)
inline

Computes the arc-tangent of the given y and x values.

Returns
Normalized angle - an angle between -Pi and Pi inclusively.
See also
https://en.cppreference.com/w/cpp/numeric/math/atan2

Referenced by playrho::d2::GetAngle(), and playrho::GetAngle().

◆ Bisect()

template<typename T >
constexpr auto playrho::Bisect ( const T &  a1,
const T &  a2 
) -> decltype((a1 + a2) / 2)
constexpr

◆ cfloor()

template<class T >
constexpr auto playrho::cfloor ( v)
constexprnoexcept

Constant expression enhanced floor function.

Note
Unlike std::floor, this function is only defined for finite values.
See also
https://en.cppreference.com/w/cpp/numeric/math/floor

Referenced by playrho::GetNormalized(), and playrho::d2::Position::GetPosition().

◆ ComputeCentroid()

Length2 playrho::ComputeCentroid ( const Span< const Length2 > &  vertices)

Computes the centroid of a counter-clockwise array of 3 or more vertices.

Precondition
vertices Has 3 or more elements and they're in counter-clockwise order.

◆ Cross()

template<class T1 , class T2 , std::enable_if_t< std::tuple_size_v< T1 >==2 &&std::tuple_size_v< T2 >==2, int > = 0>
constexpr auto playrho::Cross ( const T1 &  a,
const T2 &  b 
)
constexprnoexcept

Performs the 2-element analog of the cross product of two vectors.

Cross-products the given two values.

Defined as the result of: (a.x * b.y) - (a.y * b.x).

Note
This operation is dimension squashing. I.e. A cross of a 2-D length by a 2-D unit vector results in a 1-D length value.
The unit of the result is the 1-D product of the inputs.
This operation is anti-commutative. I.e. Cross(a, b) == -Cross(b, a).
The result will be 0 if any of the following are true: vector A or vector B has a length of zero; vectors A and B point in the same direction; or vectors A and B point in exactly opposite direction of each other.
The result will be positive if: neither vector A nor B has a length of zero; and vector B is at an angle from vector A of greater than 0 and less than 180 degrees (counter-clockwise from A being a positive angle).
Result will be negative if: neither vector A nor B has a length of zero; and vector B is at an angle from vector A of less than 0 and greater than -180 degrees (clockwise from A being a negative angle).
The absolute value of the result is the area of the parallelogram formed by the vectors A and B.
See also
https://en.wikipedia.org/wiki/Cross_product
Returns
Cross product of the two values.
Note
This operation is anti-commutative. I.e. Cross(a, b) == -Cross(b, a).
See also
https://en.wikipedia.org/wiki/Cross_product
Parameters
aValue A of a 3-element type.
bValue B of a 3-element type.
Returns
Cross product of the two values.

Referenced by playrho::d2::World::ApplyForce(), playrho::d2::Body::ApplyLinearImpulse(), playrho::d2::Simplex::CalcMetric(), playrho::d2::CalcSearchDirection(), playrho::ComputeCentroid(), playrho::d2::Simplex::Get(), playrho::d2::GetConvexHullAsVector(), playrho::d2::GetEffectiveInvMass(), playrho::d2::GetMassData(), playrho::GetPolarMoment(), playrho::GetSymInverse33(), playrho::d2::DistanceJointConf::InitVelocity(), playrho::d2::FrictionJointConf::InitVelocity(), playrho::d2::GearJointConf::InitVelocity(), playrho::d2::MotorJointConf::InitVelocity(), playrho::d2::PrismaticJointConf::InitVelocity(), playrho::d2::PulleyJointConf::InitVelocity(), playrho::d2::RevoluteJointConf::InitVelocity(), playrho::d2::RopeJointConf::InitVelocity(), playrho::d2::TargetJointConf::InitVelocity(), playrho::d2::WeldJointConf::InitVelocity(), playrho::d2::WheelJointConf::InitVelocity(), playrho::Invert(), playrho::d2::DistanceProxy::RayCast(), playrho::d2::World::SetForce(), playrho::Solve(), playrho::Solve33(), playrho::d2::DistanceJointConf::SolvePosition(), playrho::d2::GearJointConf::SolvePosition(), playrho::d2::PrismaticJointConf::SolvePosition(), playrho::d2::PulleyJointConf::SolvePosition(), playrho::d2::RevoluteJointConf::SolvePosition(), playrho::d2::RopeJointConf::SolvePosition(), playrho::d2::WeldJointConf::SolvePosition(), playrho::d2::WheelJointConf::SolvePosition(), playrho::GaussSeidel::SolvePositionConstraint(), playrho::d2::DistanceJointConf::SolveVelocity(), playrho::d2::FrictionJointConf::SolveVelocity(), playrho::d2::MotorJointConf::SolveVelocity(), playrho::d2::PulleyJointConf::SolveVelocity(), playrho::d2::RevoluteJointConf::SolveVelocity(), playrho::d2::RopeJointConf::SolveVelocity(), playrho::d2::TargetJointConf::SolveVelocity(), playrho::d2::WeldJointConf::SolveVelocity(), and playrho::d2::Validate().

◆ ctrunc()

template<class T >
constexpr auto playrho::ctrunc ( v)
constexprnoexcept

Constant expression enhanced truncate function.

Note
Unlike std::trunc, this function is only defined for finite values.
See also
https://en.cppreference.com/w/cpp/numeric/math/trunc

◆ Dot()

template<typename T1 , typename T2 >
constexpr auto playrho::Dot ( const T1 &  a,
const T2 &  b 
)
constexprnoexcept

Performs the dot product on two vectors (A and B).

The dot product of two vectors is defined as: the magnitude of vector A, multiplied by, the magnitude of vector B, multiplied by, the cosine of the angle between the two vectors (A and B). Thus the dot product of two vectors is a value ranging between plus and minus the magnitudes of each vector times each other. The middle value of 0 indicates that two vectors are perpendicular to each other (at an angle of +/- 90 degrees from each other).

Note
This operation is commutative. I.e. Dot(a, b) == Dot(b, a).
If A and B are the same vectors, GetMagnitudeSquared(Vec2) returns the same value using effectively one less input parameter.
This is similar to the std::inner_product standard library algorithm except benchmark tests suggest this implementation is faster at least for Vec2 like instances.
See also
https://en.wikipedia.org/wiki/Dot_product
Parameters
aVector A.
bVector B.
Returns
Dot product of the vectors (0 means the two vectors are perpendicular).

Referenced by playrho::d2::Simplex::Get(), playrho::d2::World::GetGearJointConf(), playrho::d2::World::GetJointTranslation(), playrho::d2::World::GetLinearVelocity(), playrho::d2::GetManifold(), playrho::d2::GetSeparationScenario(), playrho::d2::DistanceProxy::GetSupportIndex(), playrho::GetSymInverse33(), playrho::d2::PrismaticJointConf::InitVelocity(), playrho::d2::WheelJointConf::InitVelocity(), playrho::InverseTransform(), playrho::MulT(), playrho::d2::RayCast(), playrho::Solve33(), playrho::d2::GearJointConf::SolvePosition(), playrho::d2::PrismaticJointConf::SolvePosition(), playrho::d2::WheelJointConf::SolvePosition(), playrho::d2::DistanceJointConf::SolveVelocity(), playrho::d2::GearJointConf::SolveVelocity(), playrho::d2::PrismaticJointConf::SolveVelocity(), playrho::d2::PulleyJointConf::SolveVelocity(), playrho::d2::RopeJointConf::SolveVelocity(), playrho::d2::WheelJointConf::SolveVelocity(), and playrho::d2::DistanceProxy::TestPoint().

◆ GetAngle()

template<class T >
Angle playrho::GetAngle ( const Vector2< T > &  value)
inline

Gets the angle.

Returns
Angular value in the range of -Pi to +Pi radians.

Referenced by playrho::d2::Body::SetAcceleration(), and playrho::d2::Body::SetTransformation().

◆ GetAreaOfPolygon()

NonNegativeFF< Area > playrho::GetAreaOfPolygon ( const Span< const Length2 > &  vertices)

Gets the area of a polygon.

Note
This function is valid for any non-self-intersecting (simple) polygon, which can be convex or concave.
Winding order doesn't matter.

◆ GetFwdRotationalAngle()

constexpr Angle playrho::GetFwdRotationalAngle ( const Angle a1,
const Angle a2 
)
constexprnoexcept

Gets the forward/clockwise rotational angle to go from angle 1 to angle 2.

Returns
Angular rotation in the clockwise direction to go from angle 1 to angle 2.

Referenced by playrho::d2::GearJointConf::SolvePosition().

◆ GetInverse22()

constexpr auto playrho::GetInverse22 ( const Mat33 value) -> Mat33
constexprnoexcept

Gets the inverse of the given matrix as a 2-by-2.

Returns
Zero matrix if singular.

Referenced by playrho::d2::WeldJointConf::InitVelocity().

◆ GetMagnitude()

◆ GetMagnitudeSquared()

◆ GetModuloNext()

template<typename T >
constexpr auto playrho::GetModuloNext ( value,
const T  count 
) -> decltype(++value, (value < count)? value: static_cast<T>(0), T())
constexprnoexcept

Gets the modulo next value.

Parameters
valueTo get the modulo next value for.
countCount to wrap around at. Must be greater-than zero.
Precondition
value is less than count.
count is greater-than zero.
value plus one is greater-than zero.
See also
GetModuloPrev.

Referenced by playrho::ComputeCentroid(), playrho::GetAreaOfPolygon(), playrho::d2::GetFwdNormalsArray(), playrho::d2::GetFwdNormalsVector(), playrho::d2::GetManifold(), playrho::d2::GetMassData(), playrho::d2::GetNextIndex(), playrho::GetPolarMoment(), playrho::d2::DistanceProxy::RayCast(), playrho::d2::DistanceProxy::TestPoint(), and playrho::d2::Validate().

◆ GetModuloPrev()

template<typename T >
constexpr auto playrho::GetModuloPrev ( const T  value,
const T  count 
) -> decltype((value ? value : count) - static_cast<T>(1), T())
constexprnoexcept

Gets the modulo previous value.

Parameters
valueTo get the modulo previous value for.
countCount to wrap around at. Must be greater-than zero.
Precondition
count is greater-than zero and value is less than count.
See also
GetModuloNext.

Referenced by playrho::GetAreaOfPolygon().

◆ GetNormalized()

Angle playrho::GetNormalized ( Angle  value)
noexcept

Gets the "normalized" value of the given angle.

Note
An angle of zero (0), represents the positive X-axis.
Both -Pi and +Pi normalize to -Pi.
Parameters
valueA finite angular value. Behavior of this function is not defined if given a non-finite value.
Returns
Angle that's greater than or equal to -Pi and that's less than +Pi radians. I.e. the value returned will be a value within the half-open interval of [-Pi, +Pi).
See also
Atan2

Referenced by playrho::d2::GetNormalized(), playrho::d2::Sweep::GetNormalized(), and playrho::GetShortestDelta().

◆ GetPolarMoment()

SecondMomentOfArea playrho::GetPolarMoment ( const Span< const Length2 > &  vertices)

Gets the polar moment of the area enclosed by the given vertices.

Parameters
verticesCollection of three or more vertices.
Precondition
vertices has 3 or more elements.

Referenced by playrho::d2::GetMassData().

◆ GetRevRotationalAngle()

constexpr Angle playrho::GetRevRotationalAngle ( const Angle a1,
const Angle a2 
)
constexprnoexcept

Gets the reverse (counter) clockwise rotational angle to go from angle 1 to angle 2.

Returns
Angular rotation in the counter clockwise direction to go from angle 1 to angle 2.

Referenced by playrho::d2::GearJointConf::SolvePosition().

◆ GetShortestDelta()

Angle playrho::GetShortestDelta ( Angle  a0,
Angle  a1 
)
noexcept

Gets the shortest angular distance to go from angle 0 to angle 1.

This gets the angle to rotate angle 0 by, in order to get to angle 1, with the least amount of rotation.

Returns
Angle between -Pi and Pi radians inclusively.
See also
GetNormalized

Referenced by playrho::d2::Position::GetPosition().

◆ GetSymInverse33()

constexpr auto playrho::GetSymInverse33 ( const Mat33 value) -> Mat33
constexprnoexcept

Gets the symmetric inverse of this matrix as a 3-by-3.

Returns
Zero matrix if singular.

Referenced by playrho::d2::WeldJointConf::InitVelocity().

◆ InverseTransform()

constexpr Vec2 playrho::InverseTransform ( const Vec2 v,
const Mat22 A 
)
constexprnoexcept

Multiply a matrix transpose times a vector. If a rotation matrix is provided, then this transforms the vector from one frame to another (inverse transform).

◆ IsOdd()

template<typename T >
constexpr auto playrho::IsOdd ( const T &  val) -> decltype((val % 2) != T{})
constexpr

Is-odd.

Determines whether the given integral value is odd (as opposed to being even).

Referenced by playrho::ToiOutput::GetToiViaSat().

◆ ModuloViaFmod()

template<typename T >
auto playrho::ModuloViaFmod ( dividend,
divisor 
)

Modulo operation using std::fmod.

Note
Modulo via std::fmod appears slower than via std::trunc.
See also
ModuloViaTrunc

Referenced by playrho::GetNormalized().

◆ ModuloViaTrunc()

template<typename T >
auto playrho::ModuloViaTrunc ( dividend,
divisor 
)
noexcept

Modulo operation using std::trunc.

Note
Modulo via std::fmod appears slower than via std::trunc.
This function won't behave like ModuloViaFmod when divisor is infinite.
Parameters
dividendDividend value for which isfinite returns true.
divisorDivisor value for which isfinite returns true.
See also
ModuloViaFmod

Referenced by playrho::GetNormalized(), and playrho::GetShortestDelta().

◆ NextPowerOfTwo()

template<typename T >
constexpr auto playrho::NextPowerOfTwo ( x) -> decltype((x | (x >> 1u)), T(++x))
constexpr

Gets the next largest power of 2.

Given a binary integer value x, the next largest power of 2 can be computed by a S.W.A.R. algorithm that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with the same most significant 1 as x, but all one's below it. Adding 1 to that value yields the next largest power of 2.

Referenced by playrho::d2::DynamicTree::Reserve().

◆ RoundOff()

auto playrho::RoundOff ( const Vec2 value,
std::uint32_t  precision = DefaultRoundOffPrecission 
) -> Vec2
inline

Computes the rounded value of the given value.

Todo:
Consider making this function generic to any Vector.

◆ Secant()

template<typename T , typename U >
constexpr auto playrho::Secant ( const T &  target,
const U &  a1,
const T &  s1,
const U &  a2,
const T &  s2 
) -> decltype(a1 + (target - s1) * (a2 - a1) / (s2 - s1))
constexpr

◆ Solve()

template<typename T , typename U >
constexpr auto playrho::Solve ( const Matrix22< U > &  mat,
const Vector2< T > &  b 
)
constexprnoexcept

Solves A * x = b, where b is a column vector.

Note
This is more efficient than computing the inverse in one-shot cases.

Referenced by playrho::d2::PrismaticJointConf::SolvePosition(), and playrho::d2::RevoluteJointConf::SolvePosition().

◆ Solve22()

template<typename T >
constexpr auto playrho::Solve22 ( const Mat33 mat,
const Vector2< T > &  b 
) -> Vector2<T>
constexprnoexcept

Solves A * x = b, where b is a column vector.

Note
This is more efficient than computing the inverse in one-shot cases.
Solves only the upper 2-by-2 matrix equation.

Referenced by playrho::d2::WeldJointConf::SolvePosition(), playrho::d2::PrismaticJointConf::SolveVelocity(), and playrho::d2::RevoluteJointConf::SolveVelocity().

◆ Solve33()

template<typename T >
constexpr auto playrho::Solve33 ( const Mat33 mat,
const Vector3< T > &  b 
) -> Vector3<T>
constexprnoexcept

Solves A * x = b, where b is a column vector.

Note
This is more efficient than computing the inverse in one-shot cases.

Referenced by playrho::d2::PrismaticJointConf::SolvePosition(), playrho::d2::WeldJointConf::SolvePosition(), playrho::d2::PrismaticJointConf::SolveVelocity(), and playrho::d2::RevoluteJointConf::SolveVelocity().

◆ Transform()

template<std::size_t M, typename T1 , std::size_t N, typename T2 >
constexpr auto playrho::Transform ( const Vector< T1, M > &  v,
const Matrix< T2, M, N > &  m 
)
constexprnoexcept

Multiplies an M-element vector by an M-by-N matrix.

Parameters
vVector that's interpreted as a matrix with 1 row and M-columns.
mAn M-row by N-column transformation matrix to multiply the vector by.
See also
https://en.wikipedia.org/wiki/Transformation_matrix