2-D unit vector. More...
#include <playrho/d2/UnitVec.hpp>
Public Types | |
using | checker_type = detail::UnitMagnitudeChecker< underlying_type > |
Alias for checker type this class template was instantiated for. | |
using | const_iterator = underlying_type::const_iterator |
Constant iterator type. | |
using | const_pointer = underlying_type::const_pointer |
Constant pointer type. | |
using | const_reference = underlying_type::const_reference |
Constant reference type. | |
using | const_reverse_iterator = underlying_type::const_reverse_iterator |
Constant reverse iterator type. | |
using | exception_type = InvalidArgument |
Alias for the exception type possibly thrown by this class. | |
template<typename T > | |
using | PolarCoord = std::enable_if_t< IsArithmeticV< T >, std::pair< UnitVec, T > > |
Polar coordinate. More... | |
using | size_type = underlying_type::size_type |
Size type. | |
using | underlying_type = Vector< value_type, N > |
Alias for the underlying type of this object. | |
using | value_type = Real |
Value type used for the coordinate values of this vector. | |
Public Member Functions | |
constexpr | UnitVec () noexcept=default |
Default constructor. More... | |
UnitVec (const underlying_type &v) | |
Initializing constructor. More... | |
constexpr UnitVec | Absolute () const noexcept |
Gets the absolute value. | |
constexpr const_reference | at (size_type pos) const |
Gets a constant reference to the requested element. More... | |
const_iterator | begin () const noexcept |
Gets a "begin" iterator. | |
const_iterator | cbegin () const noexcept |
Gets a "begin" iterator. | |
const_iterator | cend () const noexcept |
Gets an "end" iterator. | |
const_reverse_iterator | crbegin () const noexcept |
Gets a reverse "begin" iterator. | |
const_reverse_iterator | crend () const noexcept |
Gets a reverse "end" iterator. | |
constexpr const_pointer | data () const noexcept |
Direct access to data. | |
const_iterator | end () const noexcept |
Gets an "end" iterator. | |
constexpr UnitVec | FlipX () const noexcept |
Flips the X value. | |
constexpr UnitVec | FlipXY () const noexcept |
Flips the X and Y values. | |
constexpr UnitVec | FlipY () const noexcept |
Flips the Y value. | |
constexpr UnitVec | GetFwdPerpendicular () const noexcept |
Gets a vector clockwise (forward-clockwise) perpendicular to this vector. More... | |
constexpr UnitVec | GetRevPerpendicular () const noexcept |
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to this vector. More... | |
constexpr auto | GetX () const noexcept |
Gets the "X" value. | |
constexpr auto | GetY () const noexcept |
Gets the "Y" value. | |
constexpr | operator underlying_type () const noexcept |
Implicitly gets the underlying value via a cast or implicit conversion. | |
constexpr UnitVec | operator+ () const noexcept |
Positive operator. | |
constexpr UnitVec | operator- () const noexcept |
Negation operator. | |
constexpr const_reference | operator[] (size_type pos) const noexcept |
Gets a constant reference to the requested element. More... | |
const_reverse_iterator | rbegin () const noexcept |
Gets a reverse "begin" iterator. | |
const_reverse_iterator | rend () const noexcept |
Gets a reverse "end" iterator. | |
constexpr UnitVec | Rotate (const UnitVec &amount) const noexcept |
Rotates the unit vector by the given amount. More... | |
Static Public Member Functions | |
static constexpr bool | empty () noexcept |
Whether empty. More... | |
static UnitVec | Get (Angle angle) noexcept |
Gets the given angled unit vector. More... | |
template<typename T > | |
static PolarCoord< T > | Get (const T x, const T y, const UnitVec &fallback=GetDefaultFallback()) noexcept |
Gets the unit vector & magnitude from the given parameters. More... | |
static constexpr UnitVec | GetDefaultFallback () noexcept |
Gets the default fallback. | |
static constexpr UnitVec | GetDown () noexcept |
Gets the down-ward oriented unit vector. More... | |
static constexpr UnitVec | GetDownRight () noexcept |
Gets the -45 degree unit vector. More... | |
static constexpr UnitVec | GetLeft () noexcept |
Gets the left-ward oriented unit vector. More... | |
static constexpr UnitVec | GetRight () noexcept |
Gets the right-ward oriented unit vector. More... | |
static constexpr UnitVec | GetUp () noexcept |
Gets the up-ward oriented unit vector. More... | |
static constexpr UnitVec | GetUpRight () noexcept |
Gets the 45 degree unit vector. More... | |
static constexpr UnitVec | GetZero () noexcept |
Gets the non-oriented unit vector. | |
static constexpr size_type | max_size () noexcept |
Gets the max size. | |
static constexpr size_type | size () noexcept |
Gets the size. | |
static auto | ThrowIfInvalid (const underlying_type &value) -> void |
Throws this class's exception type if the given value is invalid. More... | |
static auto | Validate (const underlying_type &value) -> underlying_type |
Static Public Attributes | |
static constexpr auto | N = std::size_t{2} |
Dimensionality of this type. | |
2-D unit vector.
This is a 2-dimensional directional vector.
using playrho::d2::UnitVec::PolarCoord = std::enable_if_t<IsArithmeticV<T>, std::pair<UnitVec, T> > |
Polar coordinate.
This is a direction and magnitude pair defined by the unit vector class.
|
constexprdefaultnoexcept |
|
inlineexplicit |
Initializing constructor.
Explicitly converts a vector of unit magnitude to an object or throws.
Get
function instead for arbitrary values. GetX
and GetY
return the X and Y components respectively of the given value, exactly. exception_type | Constructed with the returned error - if the checker returned a non-null explanatory string. |
|
inlineconstexpr |
Gets a constant reference to the requested element.
InvalidArgument | if given a position that's >= size(). |
|
inlinestaticconstexprnoexcept |
Whether empty.
Gets the given angled unit vector.
|
inlinestaticnoexcept |
Gets the unit vector & magnitude from the given parameters.
Referenced by playrho::d2::GetTransformation(), playrho::d2::GetUnitVector(), 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::d2::PolygonShapeConf::SetAsBox(), playrho::d2::World::SetTransform(), 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(), and playrho::d2::WheelJointConf::SolvePosition().
|
inlinestaticconstexprnoexcept |
Gets the down-ward oriented unit vector.
Referenced by Get(), and playrho::d2::RayCast().
|
inlinestaticconstexprnoexcept |
Gets the -45 degree unit vector.
This is the unit vector in the positive X and negative Y quadrant where |X| == |Y|.
|
inlineconstexprnoexcept |
Gets a vector clockwise (forward-clockwise) perpendicular to this vector.
This returns the unit vector (y, -x).
Referenced by playrho::d2::GetFwdPerpendicular().
|
inlinestaticconstexprnoexcept |
Gets the left-ward oriented unit vector.
Referenced by Get(), and playrho::d2::RayCast().
|
inlineconstexprnoexcept |
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to this vector.
This returns the unit vector (-y, x).
Referenced by playrho::d2::GetRevPerpendicular(), and playrho::d2::GetYAxis().
|
inlinestaticconstexprnoexcept |
Gets the right-ward oriented unit vector.
Referenced by Get(), playrho::d2::RayCast(), playrho::d2::part::Compositor< P1, P2, P3, P4, P5, P6 >::Rotate(), and playrho::d2::detail::Rotate().
|
inlinestaticconstexprnoexcept |
Gets the up-ward oriented unit vector.
Referenced by Get(), and playrho::d2::RayCast().
|
inlinestaticconstexprnoexcept |
Gets the 45 degree unit vector.
This is the unit vector in the positive X and Y quadrant where X == Y.
|
inlineconstexprnoexcept |
Gets a constant reference to the requested element.
pos | Valid element index to get value for. |
pos
), is less than size()
.
|
inlineconstexprnoexcept |
Rotates the unit vector by the given amount.
amount | Expresses the angular difference from the right-ward oriented unit vector to rotate this unit vector by. |
|
inlinestatic |
Throws this class's exception type if the given value is invalid.
exception_type | Constructed with the returned error - if the checker returned a non-null explanatory string. |
Referenced by Validate().
|
inlinestatic |
Validates the given value using the checker_type
type and returns the value given if it checks out.
exception_type | Constructed with the returned error - if the checker returned a non-null explanatory string. |
Referenced by UnitVec().