versor  3.0
C++11 library for Geometric algebra
vsr_cga3D_round.h
1 
20 #ifndef vsr_cga3D_round_INC
21 #define vsr_cga3D_round_INC
22 
23 
24 #include "detail/vsr_generic_op.h"
25 #include "space/vsr_cga3D_types.h"
26 
27 namespace vsr { namespace cga {
28 
42  struct Round {
43 
45 
47  static Point null ( const Vec& v);
48 
51  static Point null ( const Point& v);
52 
55  static Point null(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z);
56 
59  static Point point(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z);
61 
63 
73  static DualSphere dualSphere( VSR_PRECISION r, VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z);
74 
79  static DualSphere dls( VSR_PRECISION r, VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z ){
80  return dualSphere(r,x,y,z);
81  }
82 
87  static DualSphere dls( const Vec& v, VSR_PRECISION r = 1.0 );
88 
93  static DualSphere sphere( const Point& v, VSR_PRECISION r = 1.0 );
94 
99  static DualSphere dls( const Point& p, VSR_PRECISION r = 1.0 );
101 
103 
108  static Point center( const DualSphere& s);
109  /*
110  Simple Center of A Pair (not normalized -- use loc or location method instead)
111  */
112  static Point center( const Pair& s);
113  /*
114  Simple Center of A Circle (not normalized -- use loc or location method instead)
115  */
116  static Point center( const Circle& s);
117  /*
118  Simple Center of A Sphere (not normalized -- use loc or location method instead)
119  */
120  static Point center( const Sphere& s);
127  template<class A>
128  static Point cen( const A& s) { return center(s); }
129 
135  template<class A>
136  static Point location(const A& s){ return null( cen(s) ); }
137 
145  template<class A>
146  static Point loc(const A& s){ return location(s); }
148 
150 
155  static VSR_PRECISION size( const DualSphere& s, bool bDual =true);
156 
162  static VSR_PRECISION size( const Pair& s, bool bDual=true);
163 
169  static VSR_PRECISION size( const Circle& s, bool bDual=false);
170 
176  static VSR_PRECISION size( const Sphere& s, bool bDual = false);
177 
183  static VSR_PRECISION dsize( const Point& dls );
184 
185 
188  static VSR_PRECISION radius( const DualSphere& s );
189 
192  static VSR_PRECISION radius( const Pair& s );
193 
196  static VSR_PRECISION radius( const Circle& s );
197 
200  static VSR_PRECISION radius( const Sphere& s );
201 
202 
203  template<class T> static VSR_PRECISION rad( const T& t) { return radius(t); }
204 
208  template<class A>
209  static VSR_PRECISION
210  curvature(const A& s){
211  VSR_PRECISION r = rad( s );
212  return (r==0) ? 10000 : 1.0 / rad(s);
213  }
214 
218  template<class T>
219  static VSR_PRECISION cur( const T& t) { return curvature(t); }
221 
222 
224 
228  static VSR_PRECISION squaredDistance(const Point& a, const Point b);
229 
230 
233  static VSR_PRECISION sqd(const Point& a, const Point b) { return squaredDistance(a,b); }
234 
236  static VSR_PRECISION distance(const Point& a, const Point b);
237 
239  static VSR_PRECISION dist( const Point& a, const Point& b) { return distance(a,b); }
241 
243 
247  static std::vector<Point> split(const Pair& pp);
248 
253  static std::vector<Point> splitLocation(const Pair& pp);
254 
260  static Point split(const Pair& pp, bool bFirst);
261 
265  static std::vector<Point> split( const Circle& nc ){
266  return split( nc.dual() );
267  }
269 
271 
277  static DirectionVector direction( const Pair& p );
278 
286  static DirectionBivector direction( const Circle& c );
287 
288 
295  static DirectionBivector direction( const Sphere& c );
296 
300  template<class A>
301  static auto dir( const A&s ) -> decltype(direction(s)) { return direction(s); }
303 
305 
310  static Line carrier(const Pair& p);
311 
318  static Plane carrier(const Circle& c);
319 
326  template<class A>
327  static auto car( const A& s) -> decltype(carrier(s)) { return carrier(s); }
329 
330 
334  static DualSphere surround( const Pair& s);
335 
339  static DualSphere surround( const Circle& s);
340 
346  template <class A>
347  static DualSphere sur( const A& s) { return surround(s); }
348 
361  static Pair produce(const DualSphere& dls, const Vec& v);
362 
375  static Circle produce(const DualSphere& dls, const Biv& b);
376 
377 // /*
378 // Creates a real / imaginary round from an imaginary / real round
379 // */
380 // template<class A>
381 // auto
382 // real(const A& s) RETURNS (
383 // produce(
384 // Round::dls( Round::loc( s ), -Round::rad( Round::sur( s ) ) ),
385 // typename A::space::origin(-1) <= Round::dir( s )
386 // )
387 // )
388 //
389 //
390 // /*
391 // Creates an imaginary round from an real round
392 // */
393 // template<class A>
394 // auto
395 // imag(const A& s) RETURNS (
396 // produce(
397 // Round::dls( Round::loc( s ), Round::rad( Round::sur( s ) ) ),
398 // typename A::space::origin(-1) <= Round::dir( s )
399 // )
400 // )
401 
407  static DualSphere at( const Point& c, const Point& p);
408 
413  static Point point(const DualSphere & dls, const Vec& flat);
414 
419  static Vec vec(const Circle& c, VSR_PRECISION theta = 0);
420 
424  static Pair pair(const Circle& c, VSR_PRECISION t);
425 
429  static Point point(const Circle& c, VSR_PRECISION t);
430 
431  };
432 
433 
442  struct Flat {
443 
445 
450  static DirectionVector direction( const Line& f);
451 
457  static DirectionBivector direction( const Plane& f);
458 
467  template<class A> static auto dir( const A& s ) -> decltype( direction(s) ) { return direction(s); }
469 
470 
472 
481  static Point location(const DualLine& f, const Point& p, bool dual=true);
482 
492  static Point location(const Line& f, const Point& p, bool dual=false);
493 
503  static Point location(const DualPlane& f, const Point& p, bool dual=true);
504 
514  static Point location(const Plane& f, const Point& p, bool dual=false);
515 
523  template<class A> static Point loc( const A& a, const Point& p, bool dual ) { return location(a,p); }
525 
531  static VSR_PRECISION wt(const DualLine& f, bool bDual=true);
532 
533 
535  static DualPlane plane( const Point& pnt, const DirectionVector& drv);
536 
538  static Line line( VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z );
539 
541  static Circle dline( VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z );
542 
543  };
544 
545 
546 
555  struct Tangent {
556 
564  static Pair at( const Circle& r, const Point& p);
565 
566 
574  static Circle at( const Sphere& r, const Point& p);
575 
579  static VSR_PRECISION wt(const TangentVector& s);
580 
581 
585  static VSR_PRECISION wt(const TangentBivector& s);
586 
590  static VSR_PRECISION wt(const TangentTrivector& s);
591 
592 
593  };
594 
595 
596 
597 }} //vsr::cga::
598 
599 #endif /* ----- #ifndef vsr_cga3D_round_INC ----- */
static std::vector< Point > split(const Pair &pp)
Split Points from Point Pair.
static DualSphere dls(VSR_PRECISION r, VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Dual Sphere from Coordinate Center (shorthand)
Definition: vsr_cga3D_round.h:79
static DirectionVector direction(const Pair &p)
Direction of a Pair.
static Vec vec(const Circle &c, VSR_PRECISION theta=0)
Euclidean Vector of Circle at theta.
static std::vector< Point > splitLocation(const Pair &pp)
Split Points from Point Pair and normalize.
static DualSphere at(const Point &c, const Point &p)
Dual Round from Center and Point on Surface.
static DualSphere dualSphere(VSR_PRECISION r, VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Dual Sphere from Coordinate Center.
static Line line(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Direct Line at origin with coordinate v ...
static DualPlane plane(const Point &pnt, const DirectionVector &drv)
Dual Plane from Point and Direction.
static Point center(const DualSphere &s)
Simple Center of A Round (not normalized – use loc or location method instead)
static Line carrier(const Pair &p)
Carrier Flat of Pair.
static VSR_PRECISION dsize(const Point &dls)
Squared Size of Normalized Dual Sphere (faster than general case)
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
static VSR_PRECISION sqd(const Point &a, const Point b)
Squared distance between two points.
Definition: vsr_cga3D_round.h:233
static DualSphere sur(const A &s)
Dual Surround of a Direct or Dual Round Element (Shorthand)
Definition: vsr_cga3D_round.h:347
static auto car(const A &s) -> decltype(carrier(s))
Carrier Flat of Direct? Round Element (Shorthand)
Definition: vsr_cga3D_round.h:327
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
static Point loc(const A &s)
Location (normalizd) of a Round Element (shorthand)
Definition: vsr_cga3D_round.h:146
3D operations on Round types (Points, Point Pairs, Circles, Spheres)
Definition: vsr_cga3D_round.h:42
core namespaced operations that are metric-agnostic
static DirectionVector direction(const Line &f)
Direction of Line.
3D operations on Flat types
Definition: vsr_cga3D_round.h:442
static Point location(const A &s)
Location (normalized) of A Round Element (normalized) (Shorthand)
Definition: vsr_cga3D_round.h:136
static DualSphere surround(const Pair &s)
Dual Surround of a Direct or Dual Pair.
static Point cen(const A &s)
Simple Center of a Round Element (shorthand)
Definition: vsr_cga3D_round.h:128
static Pair at(const Circle &r, const Point &p)
Tangent Element of A Circle at Point p.
static auto dir(const A &s) -> decltype(direction(s))
Direction of Round Element (shorthand)
Definition: vsr_cga3D_round.h:301
static VSR_PRECISION rad(const T &t)
Squared Size of a DualSphere (result could be negative)
Definition: vsr_cga3D_round.h:203
static std::vector< Point > split(const Circle &nc)
Split A Circle into its dual point pair poles.
Definition: vsr_cga3D_round.h:265
static VSR_PRECISION curvature(const A &s)
Curvature of Round.
Definition: vsr_cga3D_round.h:210
static VSR_PRECISION squaredDistance(const Point &a, const Point b)
Squared distance between two points.
static VSR_PRECISION radius(const DualSphere &s)
Radius of DualSphere.
static VSR_PRECISION wt(const DualLine &f, bool bDual=true)
Weight of DualLine.
static VSR_PRECISION dist(const Point &a, const Point &b)
Distance between points a and b (shorthand)
Definition: vsr_cga3D_round.h:239
static VSR_PRECISION cur(const T &t)
Curvature of Round.
Definition: vsr_cga3D_round.h:219
the versor library namespace
Definition: vsr_algebra.h:29
3D operations on Tangent types
Definition: vsr_cga3D_round.h:555
static DualSphere sphere(const Point &v, VSR_PRECISION r=1.0)
Dual Sphere from Element FIRST and Radius.
static Pair produce(const DualSphere &dls, const Vec &v)
Pair From DualSphere and Euclidean subspace Bivector Note: Result will be imaginary if input DualSphe...
static VSR_PRECISION size(const DualSphere &s, bool bDual=true)
Squared Size of a DualSphere (result could be negative)
static Point point(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Null Point from Coordinates.
static VSR_PRECISION distance(const Point &a, const Point b)
Distance between points a and b.
static VSR_PRECISION wt(const TangentVector &s)
Weight of TangentVector.
static auto dir(const A &s) -> decltype(direction(s))
direction shorthand
Definition: vsr_cga3D_round.h:467
static Pair pair(const Circle &c, VSR_PRECISION t)
Point Pair on Direct Circle at angle t.
static Point location(const DualLine &f, const Point &p, bool dual=true)
Location of DualLine closest to Point p.
static Point null(const Vec &v)
Null Point from a vec.
static Circle dline(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Direct hyperbolic d-Line at origin with coordinate v ...