10 #ifndef CGA3D_OPERATIONS_H_INCLUDED
11 #define CGA3D_OPERATIONS_H_INCLUDED
16 #include "vsr_cga3D_types.h"
17 #include "vsr_cga3D_round.h"
20 #include "util/vsr_constants.h"
21 #include "util/vsr_math.h"
23 namespace vsr{
namespace cga{
56 static auto dual(
const A& a ) RETURNS (
61 static auto undual(
const A& a ) RETURNS (
66 static auto duale(
const A& a ) RETURNS (
71 static auto unduale(
const A& a ) RETURNS (
75 template<class T>
static auto dl(
const T& t ) RETURNS ( dual(t) )
76 template<
class T>
static auto udl(
const T& t) RETURNS ( udual(t) )
77 template<
class T>
static auto dle(
const T& t) RETURNS (duale(t))
78 template<
class T>
static auto udle(
const T& t) RETURNS (unduale(t))
82 static constexpr
bool sign(
const A& a,
const A& b) {
83 return (a / b)[0] > 0 ? 1 : 0;
88 static constexpr
bool sn(
const A& a,
const A& b){
93 template<
class A,
class B>
94 static constexpr
auto project(
const A& a,
const B& b) RETURNS (
99 template< class A, class B>
100 static constexpr auto
reject(const A& a, const B& b) RETURNS (
105 template< class A, class B>
106 static constexpr auto
pj(const A& a, const B& b) RETURNS (
project(a,b) )
107 template< class A, class B>
108 static constexpr auto rj(const A& a, const B& b) RETURNS (
reject(a,b) )
122 static Rot rot(
const Biv& b);
124 static Rot rotor(
const Biv& b);
128 static Bst boost(
const Pair& p);
130 static Tsd dil(
const Pnt& p, VSR_PRECISION t);
132 static Tsd dilator(
const Pnt& p, VSR_PRECISION t);
149 static Rot ratio(
const Vec& v,
const Vec& v2);
151 static Biv log(
const Rot& r);
158 static Rot rot(
double theta,
double phi);
165 static Rot rot(
double yaw,
double pitch,
double roll);
173 static Mot mot(
const Dll& dll);
178 static Mot motor(
const Dll& dll);
183 static Dll log(
const Mot& m);
193 static Dll log(
const Dll& a,
const Dll& b, VSR_PRECISION t = 1.0);
226 template <
class A,
class T>
240 static Pair atanh2(
const Pair& p, VSR_PRECISION cs,
bool bCW);
243 static Pair log(
const Bst& b,
bool bCW =
false);
248 static Con ratio(
const Circle& a,
const Circle& b,
bool bFlip =
false,
float theta = 0);
253 static Con ratio(
const Pair& a,
const Pair& b,
bool bFlip =
false,
float theta = 0);
259 static vector<Pair> split(
const Pair& par);
265 static vector<Pair> split(
const Con& con);
269 static vector<Pair> log(
const Con& rot);
272 static vector<Pair> log(
const Circle& ca,
const Circle& cb,
bool bFlip =
false, VSR_PRECISION theta = 0);
275 static vector<Pair> log(
const Pair& ca,
const Pair& cb,
bool bFlip =
false, VSR_PRECISION theta = 0);
279 static Con con(
const vector<Pair>& log, VSR_PRECISION amt);
282 static Con con(
const vector<Pair>& log, VSR_PRECISION amtA, VSR_PRECISION amtB);
286 static Con con(
const Circle& ca,
const Circle& cb, VSR_PRECISION amt);
289 static Con con(
const Circle& ca,
const Circle& cb, VSR_PRECISION amtA, VSR_PRECISION amtB);
345 static Pair pair(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z,
Vec vec = Vec::y, VSR_PRECISION r=1.0);
362 static Point point(
const Circle& c, VSR_PRECISION t);
366 static Point point(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z);
387 static Circle circle(
const Point& p, VSR_PRECISION r,
const Biv& biv = Biv::xy);
394 static Circle circle(
const Vec& v, VSR_PRECISION r=1.0);
397 static Circle circle(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z,
Biv biv = Biv::xy, VSR_PRECISION r=1.0);
405 static DualSphere sphere(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z, VSR_PRECISION r=1.0);
415 static DualPlane plane( VSR_PRECISION a, VSR_PRECISION b, VSR_PRECISION c, VSR_PRECISION d=0.0);
417 static DualPlane plane(
const Vec& v, VSR_PRECISION d=0.0);
431 static Line line(
const Vec& a,
const Vec& b);
434 static Line line( VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z );
437 static Line dualLine( VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z );
454 static VSR_PRECISION distance(
const Lin& lin,
const Pnt& pnt);
457 #pragma mark COINCIDENCE_FUNCTIONS
479 static Pair meet(
const Cir& cir,
const Dlp& dlp);
481 static Pair meet(
const Cir& cir,
const Dls& s);
483 #pragma mark HIT_TESTS
488 static bool hit(
const Point&,
const Pair&);
495 static double squaredDistance(
const Point& a,
const Point& b);
498 #pragma mark HYPERBOLIC_FUNCTIONS
512 static double hdist(
const Pnt& pa,
const Pnt& pb);
518 static Pair hgen(
const Pnt& pa,
const Pnt& pb,
double amt);
523 static Point hspin(
const Pnt& pa,
const Pnt& pb,
double amt);
526 #pragma mark AFFINE combinations
528 template<
class A,
class B>
529 static Point affine(
const A& a,
const B& b, VSR_PRECISION t){
530 return (a + (b-a)*t).
null();
552 for (
int i=0;i<=num;++i){
568 for (
int i = 0; i < u; ++i){
569 for (
int j = 0; j < v; ++j){
571 float tu= TWOPI * i/u;
572 float tv = -PIOVERTWO + PI * j/v;
585 template<
class Algebra,
class B>
template <
class A>
586 Multivector<Algebra,B> Multivector<Algebra,B>::mot(
const Multivector<Algebra,A>& t)
const{
589 template<
class Algebra,
class B>
template <
class A>
590 Multivector<Algebra,B> Multivector<Algebra,B>::motor(
const Multivector<Algebra,A>& t)
const{
593 template<
class Algebra,
class B>
template <
class A>
594 Multivector<Algebra,B> Multivector<Algebra,B>::twist(
const Multivector<Algebra,A>& t)
const{
610 #define PT(x,y,z) vsr::cga::Round::null(vsr::cga::Vec(x,y,z))
611 #define DLS(r) vsr::cga::Round::dls(0,0,0,r)
614 #define PV(v) vsr::cga::Round::null(v)
615 #define PX(f) vsr::cga::Round::null(vsr::cga::Vec(f,0,0))
616 #define PY(f) vsr::cga::Round::null(vsr::cga::Vec(0,f,0))
617 #define PZ(f) vsr::cga::Round::null(vsr::cga::Vec(0,0,f))
620 #define PAIR(x,y,z) (PT(x,y,z)^PT(-x,-y,-z))
621 #define CXY(f) (PX(f)^PY(f)^PX(-f)).unit()
623 #define CXZ(f) (PX(f)^PZ(f)^PX(-f)).unit()
625 #define CYZ(f) (PY(f)^PY(-f)^PZ(f)).unit()
627 #define F2S(f) f*1000.0
628 #define S2F(f) f/1000.0
631 #define LN(x,y,z) ( vsr::cga::Point(0,0,0,1,.5)^PT(x,y,z)^vsr::cga::Inf(1) )
632 #define DLN(x,y,z) ( vsr::Op::dl(LN(x,y,z)) )
634 #define PAO vsr::cga::Point(0,0,0,1,0)
635 #define EP vsr::cga::Dls(0,0,0,1,-.5)
636 #define EM vsr::cga::Dls(0,0,0,1,.5)
637 #define INFTY vsr::cga::Inf(1)
638 #define HYPERBOLIC_INF EP
639 #define SPHERICAL_INF EM
640 #define EUCLIDEAN_INF INFTY
641 #define HLN(x,y,z) (vsr::cga::Ori(1)^PT(x,y,z)^EP) //hyperbolic line (circle)
642 #define HDLN(x,y,z) (vsr::Op::dl(HLN(x,y,z)))
static constexpr bool sn(const A &a, const A &b)
Sign of A with Respect to B (short hand)
Definition: vsr_cga3D_op.h:88
static Bst bst(const Pair &p)
vsr::cga::Boost from vsr::cga::Pair
constructive syntactic sugar for making geometric elements
Definition: vsr_cga3D_op.h:330
static constexpr auto pj(const A &a, const B &b) -> auto
Shorthand Proj and Rejection.
static constexpr auto project(const A &a, const B &b) -> auto
Projection of A onto B.
static Rot AA(const Vec &s)
axis angle from Vec stored in rotor
static Point point(const Circle &c, VSR_PRECISION t)
Point on Circle at theta t.
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
static Rot rot(const Biv &b)
vsr::cga::Rotor from vsr::cga::Bivector
Multivector< algebra, typename algebra::vector_basis > null() const
Conformal Mapping \(\boldsymbol(x)\to n_o + \boldsymbol{x} + \boldsymbol{x}^2n_\infty \) ...
Definition: vsr_generic_op.h:1118
static Mot mot(const Dll &dll)
Generate a vsr::cga::Motor from a vsr::cga::DualLine Axis.
static Pair pair(const DualSphere &s, const Vec &v)
constructs a Pair on Sphere s in v direction
auto pairOnSphere
a pair on dual sphere
Definition: vsr_cga3D_op.h:558
static Point loc(const A &a, const Point &p, bool dual)
Location of flat (shorthand)three-letter version of cga::Flat::location.
Definition: vsr_cga3D_round.h:523
core namespaced operations that are metric-agnostic
static constexpr bool sign(const A &a, const A &b)
Sign of A with Respect to B.
Definition: vsr_cga3D_op.h:82
NPar< 5 > Par
Pair
Definition: vsr_cga3D_types.h:73
auto pointOnSphere
a single point on dual sphere s at theta t and phi p
Definition: vsr_cga3D_op.h:562
static GATrs< A > trs(const Multivector< A, B > &a)
Generate translation from any type as exponential of a direction vector.
Definition: vsr_generic_op.h:401
static Bst bst(const A &tnv, const Vec &vec, T t)
Generate a Translated Transversion.
Definition: vsr_cga3D_op.h:227
static Vec Pos(const Dlp &s)
Position of Dlp.
Generators and Logarithms Optimized for 3D Conformal Geometric Algebra.
Definition: vsr_cga3D_op.h:119
static constexpr auto reject(const A &a, const B &b) -> auto
Rejection of A from B.
the versor library namespace
Definition: vsr_algebra.h:29
static Trv trv(const A &a)
vsr::cga::Transversor from any type
Definition: vsr_cga3D_op.h:142
auto pointOnLine
Point on line closest to another point v.
Definition: vsr_cga3D_op.h:541
static Trs translator(const A &a)
vsr::cga::Translator from any type
Definition: vsr_cga3D_op.h:139
static auto trv(const Multivector< A, B > &a) -> auto
Generate Local Boost at origin as exponential of a TangentVector vsr::GATnv
static Trs trs(const A &a)
vsr::cga::Translator from any type
Definition: vsr_cga3D_op.h:136
static Point null(const Vec &v)
Null Point from a vec.
auto pointOnCircle
a single point on circle c at theta t
Definition: vsr_cga3D_op.h:546
static Point pointA(const Pair &pp)
First point of point pair pp.
auto pointsOnCircle
n points on circle c
Definition: vsr_cga3D_op.h:550
static Trv transversor(const A &a)
vsr::cga::Transversor from any type
Definition: vsr_cga3D_op.h:145
Extraction of axis-angle orientation and 3D position features from Multivectors.
Definition: vsr_cga3D_op.h:46
auto pointsOnSphere
many points on sphere (could use map func from gfx::data)
Definition: vsr_cga3D_op.h:566