33 template<
typename>
struct Vector;
39 template<
typename Valtype>
42 typedef Valtype value_type;
59 PositionH( Valtype
x, Valtype
y, Valtype
z, Valtype
w )
noexcept;
60 template<
typename Valtype2>
62 template<
typename Valtype2>
64 template<
typename Valtype2>
65 explicit PositionH(
const Valtype2* pVal )
noexcept;
72 const Valtype& operator[](
size_t index )
const;
74 Valtype& operator[](
size_t index );
79 Valtype*
ptr() noexcept;
83 const Valtype*
ptr() const noexcept;
98 bool Equals( const
PositionH& p, Valtype epsilon = Valtype{0} )
const noexcept;
103 template<
typename Valtype>
constexpr
104 bool operator==(
const PositionH<Valtype>& p1,
const PositionH<Valtype>& p2 )
noexcept;
105 template<
typename Valtype>
constexpr
106 bool operator!=(
const PositionH<Valtype>& p1,
const PositionH<Valtype>& p2 )
noexcept;
110 template<
typename Valtype>
111 constexpr size_t size(
const PositionH<Valtype> )
noexcept {
115template<
typename Valtype>
117 :
x{
x}, y{y}, z{z}, w{w}
120template<
typename Valtype>
121template<
typename Valtype2>
123 :
x{ p.x/Valtype2{1} },
124 y{ p.y/Valtype2{1} },
125 z{ p.z/Valtype2{1} },
129template<
typename Valtype>
130template<
typename Valtype2>
132 :
x{ v.dx/Valtype2{1} },
133 y{ v.dy/Valtype2{1} },
134 z{ v.dz/Valtype2{1} },
138template<
typename Valtype>
139template<
typename Valtype2>
141 :
x{ Valtype{ pVal[0] } },
142 y{ Valtype{ pVal[1] } },
143 z{ Valtype{ pVal[2] } },
144 w{ Valtype{ pVal[3] } }
147template<
typename Valtype>
148inline const Valtype& PositionH<Valtype>::operator[](
size_t index )
const{
160 throw std::out_of_range(
"invalid PositionH subscript" );
164template<
typename Valtype>
165inline Valtype& PositionH<Valtype>::operator[](
size_t index ){
177 throw std::out_of_range(
"invalid PositionH subscript" );
181template<
typename Valtype>
186template<
typename Valtype>
191template<
typename Valtype>
193 x = Valtype{0};
y = Valtype{0};
z = Valtype{0};
w = Valtype{1};
196template<
typename Valtype>
198 if(
w != Valtype{0} ){
208template<
typename Valtype>
210 return std::abs(
x/
w - p.x/p.w) <= epsilon_ &&
211 std::abs(
y/
w - p.y/p.w) <= epsilon_ &&
212 std::abs(
z/
w - p.z/p.w) <= epsilon_;
215template<
typename Valtype>
217 return p1.x/p1.w == p2.x/p2.w &&
218 p1.y/p1.w == p2.y/p2.w &&
219 p1.z/p1.w == p2.z/p2.w;
222template<
typename Valtype>
223inline constexpr bool operator!=(
const PositionH<Valtype>& p1,
const PositionH<Valtype>& p2 )
noexcept{
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
Implements a 4D - position in homogenous coordinates.
Definition PositionH.h:41
Valtype y
y coordinate
Definition PositionH.h:45
void Init() noexcept
Sets the values to (0,0,0,1).
Definition PositionH.h:192
bool Homogenize() noexcept
Transforms the position so that w == 1.
Definition PositionH.h:197
Valtype z
z coordinate
Definition PositionH.h:46
bool Equals(const PositionH &p, Valtype epsilon=Valtype{0}) const noexcept
Comparison within some range. The area within two positions regarded as equal is a sphere with radius...
Definition PositionH.h:209
PositionH()=default
Does not initialize the members.
Valtype w
w coordinate, homogenous coordinate
Definition PositionH.h:47
Valtype * ptr() noexcept
Pointer accessor for direct copying.
Definition PositionH.h:182
Valtype x
x coordinate
Definition PositionH.h:44
Implements a 3D - position in cartesian coordinates.
Definition Position.h:46
Implements a 3D - vector in cartesian coordinates.
Definition Vector.h:48