versor  3.0
C++11 library for Geometric algebra
vsr_fold.h
1 /*
2  *
3  * SEE ALSO vsr_rigid.h for alternative (uses pointers)
4  * see also vsr_fold_molecules for early implementations
5  *
6  *
7  */
8 
9 
10 #ifndef VSR_H_FOLD_INCLUDED
11 #define VSR_H_FOLD_INCLUDED
12 
13 #include "space/vsr_cga3D_op.h"
14 #include "form/vsr_set.h"
15 #include "form/vsr_rigid.h"
16 
17 namespace vsr{ namespace cga{
18 
19 
20 
21 /*-----------------------------------------------------------------------------
22  * FOLD LINE CONSTRUCTION
23  *-----------------------------------------------------------------------------*/
24 struct Fold {
25 
26  //Perimeter lines of a triangle
27  static vector<Line> Lines(const Point& a, const Point& b, const Point& c){
28  vector<Line> vl;
29  vl.push_back( (a ^ b ^ Inf(1)).runit() );
30  vl.push_back( (b ^ c ^ Inf(1)).runit() );
31  vl.push_back( (c ^ a ^ Inf(1)).runit() );
32  return vl;
33  }
34 
35  //Perimeter lines of a quadralateral
36  static vector<Line> Lines(const Point& a, const Point& b, const Point& c, const Point& d){
37  vector<Line> vl;
38  vl.push_back( (a ^ b ^ Inf(1)).runit() );
39  vl.push_back( (b ^ c ^ Inf(1)).runit() );
40  vl.push_back( (c ^ d ^ Inf(1)).runit() );
41  vl.push_back( (d ^ a ^ Inf(1)).runit() );
42  return vl;
43  }
44 
45  //Perimeter lines of an arbitrary polygon
46  static vector<Line> Lines( const vector<Point>& src ){
47  vector<Line> vl;
48  for (int i = 0; i < src.size()-1; ++i){
49  vl.push_back( ( src[i] ^ src[i+1] ^ Inf(1) ).unit() );
50  }
51  vl.push_back( (src.back() ^ src[0] ^ Inf(1) ).unit() );
52  return vl;
53  }
54 
55  //Perimeter lines of an arbitrary polygon
56  static vector<Line> Lines( Point * src, int num ){
57  vector<Line> vl;
58  for (int i = 0; i < num -1; ++i){
59  vl.push_back( ( src[i] ^ src[i+1] ^ Inf(1) ).unit() );
60  }
61  vl.push_back( (src[num-1] ^ src[0] ^ Inf(1) ).unit() );
62  return vl;
63  }
64 
65  //Radial lines out from a center
66  static vector<Line> Lines( const Point& center, const vector<Point>& nodes){
67 
68  vector<Line> vl;
69  for (auto i : nodes){
70  vl.push_back( ( center ^ i ^ Inf(1) ).unit() );
71  }
72 
73  return vl;
74  }
75 
76 
77  static vector<Line> Bisect( const vector<Line>& lines ){
78  vector<Line> vl;
79  vl.push_back( (lines.back() - lines[0]).unit() );
80  for (int i = 0; i < lines.size()-1; ++i){
81  vl.push_back( ( lines[i] - lines[i+1] ).unit() );
82  }
83  return vl;
84  }
85 
86  static Point Meet ( const vector<Line>& lines) {
87  return Construct::meet( lines[0], lines[1] ) ;
88  }
89 
90  static Point Perpendicular( const Point& c, const Line& line){
91  return Flat::loc(line, c, false).null();
92  }
93 
94  static vector<Point> Perpendiculars( const Point& c, const vector<Line>& lines){
95  vector<Point> vp;
96 
97  for (auto i : lines){
98  vp.push_back( Flat::loc(i, c, false).null() ); //location of point closest to line
99  }
100 
101  return vp;
102  }
103 
104 
105  static vector<Circle> Circles( const vector<Point>& src, const vector<Line>& crease ){
106  vector<Circle> vc;
107  for (int i = 0; i < src.size(); ++i) {
108  vc.push_back( src[i] ^ crease[i].dual() );
109  }
110 
111  return vc;
112  }
113 
114 
115 };
116 
117 
118 } } //vsr::cga
119 
120 #endif
121 
static Circle meet(const Dls &s, const Dls &d)
circle intersection of dual spheres
Common Operations Specific to CGA3D.
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
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 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
NInf< 5 > Inf
Infinity
Definition: vsr_cga3D_types.h:68
the versor library namespace
Definition: vsr_algebra.h:29
Definition: vsr_fold.h:24