2-D unit vector. More...
#include <UnitVec.hpp>
Public Types | |
using | value_type = Real |
Value type used for the coordinate values of this vector. | |
using | size_type = std::size_t |
Size type. | |
using | const_reference = const value_type & |
Constant reference type. | |
using | const_pointer = const value_type * |
Constant pointer type. | |
using | const_iterator = const value_type * |
Constant iterator type. | |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Constant reverse iterator type. | |
template<typename T > | |
using | PolarCoord = std::enable_if_t< IsArithmetic< T >::value, std::pair< UnitVec, T > > |
Polar coordinate. More... | |
Public Member Functions | |
constexpr size_type | max_size () const noexcept |
Gets the max size. | |
constexpr size_type | size () const noexcept |
Gets the size. | |
constexpr bool | empty () const noexcept |
Whether empty. More... | |
const_iterator | begin () const noexcept |
Gets a "begin" iterator. | |
const_iterator | end () const noexcept |
Gets an "end" 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. | |
const_reverse_iterator | rbegin () const noexcept |
Gets a reverse "begin" iterator. | |
const_reverse_iterator | rend () const noexcept |
Gets a reverse "end" iterator. | |
constexpr const_reference | operator[] (size_type pos) const noexcept |
Gets a constant reference to the requested element. More... | |
constexpr const_reference | at (size_type pos) const |
Gets a constant reference to the requested element. More... | |
constexpr const_pointer | data () const noexcept |
Direct access to data. | |
constexpr auto | GetX () const noexcept |
Gets the "X" value. | |
constexpr auto | GetY () const noexcept |
Gets the "Y" value. | |
constexpr UnitVec | FlipXY () const noexcept |
Flips the X and Y values. | |
constexpr UnitVec | FlipX () const noexcept |
Flips the X value. | |
constexpr UnitVec | FlipY () const noexcept |
Flips the Y value. | |
constexpr UnitVec | Rotate (UnitVec amount) const noexcept |
Rotates the unit vector by the given amount. More... | |
constexpr UnitVec | GetRevPerpendicular () const noexcept |
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to this vector. More... | |
constexpr UnitVec | GetFwdPerpendicular () const noexcept |
Gets a vector clockwise (forward-clockwise) perpendicular to this vector. More... | |
constexpr UnitVec | operator- () const noexcept |
Negation operator. | |
constexpr UnitVec | operator+ () const noexcept |
Positive operator. | |
constexpr UnitVec | Absolute () const noexcept |
Gets the absolute value. | |
Static Public Member Functions | |
static constexpr UnitVec | GetRight () noexcept |
Gets the right-ward oriented unit vector. More... | |
static constexpr UnitVec | GetTop () noexcept |
Gets the top-ward oriented unit vector. More... | |
static constexpr UnitVec | GetLeft () noexcept |
Gets the left-ward oriented unit vector. More... | |
static constexpr UnitVec | GetBottom () noexcept |
Gets the bottom-ward oriented unit vector. More... | |
static constexpr UnitVec | GetZero () noexcept |
Gets the non-oriented unit vector. | |
static constexpr UnitVec | GetTopRight () noexcept |
Gets the 45 degree unit vector. More... | |
static constexpr UnitVec | GetBottomRight () noexcept |
Gets the -45 degree unit vector. More... | |
static constexpr UnitVec | GetDefaultFallback () noexcept |
Gets the default fallback. | |
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. | |
static UnitVec | Get (const Angle angle) noexcept |
Gets the given angled unit vector. More... | |
Private Member Functions | |
constexpr | UnitVec (value_type x, value_type y) noexcept |
Initializing constructor. | |
Private Attributes | |
value_type | m_elems [2] = { value_type{0}, value_type{0} } |
Element values. | |
2-D unit vector.
This is a 2-dimensional directional vector.
using playrho::d2::UnitVec::PolarCoord = std::enable_if_t<IsArithmetic<T>::value, std::pair<UnitVec, T> > |
Polar coordinate.
This is a direction and magnitude pair defined by the unit vector class.
|
inlineconstexpr |
Gets a constant reference to the requested element.
InvalidArgument | if given a position that's >= size(). |
|
inlineconstexprnoexcept |
Whether empty.
Gets the given angled unit vector.
|
inlinestaticconstexprnoexcept |
Gets the bottom-ward oriented unit vector.
Referenced by playrho::d2::RayCast(), and playrho::d2::PolygonShapeConf::SetAsBox().
|
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 playrho::d2::RayCast(), and playrho::d2::PolygonShapeConf::SetAsBox().
|
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 playrho::d2::RayCast(), and playrho::d2::PolygonShapeConf::SetAsBox().
|
inlinestaticconstexprnoexcept |
Gets the top-ward oriented unit vector.
Referenced by playrho::d2::RayCast(), and playrho::d2::PolygonShapeConf::SetAsBox().
|
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.
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. |