32 namespace vsr {
namespace cga {
40 return target <= (src ^
Inf(1));
46 Pair par = ( dls ^ cir.dual()).dual();
73 auto meet = (da ^ db).dual();
76 auto line = tan ^ sur ^
Inf(1);
77 auto np =
Round::split ( ( line.dual() ^ sur).dual(), false );
85 auto line = p ^ da ^
Inf(1);
86 auto np =
Round::split( (line.dual() ^ da).dual(),
false);
93 if ( (p<=da)[0] > 0 )
return p;
94 auto line = p ^ da ^
Inf(1);
95 auto np =
Round::split( (line.dual() ^ da).dual(),
false);
102 if ( ( (p<=da)[0] > 0 ) && ( (p<=db)[0] > 0 ) )
return p;
105 auto meet = (da ^ db).dual();
108 auto line = tan ^ sur ^
Inf(1);
109 auto np =
Round::split ( ( line.dual() ^ sur).dual(), false );
117 static Point Triple0 (
const Dls& da,
const Dls& db,
const Dls& dc){
126 auto line = cen ^ sur ^
Infinity(1);
127 auto meet = (line.dual() ^ sur).dual();
188 if (src==NULL) printf(
"null DistancePtr SET\n");
193 if (src==NULL) { printf(
"null DistancePtr\n");
return Dls(); }
206 virtual void onEval(
double amt) = 0;
210 Point eval(
double amt=0){
215 void setResult(
const Point& p){
259 set(target,ra,rb,rc,m,p);
268 if (ra==NULL || rb==NULL || rc==NULL) printf(
"null rig3 set\n");
311 Rigid() : bCalc(false), bTriple(true), ra(NULL), rb(NULL), rc(NULL) {}
313 Rigid(
const Pnt& res ) : bTriple(true), ra(NULL), rb(NULL), rc(NULL) {
331 set(target,pa,pb,pc,m);
337 ra = pa; rb = pb; rc = pc;
347 ra = pa; rb = pb; rc = pc;
353 ra->
child.push_back(
this); rb->
child.push_back(
this); rc->
child.push_back(
this);
359 mtn =m; bCalc=
true; bTriple=
false;
360 ra=pa; rb=pb;rc=
this;
366 ra->
child.push_back(
this); rb->
child.push_back(
this); rc->
child.push_back(
this);
370 if (ra!=NULL && rb!=NULL && rc!=NULL) bCalc =
true;
374 return (
da()^db()).dual();
377 return (db()^dc()).dual();
379 void orbitA(
float amt){
382 void orbitB(
float amt){
390 for (
auto& i : child) i -> down();
391 (*ra).up(); (*rb).up(); (*rc).up();
393 result = bTriple ?
Constrain::Triple(
da(),db(),dc(),mtn) : Constrain::Planar(da(),db(),dc(),mtn);
401 result = bTriple ?
Constrain::Triple(
da(),db(),dc(),mtn) : Constrain::Planar(da(),db(),dc(),mtn);
409 for (
auto& i : child) {
419 return (
da() ^ db() ^ dc() ).dual();
423 void satisfy(
int max=20){
424 auto& pa = *da.
src;
auto& pb = *db.
src;
auto& pc = *dc.
src;
427 while ( rs < -.0001 && iter < max ){
458 return (da()^db()).dual();
461 bool inside(
const Point& p){
462 return ( (p<=da())[0] > 0 ) && ( (p<=db())[0] > 0 );
470 bool bMtn,bCalc,bReCalc;
474 vector<Rigid2*> child;
477 Rigid2() : bCalc(false), bReCalc(false) {}
480 void set(
const Pnt& res){
481 bCalc=
false; bReCalc=
false;
486 void add(Rigid2 *pa, Rigid2 *pb,
bool m){
488 bCalc=
true; bReCalc=
true;
495 p.da.
set(pa->result,result);
496 p.db.
set(pb->result,result);
499 pa->child.push_back(
this);
501 parents.push_back(p);
514 void reset(){ bCalc=
true; bReCalc=
true; iter=0; }
520 for(
auto& i : parents){
532 for(
auto& i : parents){
539 void satisfy_old(Rigid2 * r){
544 while(bRepeat && (iter<10) ){
547 for(
auto& i : parents){
548 if ( (r==i.ra) || (r==i.rb) ){
549 bool bCocircular = ( fabs( (result <= i.meet()).wt() ) < .001);
561 bool hasA(Rigid2 * r){
562 for (
auto& i : parents){
563 if (r==i.ra)
return true;
568 bool hasB(Rigid2 * r){
569 for (
auto& i : parents){
570 if (r==i.rb)
return true;
577 void satisfy_forward(Rigid2 * r){
579 for(
auto& i : parents){
586 void satisfy_backward(Rigid2 * r){
588 for(
auto& i : parents){
596 float error(Rigid2 * r){
597 float tf=0;
bool bFound=
false;
598 for (
auto& i : parents){
601 tf = fabs((result <= i.meet()).wt());
605 for (
auto& i : parents){
607 tf = fabs((result <= i.meet()).wt());
632 for (
auto& i : parents){
633 if (i.ra->error(
this)>.001){
643 vector<Rigid2*> satisfy(
int begin,
int end){
645 if (!parents.empty()){
650 for (
auto& i : parents){
657 bool bLoop = parents[0].ra->hasA(
this);
661 for (
int i=begin; i<=end;++i){
662 parents[i].ra->satisfy_forward(
this);
664 for(
int i =end; i >= begin; i-- ) {
665 parents[i].ra->satisfy_backward(
this);
667 tf = tr->error(
this);
668 }
while( (tf>.001) && (tIter < 10));
672 for (
int i=begin; i<=end;++i){
673 parents[i].ra->satisfy_forward(
this);
674 parents[i].rb->satisfy_forward(
this);
676 for(
int i =end; i >= begin; i-- ) {
677 parents[i].rb->satisfy_backward(
this);
678 parents[i].ra->satisfy_backward(
this);
681 tf = tr->error(
this);
682 }
while( (tf>.001) && (tIter < 10));
687 vector<Rigid2*> temp;
690 for (
auto& i : parents){
691 if(i.ra->bReCalc==
true) temp.push_back(i.ra);
695 bool bLoop = parents[0].ra->hasA(
this);
697 if(parents.back().rb->bReCalc==
true) temp.push_back(parents.back().rb);
698 parents.back().rb->bReCalc=
false;
706 void cascade(
int begin,
int end){
710 auto rp = satisfy(begin,end);
711 cout <<
"parents to solve: " << rp.size() << endl;
714 vector<Rigid2*> temp;
716 auto r = i->satisfy(0, i->parents.size()-1);
728 Cir circle(
int idx =0) {
return ( parents[idx].da() ^ parents[idx].db() ).dual(); }
745 void set(
const Pnt& res){
746 bCalc=
false; bReCalc=
false;
751 bCalc=
true; bReCalc=
true; iter=0;
760 void set(
const Point& p){
769 float distance(
const Point& p){
774 vector<Parent> parent;
778 void add(
Rig * r,
bool bStrut=
true){
784 p.rig->child.push_back(
this);
787 void modify(
Rig * r,
bool bStrut){
788 for (
auto& i : parent){
789 if (r==i.rig) i.bStrut=bStrut;
794 void satisfy(Rig * r){
796 for (
auto& i : parent){
799 if (r==i.rig) tCalc=
true;
801 for (
auto& j : i.rig->parent){
802 if (r==j.rig) tCalc=
true;
806 result = i.constrain(result);
818 for (
auto& i : child){
821 for (
auto& i : child){
static std::vector< Point > split(const Pair &pp)
Split Points from Point Pair.
bool bCalc
default calc is false until ra parents are set
Definition: vsr_rigid.h:291
A Rigid Contraint Node set by Two Distance Pointers.
Definition: vsr_rigid.h:222
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
bool bTriple
coplanar or not
Definition: vsr_rigid.h:294
bool mtn
mountain or valley
Definition: vsr_rigid.h:300
Methods for Evaluating Constrained Points using Intersections of Sphere-based Distances.
Definition: vsr_rigid.h:36
Dls operator()()
Evaluate Distance Constraint as a Dual Sphere.
Definition: vsr_rigid.h:192
NCir< 5 > Cir
Circle
Definition: vsr_cga3D_types.h:74
bool bCalc
whether to Evaluate
Definition: vsr_rigid.h:204
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
static DualSphere at(const Point &c, const Point &p)
Dual Round from Center and Point on Surface.
virtual void onEval(double amt)=0
evaluation implementation to be implemented by subclass
static Point Double(const Dls &da, const Dls &db, double amt)
two distances and a theta around their meet
Definition: vsr_rigid.h:52
Par Pair
Point Pair 2-blade \(\tau=p_a \wedge p_b=\{e_{12},e_{13},e_{23},e_{1}n_o,e_{2}n_o,e_{3}n_o,e_{1}n_\infty,e_{2}n_\infty,e_{3}n_\infty,n_{o}n_\infty\}\)
Definition: vsr_cga3D_types.h:129
static Line carrier(const Pair &p)
Carrier Flat of Pair.
NDls< 5 > Dls
DualSphere
Definition: vsr_cga3D_types.h:76
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
void set(Rigid *pa, Rigid *pb, Rigid *pc, bool m)
set from constraints Counter Clockwise
Definition: vsr_rigid.h:345
Inf Infinity
Null Infinity Blade: \(n_\infty\)
Definition: vsr_cga3D_types.h:125
static Point Planar(const Dls &da, const Dls &db, const Dls &dc, bool mtn)
planar constraint: two distances and a plane
Definition: vsr_rigid.h:65
bool bMtn
fold is a mountain fold
Definition: vsr_rigid.h:253
vector< Parents > parents
possibly many couples (one per valence)
Definition: vsr_rigid.h:473
static DualSphere sur(const A &s)
Dual Surround of a Direct or Dual Round Element (Shorthand)
Definition: vsr_cga3D_round.h:347
static Point loc(const A &s)
Location (normalizd) of a Round Element (shorthand)
Definition: vsr_cga3D_round.h:146
static Point Tangency(const Pnt &p, const Dls &da)
spherical tangency constrain, one distance and an original point (returns point on sphere closest to ...
Definition: vsr_rigid.h:84
double t
Distance t from Source.
Definition: vsr_rigid.h:176
DistancePtr da
three dual sphere distances
Definition: vsr_rigid.h:303
static DualSphere surround(const Pair &s)
Dual Surround of a Direct or Dual Pair.
Definition: vsr_rigid.h:442
Cir Circle
Direct Circle 3-blade \(\kappa=p_a \wedge p_b \wedge p_c\)
Definition: vsr_cga3D_types.h:130
vector< RigidNode * > mParent
parents which might need to be evaluated before this one
Definition: vsr_rigid.h:208
static Pair at(const Circle &r, const Point &p)
Tangent Element of A Circle at Point p.
static Point Tetral(const Dls &da, const Dls &db, const Dls &dc, bool mtn)
tetral constraint
Definition: vsr_rigid.h:61
NInf< 5 > Inf
Infinity
Definition: vsr_cga3D_types.h:68
void setResult(const Pnt &res)
set result
Definition: vsr_rigid.h:324
bool bCoplanar
result is coplanar with three constraints
Definition: vsr_rigid.h:254
Pnt Point
Null Vector \(p=\{e_1,e_2,e_3,n_o,n_\infty\}\)
Definition: vsr_cga3D_types.h:128
Rigid * ra
linked to three parents
Definition: vsr_rigid.h:306
static VSR_PRECISION rad(const T &t)
Squared Size of a DualSphere (result could be negative)
Definition: vsr_cga3D_round.h:203
Multivector & set(value_t v)
Set value of blade type IDX
static Point PointToCircle(const Point &p, const Circle &c)
constrain a point p to a circle c
Definition: vsr_rigid.h:122
vector< Rigid * > child
Has n children which depend on it.
Definition: vsr_rigid.h:309
Point result
Meet of parents.
Definition: vsr_rigid.h:445
the versor library namespace
Definition: vsr_algebra.h:29
Pnt orbit(VSR_PRECISION t, int idx=0)
get point at theta t around constraint orbit
Definition: vsr_rigid.h:731
static Point Tangency(const Pnt &p, const Dls &da, const Dls &db)
circle tangency constraint, two distances and an original point (closest to original) ...
Definition: vsr_rigid.h:71
Definition: vsr_rigid.h:453
static Point Tension(const Pnt &p, const Dls &da)
Tension tangency constrain, one distance and an original point (returns point on sphere closest to p ...
Definition: vsr_rigid.h:92
Point * src
Pointer to Point Source.
Definition: vsr_rigid.h:175
virtual void onEval(double amt)
evaluation implementation to be implemented by subclass
Definition: vsr_rigid.h:241
Holds a pointer to a source, and has a radius t, the operator() generates a dual sphere at source wit...
Definition: vsr_rigid.h:173
static Point Triple(const Dls &da, const Dls &db, const Dls &dc, bool mtn)
three distances, counter clockwise (deprecated, use Tetral)
Definition: vsr_rigid.h:57
A Rigid Constraint Node set by Three Distance Pointers.
Definition: vsr_rigid.h:288
void set(const Point &target, RigidNode *ra, RigidNode *rb, RigidNode *rc, bool m, bool p)
set from target and constraints Counter Clockwise
Definition: vsr_rigid.h:263
static VSR_PRECISION size(const DualSphere &s, bool bDual=true)
Squared Size of a DualSphere (result could be negative)
NPnt< 5 > Pnt
Point
Definition: vsr_cga3D_types.h:72
static Point point(VSR_PRECISION x, VSR_PRECISION y, VSR_PRECISION z)
Null Point from Coordinates.
Point result
result of constraint computation
Definition: vsr_rigid.h:741
void set(const Pnt &res)
set result
Definition: vsr_rigid.h:318
Pnt result
stored evaluated result of (*this)()
Definition: vsr_rigid.h:297
void set(const Pnt &target, Rigid *pa, Rigid *pb, Rigid *pc, bool m)
set from target and constraints Counter Clockwise
Definition: vsr_rigid.h:335
void set(Pnt &a, const Pnt &target)
Set constraint from source and target.
Definition: vsr_rigid.h:186
static Point location(const DualLine &f, const Point &p, bool dual=true)
Location of DualLine closest to Point p.
Definition: vsr_rigid.h:754
static DualSphere Distance(const Point &src, const Point &target)
Construct a Distance Constraint from a source and target.
Definition: vsr_rigid.h:39
static Point null(const Vec &v)
Null Point from a vec.
static Point Tension(const Pnt &p, const Dls &da, const Dls &db)
tension constraint from two distances
Definition: vsr_rigid.h:100
Definition: vsr_rigid.h:248
Point result
stored evaluated result
Definition: vsr_rigid.h:202
Rig has n spherical constraints to satisfy (try using fabrik solver here)
Definition: vsr_rigid.h:739
virtual void onEval(double amt)
evaluation implementation to be implemented by subclass
Definition: vsr_rigid.h:279
Generic Rigid Constraint Node.
Definition: vsr_rigid.h:200