37 T tp = p.reflect( i );
40 res.push_back( tp.reflect( ops[0] ) );
56 using Trs =
typename V::space::translator;
59 vector<decltype(V()*V())>
sops;
60 vector<decltype(V()*V()*V())>
tops;
61 vector<decltype(V()*Trs())>
gops;
62 vector<decltype(V()*V()*Trs())>
scrops;
65 Group( vector<V> v ) : ops(v) {}
74 T tp = p.reflect( i.unit() );
77 res.push_back( tp.reflect( ops[0].unit() ) );
97 res.push_back( tg.reflect( gops[0] ) );
100 T tp = tg.reflect( j.unit() );
102 res.push_back( tp.reflect( ops[0].unit() ) );
114 auto tRes = (*this)(i);
115 for (
auto& j : tRes){
131 typedef decltype( V() ^ V() )
Biv;
138 PointGroup2D(
int p,
bool pin =
true) : mP(p), bPin(pin) {
140 b = V::x.rot( Biv::xy * PIOVERTWO/p );
141 calcOps(a.unit(), b.unit());
144 void calcOps(
const V& ta,
const V& tb){
148 if (bPin) this->
ops = Root::System(ta,tb);
152 for (
int i=0;i<
mP;++i){
153 this->
sops.push_back(trot);
167 using Trs =
typename V::space::translator;
168 using Vec =
typename V::space::vector;
170 typedef decltype( V() ^ V() ) Biv;
183 SpaceGroup2D(
int p,
float ratio = 1.0,
bool pin=
true,
int div = 1,
bool ga=
false,
bool gb=
false)
192 this->
gops.push_back( this->a *
Gen::trs( Vec::y * .5) );
198 this->
ops.push_back(this->b);
199 this->
gops.push_back( this->a *
Gen::trs(this->b * .5) );
202 this->
ops.pop_back();
203 this->
gops.push_back( this->b *
Gen::trs(this->a * .5) );
207 this->b = this->a + (this->a).rot( Biv::xy * PIOVERTWO/2);
210 this->
ops.push_back(this->b.unit());
211 this->
ops.push_back(this->b.reflect(this->a).unit());
212 this->
gops.push_back( this->a *
Gen::trs((this->b - this->a) * .5) );
216 this->b = this->a + this->a.rot( Biv::xy * PIOVERTWO/3);
223 Vec vec(
float x,
float y){
224 if (this->mP!=1)
return this->a*x*mRatioX + this->b*y*mRatioY;
225 else return this->a*x + Vec::y*y;
233 vector<T> apply(
const T& motif,
int x,
int y){
235 auto tmp = (*this)(motif);
238 for (
auto& i : tmp ){
239 for (
int j=-x/2.0;j<x/2.0;++j){
240 for (
int k=-y/2.0;k<y/2.0;++k){
241 for (
int m =0;m<mDiv;++m){
242 float t = (float)m/mDiv;
244 res.push_back( i.trs( vec(j,k) + vec(t,t) ) );
254 vector<T>
apply(
const vector<T>& motif,
int x,
int y){
256 for (
auto& i : motif){
257 vector<T> tRes = apply(i,x,y);
258 for (
auto& j : tRes) res.push_back(j);
265 vector<T>
hang(
const T& motif,
int x,
int y){
267 for (
int j=-x/2.0;j<x/2.0;++j){
268 for (
int k=-y/2.0;k<y/2.0;++k){
269 for (
int m =0;m<mDiv;++m){
270 float t = (float)m/mDiv;
271 res.push_back( motif.trs( vec(j,k) + vec(t,t) ) );
279 vector<T>
hang(
const vector<T>& motif,
int x,
int y){
281 for (
auto& i : motif){
282 for (
int j=-x/2.0;j<x/2.0;++j){
283 for (
int k=-y/2.0;k<y/2.0;++k){
284 for (
int m =0;m<mDiv;++m){
285 float t = (float)m/mDiv;
286 res.push_back( i.trs( vec(j,k) + vec(t,t) ) );
297 template<
int DIM,
class V >
300 static const int Dim = DIM;
303 typedef typename V::template BType< typename V::Mode::Vec > Vec;
304 typedef typename V::template BType< typename V::Mode::Biv > Biv;
308 Vec& operator[](
int idx) {
return vec[idx]; }
309 Vec operator[](
int idx)
const {
return vec[idx]; }
311 Vec at() {
return Vec(); }
313 template<
class ... T>
314 Vec at(
int x, T...v ){
315 int idx = DIM - (
sizeof...(v) + 1 );
316 return vec[idx] * x + at(v...);
322 template<
class ... T>
323 void set(
int x, T ... xs){
324 using TE =
typename V::template BType<
typename V::Mode::template e< ( DIM - (
sizeof...(T) )) > >;
325 int idx = DIM - (
sizeof...(T) + 1);
326 Biv biv = V::x ^ TE(1);
327 vec[idx] = V::x.rot( biv * PIOVERTWO/x );
333 template<
class ... T>
348 int type, opIdx, resIdx;
360 PointGroup3D(
int p,
int q,
bool abar=
false,
bool bbar=
false,
bool abbar=
false) {
367 double tb = PIOVERTWO;
368 double ta = PI/(int)p;
369 double tc = PI/(int)q;
378 double tA = acos( (ca-(cb*cc))/(sb*sc) );
379 double tC = acos( (cc-(ca*cb))/(sa*sb) );
382 auto bivA = (a ^ c).rot( a.duale() * tC / 2.0 );
383 auto bivC = (a ^ c).rot( c.duale() * tA / 2.0 );
386 b = (bivA.duale() ^ bivC.duale()).duale().unit();
389 if (!abar && !bbar && !abbar ){
392 this->
tops.push_back(a*b*c);
393 }
else if ( abar && bbar ) {
394 this->
sops.push_back(a*b);
395 this->
sops.push_back(b*c);
397 this->
sops.push_back(a*b);
398 this->
ops.push_back(c);
400 this->
sops.push_back(b*c);
401 this->
ops.push_back(a);
411 vector<T> operator() (
const T& p){
416 vector<T> operator() (
const vector<T>& p){
427 void seed(
const Vec& vec=Vec(.213,.659,1.6967).unit() ){
433 for(
auto& i : this->
ops){
434 auto tvec = vec.reflect(i);
438 for(
auto& i : this->
sops){
439 auto tvec = vec.spin(i);
447 bool keepgoing=
true;
int iter=0;
int maxiter = 100;
448 while(keepgoing && iter<maxiter){
454 for(
int i =0; i<this->ops.size(); ++i){
455 for (
int j=0;j<tn;++j){
457 auto tvec = tv[j].reflect( this->ops[i] );
469 opIdx.push_back( {1,i,j} );
476 for(
int i =0; i<this->sops.size(); ++i){
477 for (
int j=0;j<tn;++j){
479 auto tvec = tv[j].spin( this->sops[i] );
491 opIdx.push_back( {0,i,j} );
502 vector<T> apply(
const T& p){
506 for(
auto& i : this->ops){
507 res.push_back(p.reflect(i));
511 for(
auto& i : this->sops){
512 res.push_back(p.spin(i));
515 for (
auto& i : opIdx){
516 auto tmp = i.type ? res[ i.resIdx ].reflect( this->ops[ i.opIdx] )
517 : res[ i.resIdx ].spin( this->sops[ i.opIdx] );
526 auto ab() RETURNS ( a * b )
527 auto ac() RETURNS ( a * c )
528 auto bc() RETURNS ( b * c )
542 using Trs =
typename V::space::translator;
549 Primitive, Body, AFace, CFace, HFace, Face2, Face3, Rhombo
554 None, AxialA, AxialB, AxialC, Diagonal, Diamond
566 LatticeType mLatticeType;
574 bool abar=
false,
bool bbar=
false,
bool abbar=
false,
575 LatticeType lattice = Primitive,
576 Vec ratio= Vec(1,1,1),
582 mLatticeType(lattice),
597 switch(mGlide.a.type){
600 replace.push_back(0);
601 auto trs =
Gen::trs( ( (mGlide.a.bInvert) ? (this->a - this->b) : (this->b) ) * .5 );
602 this->
gops.push_back( this->a * trs );
607 replace.push_back(0);
608 auto trs =
Gen::trs( ( (mGlide.a.bInvert) ? (this->a - this->c) : (this->c) ) * .5 );
609 this->
gops.push_back( this->a * trs );
614 replace.push_back(0);
615 auto trs =
Gen::trs( ( (mGlide.a.bInvert) ? (this->a - (this->b+this->c)) : (this->b+this->c) ) * .5 );
616 this->
gops.push_back( this->a * trs );
622 switch(mGlide.b.type){
626 switch(mGlide.c.type){
630 for (
int i = 0; i < this->ops.size(); ++i){
644 vector<T> operator() (
const T& p){
649 vector<T> apply(
const T& p ){
650 auto pg = PointGroup3D<V>::apply(p);
652 for (
int i=0;i<pg.size();++i){
653 for (
auto& j : this->
gops ){
654 pg.push_back( pg[i].reflect(j) );
656 for (
auto& j : this->
scrops ){
657 pg.push_back( pg[i].spin(j) );
665 vector<T> apply(
const vector<T>& p){
680 Vec
vec(
float x,
float y,
float z){
681 return this->a*x * mRatio[0] + this->b*y * mRatio[1] + this->c*z * mRatio[2];
689 vector<T>
hang(
const T& motif,
int x,
int y,
int z){
692 switch( mLatticeType ){
695 for (
int j=-x/2.0;j<x/2.0;++j){
696 for (
int k=-y/2.0;k<y/2.0;++k){
697 for (
int l=-z/2.0;l<z/2.0;++l){
698 res.push_back( motif.trs( vec(j,k,l) ) );
706 for (
int j=-x/2.0;j<x/2.0;++j){
707 for (
int k=-y/2.0;k<y/2.0;++k){
708 for (
int l=-z/2.0;l<z/2.0;++l){
709 res.push_back( motif.trs( vec(j,k,l) ) );
710 res.push_back( motif.trs( vec(j,k,l) + vec(.5,.5,.5) ) );
718 for (
int j=-x/2.0;j<x/2.0;++j){
719 for (
int k=-y/2.0;k<y/2.0;++k){
720 for (
int l=-z/2.0;l<z/2.0;++l){
721 res.push_back( motif.trs( vec(j,k,l) ) );
722 res.push_back( motif.trs( vec(j,k,l) + vec(0,.5,.5) ) );
730 for (
int j=-x/2.0;j<x/2.0;++j){
731 for (
int k=-y/2.0;k<y/2.0;++k){
732 for (
int l=-z/2.0;l<z/2.0;++l){
733 res.push_back( motif.trs( vec(j,k,l) ) );
734 res.push_back( motif.trs( vec(j,k,l) + vec(.5,.5,0) ) );
742 for (
int j=-x/2.0;j<x/2.0;++j){
743 for (
int k=-y/2.0;k<y/2.0;++k){
744 for (
int l=-z/2.0;l<z/2.0;++l){
745 res.push_back( motif.trs( vec(j,k,l) ) );
746 res.push_back( motif.trs( vec(j,k,l) + vec(.3333333,.3333333,0) ) );
747 res.push_back( motif.trs( vec(j,k,l) + vec(.6666666,.6666666,0) ) );
755 for (
int j=-x/2.0;j<x/2.0;++j){
756 for (
int k=-y/2.0;k<y/2.0;++k){
757 for (
int l=-z/2.0;l<z/2.0;++l){
758 res.push_back( motif.trs( vec(j,k,l) ) );
759 res.push_back( motif.trs( vec(j,k,l) + vec(.3333333,.3333333,.3333333) ) );
760 res.push_back( motif.trs( vec(j,k,l) + vec(.6666666,.6666666,.6666666) ) );
768 for (
int j=-x/2.0;j<x/2.0;++j){
769 for (
int k=-y/2.0;k<y/2.0;++k){
770 for (
int l=-z/2.0;l<z/2.0;++l){
771 res.push_back( motif.trs( vec(j,k,l) ) );
772 for (
int m =1;m<2;++m){
773 float t = (float)m/2;
774 res.push_back( motif.trs( vec(j,k,l) + vec(t,t,0) ) );
775 res.push_back( motif.trs( vec(j,k,l) + vec(0,t,t) ) );
776 res.push_back( motif.trs( vec(j,k,l) + vec(-t,0,t) ) );
785 for (
int j=-x/2.0;j<x/2.0;++j){
786 for (
int k=-y/2.0;k<y/2.0;++k){
787 for (
int l=-z/2.0;l<z/2.0;++l){
788 res.push_back( motif.trs( vec(j,k,l) ) );
789 for (
int m =1;m<3;++m){
790 float t = (float)m/3;
791 res.push_back( motif.trs( vec(j,k,l) + vec(t,t,0) ) );
792 res.push_back( motif.trs( vec(j,k,l) + vec(0,t,t) ) );
793 res.push_back( motif.trs( vec(j,k,l) + vec(-t,0,t) ) );
806 vector<T> hang(
const vector<T>& motif,
int x,
int y,
int z ){
808 for (
auto& i : motif){
809 auto tmp = hang(i,x,y,z);
810 for (
auto& j : tmp) res.push_back(j);
SimpleGroup(vector< V > v)
Instantiate with unit length pin group.
Definition: vsr_group.h:30
vector< T > hang(const T &motif, int x, int y, int z)
Hang a motif on a Lattice of dimensions x,y,z
Definition: vsr_group.h:689
V b
Generators.
Definition: vsr_group.h:133
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
void set()
END case.
Definition: vsr_group.h:320
ND lattice, on a metric specified by V's type. Not a group, but a group can be made from it...
Definition: vsr_group.h:298
bool bPin
Pin or Spin.
Definition: vsr_group.h:136
Definition: vsr_group.h:129
Definition: vsr_group.h:345
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
vector< T > operator()(const T &p)
Applies all operators on p motif and returns results.
Definition: vsr_group.h:34
vector< T > operator()(const T &p)
Applies all operators on p motif and returns results.
Definition: vsr_group.h:70
static bool Compare(const V &a, const V &b, bool ref=true)
Utility function to compare two unit vectors (looks at dot product, or norm of diff...)
Definition: vsr_root.h:125
vector< decltype(V()*V()*V())> tops
Triple Reflection (abbar 3d group)
Definition: vsr_group.h:60
vector< V > ops
Pin Operators (Vec, etc)
Definition: vsr_group.h:58
Definition: vsr_group.h:561
Vec vec(float x, float y, float z)
Calculate a vector transformation basice on generators and ratio
Definition: vsr_group.h:680
SpaceGroup2D(int p, float ratio=1.0, bool pin=true, int div=1, bool ga=false, bool gb=false)
Constructor.
Definition: vsr_group.h:183
core namespaced operations that are metric-agnostic
vector< T > operator()(const vector< T > &p)
Applies all operations on a vector of type T.
Definition: vsr_group.h:111
vector< T > apply(const vector< T > &motif, int x, int y)
Apply to a vector of elements.
Definition: vsr_group.h:254
vector< decltype(V()*V())> sops
Spin Operators (Rot, etc)
Definition: vsr_group.h:59
vector< T > hang(const T &motif, int x, int y)
Don't apply operations, just hang on lattice points.
Definition: vsr_group.h:265
void set(int x, T...xs)
Recursively set each idx.
Definition: vsr_group.h:323
Lattice(int x, T...xs)
Feed in a list of ratios.
Definition: vsr_group.h:334
vector< T > hang(const vector< T > &motif, int x, int y)
Don't apply operations, just hang on lattice points.
Definition: vsr_group.h:279
typename V::space::translator Trs
Trs is the translator type of whatever conformal metric we are in.
Definition: vsr_group.h:56
int numSimple
number of simple roots used to generate group
Definition: vsr_group.h:52
vector< V > ops
Pin Operators (Vec, etc)
Definition: vsr_group.h:27
the versor library namespace
Definition: vsr_algebra.h:29
Definition: vsr_group.h:347
NBiv< 5 > Biv
Bivector
Definition: vsr_cga3D_types.h:63
int mP
Symmetry Group.
Definition: vsr_group.h:135
Definition: vsr_group.h:556
Definition: vsr_group.h:165
Definition: vsr_group.h:539
static Trs trs(const A &a)
vsr::cga::Translator from any type
Definition: vsr_cga3D_op.h:136
vector< decltype(V()*V()*Trs())> scrops
Screw Operators (Motor)
Definition: vsr_group.h:62
A Group of Operations called with group( sometype t ) or group( vector t) V are versors any...
Definition: vsr_group.h:50
vector< decltype(V()*Trs())> gops
Glide Operators.
Definition: vsr_group.h:61
Simple Reflection Group (no translating or gliding spinors)
Definition: vsr_group.h:26