40#ifndef GEOGRAM_BASIC_VECHG
41#define GEOGRAM_BASIC_VECHG
60 template <
class T>
class vec2Hg {
67 vec2Hg(
const T& x_in,
const T& y_in,
const T& w_in) :
73 vec2Hg(
double x_in,
double y_in,
double w_in) :
79 vec2Hg(T&& x_in, T&& y_in, T&& w_in) :
85 vec2Hg(
const vec2Hg& rhs) =
default;
87 vec2Hg(vec2Hg&& rhs) =
default;
89 template <
class T2>
explicit vec2Hg(
const vecng<2,T2>& rhs) :
95 template <
class T2>
explicit vec2Hg(
const vec2Hg<T2>& rhs) :
101 vec2Hg& operator=(
const vec2Hg& rhs) =
default;
102 vec2Hg& operator=(vec2Hg&& rhs) =
default;
108 const T* data()
const {
124 return rationalg<T>(data()[i], data()[2]);
151 det2x2(p1.x,p1.w,p2.x,p2.w),
152 det2x2(p1.y,p1.w,p2.y,p2.w),
190 template <
class T>
class vec3Hg {
197 vec3Hg(
const T& x_in,
const T& y_in,
const T& z_in,
const T& w_in) :
204 vec3Hg(T&& x_in, T&& y_in, T&& z_in, T&& w_in) :
211 vec3Hg(
double x_in,
double y_in,
double z_in,
double w_in) :
218 vec3Hg(
const vec3Hg& rhs) =
default;
220 vec3Hg(vec3Hg&& rhs) =
default;
222 template <
class T2>
explicit vec3Hg(
const vecng<3,T2>& rhs) :
229 template <
class T2>
explicit vec3Hg(
const vec3Hg<T2>& rhs) :
236 vec3Hg& operator=(
const vec3Hg& rhs) =
default;
237 vec3Hg& operator=(vec3Hg&& rhs) =
default;
243 const T* data()
const {
259 return rationalg<T>(data()[i], data()[3]);
289 det2x2(p1.x,p1.w,p2.x,p2.w),
290 det2x2(p1.y,p1.w,p2.y,p2.w),
291 det2x2(p1.z,p1.w,p2.z,p2.w),
335 template <
class T>
inline vec2Hg<T> mix(
336 const rationalg<T>& t,
337 const vecng<2,double>& p1,
const vecng<2,double>& p2
339 const T& st_d = t.denom();
340 const T& t_n = t.num();
343 s_n * T(p1.x) + t_n * T(p2.x),
344 s_n * T(p1.y) + t_n * T(p2.y),
353 const T& st_d = t.denom();
354 const T& t_n = t.num();
357 s_n * T(p1.x) + t_n * T(p2.x),
358 s_n * T(p1.y) + t_n * T(p2.y),
359 s_n * T(p1.z) + t_n * T(p2.z),
369 T sn = t.denom() - t.num();
372 sn * p1.x + tn * p2.x,
373 sn * p1.y + tn * p2.y,
377 T sn = p2.w*(t.denom() - t.num());
380 sn * p1.x + tn * p2.x,
381 sn * p1.y + tn * p2.y,
382 t.denom() * p1.w * p2.w
391 T sn = t.denom() - t.num();
394 sn * p1.x + tn * p2.x,
395 sn * p1.y + tn * p2.y,
396 sn * p1.z + tn * p2.z,
400 T sn = p2.w*(t.denom() - t.num());
403 sn * p1.x + tn * p2.x,
404 sn * p1.y + tn * p2.y,
405 sn * p1.z + tn * p2.z,
406 t.denom() * p1.w * p2.w
#define geo_debug_assert(x)
Verifies that a condition is met.
rationalg (generic rational) is used to compute the sign of rational fractions exactly.
Comparator class for vec2Hg \detail Used to create maps indexed by vec2Hg or SOS symbolic perturbatio...
bool operator()(const vec2Hg< T > &v1, const vec2Hg< T > &v2) const
Compares two vec2Hg.
2d vector with homogeneous coordinates
T value_type
The type of the vector coordinates.
Comparator class for vec3Hg \detail Used to create maps indexed by vec3Hg or SOS symbolic perturbatio...
bool operator()(const vec3Hg< T > &v1, const vec3Hg< T > &v2) const
Compares two vec3Hg.
3d vector with homogeneous coordinates
T value_type
The type of the vector coordinates.
Common include file, providing basic definitions. Should be included before anything else by all head...
Defines numeric types used in Vorpaline.
Sign ratio_compare(const T &a_num, const T &a_denom, const T &b_num, const T &b_denom)
Compares two rational numbers given as separate numerators and denominators.
void optimize_number_representation(T &x)
place holder for optimizing internal number representation
Global Vorpaline namespace.
Quaternion operator-(const Quaternion &a, const Quaternion &b)
Computes the difference between two Quaternion.
Sign
Integer constants that represent the sign of a value.
T det2x2(const T &a11, const T &a12, const T &a21, const T &a22)
Computes a two-by-two determinant.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Generic implementation of rational type.
Generic implementation of geometric vectors.