- Timestamp:
- 02/20/14 17:49:28 (11 years ago)
- Location:
- cpp/frams
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genooper_test.cpp
r138 r139 26 26 gm.p_report(NULL, NULL); 27 27 28 const char* src = (argc > 1) ? argv[1] : "/*9*/ RRR";28 const char* src = (argc > 1) ? argv[1] : "/*9*/UUU"; 29 29 Geno gsrc(src, -1, "First"); 30 30 printGenAndTitle(gsrc, "source genotype (gsrc)"); … … 42 42 printGenAndTitle(ginvalid, "invalid"); 43 43 44 Geno fixed = gm.Validate(ginvalid);45 printGenAndTitle( fixed, "validated");44 Geno gvalidated = gm.Validate(ginvalid); 45 printGenAndTitle(gvalidated, "validated"); 46 46 47 printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*) fixed.getGene()));47 printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*)gvalidated.getGene())); 48 48 49 49 return 0; -
cpp/frams/_demos/part_shapes.cpp
r121 r139 9 9 int main() 10 10 { 11 Model *m=new Model;12 Part *p1,*p2;13 Joint *j;11 Model m; 12 Part *p1, *p2; 13 Joint *j; 14 14 15 m->open();15 m.open(); 16 16 17 // chain of ellipsoids - subsequent parts are placed relative to the previous part's orientation and location18 p1=m->addNewPart(Part::SHAPE_ELLIPSOID); //initial part19 p1->scale=Pt3D(1.0,0.7,0.4);17 // chain of ellipsoids - subsequent parts are placed relative to the previous part's orientation and location 18 p1 = m.addNewPart(Part::SHAPE_ELLIPSOID); //initial part 19 p1->scale = Pt3D(1.0, 0.7, 0.4); 20 20 21 Orient rotation=Orient_1; //must be initialized explicitly because the default Orient constructor does not initialize anything22 rotation.rotate(Pt3D(0.1,0.2,0.3));21 Orient rotation = Orient_1; //must be initialized explicitly because the default Orient constructor does not initialize anything 22 rotation.rotate(Pt3D(0.1, 0.2, 0.3)); 23 23 24 for(int N=10;N>0;N--,p1=p2)24 for (int N = 10; N > 0; N--, p1 = p2) 25 25 { 26 p2=m->addNewPart(Part::SHAPE_ELLIPSOID); 27 p2->scale=p1->scale*0.9; //each part is smaller than its predecessor 28 29 Pt3D advance(p1->scale.x,0,0); //advance by previous part's ellipsoid x radius 30 p2->p = p1->p + p1->o.transform(advance); //advance vector transformed by p1 orientation == in p1 local coordinates 31 p2->setOrient(p1->o.transform(rotation)); //rotation transformed by p1 orientation 26 p2 = m.addNewPart(Part::SHAPE_ELLIPSOID); 27 p2->scale = p1->scale*0.9; //each part is smaller than its predecessor 32 28 33 m->addNewJoint(p1,p2,Joint::SHAPE_SOLID); //all parts must be connected 29 Pt3D advance(p1->scale.x, 0, 0); //advance by previous part's ellipsoid x radius 30 p2->p = p1->p + p1->o.transform(advance); //advance vector transformed by p1's orientation (i.e., in p1's local coordinates) 31 p2->setOrient(p1->o.transform(rotation)); //rotation transformed by p1's orientation 32 33 m.addNewJoint(p1, p2, Joint::SHAPE_SOLID); //all parts must be connected 34 34 } 35 35 36 // chain of cyllinders - line segments between points calculated from the parametric formula P(a)=(2-2*cos(a),2*sin(a)) (circle with r=2)37 Pt3D prev,next;38 p1=m->getPart(0);39 for(float a=0;a<M_PI;a+=M_PI/10)36 // chain of cyllinders - line segments between points calculated from the parametric formula P(a)=(2-2*cos(a),2*sin(a)) (circle with r=2) 37 Pt3D prev, next; 38 p1 = m.getPart(0); 39 for (float a = 0; a<M_PI; a += M_PI / 10) 40 40 { 41 Pt3D next(2-2*cos(a),0,2*sin(a));42 if (a>0)41 Pt3D next(2 - 2 * cos(a), 0, 2 * sin(a)); 42 if (a>0) 43 43 { 44 p2=m->addNewPart(Part::SHAPE_CYLINDER);45 p2->setPositionAndRotationFromAxis(prev,next);46 p2->scale=Pt3D(prev.distanceTo(next)*0.5,0.05,0.05);// distance*0.5 because scale is "radius", not cylinder length44 p2 = m.addNewPart(Part::SHAPE_CYLINDER); 45 p2->setPositionAndRotationFromAxis(prev, next); 46 p2->scale = Pt3D(prev.distanceTo(next)*0.5, 0.05, 0.05);// distance*0.5 because scale is "radius", not cylinder length 47 47 48 m->addNewJoint(p1,p2,Joint::SHAPE_SOLID); //all parts must be connected48 m.addNewJoint(p1, p2, Joint::SHAPE_SOLID); //all parts must be connected 49 49 } 50 p1=p2;51 prev=next;50 p1 = p2; 51 prev = next; 52 52 } 53 53 54 m->close();55 puts((const char*)m->getF0Geno().toString());56 // the genotype can be fed directly to the genotype viewer, like this:57 // part_shapes | theater -g -vpart_shapes -54 m.close(); 55 puts((const char*)m.getF0Geno().toString()); 56 // the genotype can be fed directly to the genotype viewer, like this: 57 // part_shapes | theater -g -vpart_shapes - 58 58 } -
cpp/frams/genetics/defgenoconv.cpp
r121 r139 7 7 #include GEN_CONFIG_FILE 8 8 9 #ifdef USE_GENCONV_ F109 #ifdef USE_GENCONV_f10 10 10 #include "f1/conv_f1.h" 11 11 #endif 12 #ifdef USE_GENCONV_ F2012 #ifdef USE_GENCONV_f20 13 13 #include "f2/conv_f2.h" 14 14 #endif 15 #ifdef USE_GENCONV_ F3215 #ifdef USE_GENCONV_f32 16 16 #include "f3/conv_f3.h" 17 17 #endif 18 #ifdef USE_GENCONV_ F4018 #ifdef USE_GENCONV_f40 19 19 #include "f4/conv_f4.h" 20 20 #endif 21 #ifdef USE_GENCONV_ F41_TEST21 #ifdef USE_GENCONV_f41_TEST 22 22 #include "f4/conv_f4.h" 23 23 #endif 24 #ifdef USE_GENCONV_ F5024 #ifdef USE_GENCONV_f50 25 25 #include "f5/conv_f5.h" 26 26 #endif 27 #ifdef USE_GENCONV_ F6027 #ifdef USE_GENCONV_f60 28 28 #include "f6/geno_f6.h" 29 29 #endif 30 #ifdef USE_GENCONV_ F7030 #ifdef USE_GENCONV_f70 31 31 #include "f7/conv_f7.h" 32 32 #endif 33 #ifdef USE_GENCONV_ F8133 #ifdef USE_GENCONV_f81 34 34 #include "f8/conv_f8tof1.h" 35 35 #endif 36 #ifdef USE_GENCONV_ F9036 #ifdef USE_GENCONV_f90 37 37 #include "f9/conv_f9.h" 38 #endif 39 #ifdef USE_GENCONV_fF0 40 #include "fF/conv_fF.h" 38 41 #endif 39 42 40 43 DefaultGenoConvManager::DefaultGenoConvManager() 41 44 { 42 #ifdef USE_GENCONV_ F1043 addConverter(new GenoConv_F1());45 #ifdef USE_GENCONV_f10 46 addConverter(new GenoConv_f1()); 44 47 #endif 45 #ifdef USE_GENCONV_ F2046 addConverter(new GenoConv_F20());48 #ifdef USE_GENCONV_f20 49 addConverter(new GenoConv_f20()); 47 50 #endif 48 #ifdef USE_GENCONV_ F3249 addConverter(new GenoConv_F32());51 #ifdef USE_GENCONV_f32 52 addConverter(new GenoConv_f32()); 50 53 #endif 51 #ifdef USE_GENCONV_ F4052 addConverter(new GenoConv_F40());54 #ifdef USE_GENCONV_f40 55 addConverter(new GenoConv_f40()); 53 56 #endif 54 #ifdef USE_GENCONV_ F41_TEST55 addConverter(new GenoConv_F41_TestOnly());57 #ifdef USE_GENCONV_f41_TEST 58 addConverter(new GenoConv_f41_TestOnly()); 56 59 #endif 57 #ifdef USE_GENCONV_ F5058 addConverter(new GenoConv_F50);60 #ifdef USE_GENCONV_f50 61 addConverter(new GenoConv_f50); 59 62 #endif 60 #ifdef USE_GENCONV_ F6061 addConverter(new GenoConv_F60);63 #ifdef USE_GENCONV_f60 64 addConverter(new GenoConv_f60); 62 65 #endif 63 #ifdef USE_GENCONV_ F7064 addConverter(new GenoConv_F70);66 #ifdef USE_GENCONV_f70 67 addConverter(new GenoConv_f70); 65 68 #endif 66 #ifdef USE_GENCONV_ F8167 addConverter(new GenoConv_F8ToF1());69 #ifdef USE_GENCONV_f81 70 addConverter(new GenoConv_f8ToF1()); 68 71 #endif 69 #ifdef USE_GENCONV_F90 70 addConverter(new GenoConv_F90); 72 #ifdef USE_GENCONV_f90 73 addConverter(new GenoConv_f90); 74 #endif 75 #ifdef USE_GENCONV_fF0 76 addConverter(new GenoConv_fF0); 71 77 #endif 72 78 73 param.updatetab();79 param.updatetab(); 74 80 } -
cpp/frams/genetics/f1/conv_f1.cpp
r121 r139 100 100 101 101 /** main conversion function - with conversion map support */ 102 SString GenoConv_ F1::convert(SString &i,MultiMap *map)102 SString GenoConv_f1::convert(SString &i,MultiMap *map) 103 103 { 104 104 const char* g=(const char*)i; -
cpp/frams/genetics/f1/conv_f1.h
r121 r139 60 60 61 61 */ 62 class GenoConv_ F1: public GenoConverter62 class GenoConv_f1: public GenoConverter 63 63 { 64 64 public: 65 GenoConv_ F1()65 GenoConv_f1() 66 66 { 67 67 name="Recursive encoding"; … … 70 70 } 71 71 SString convert(SString &i,MultiMap *map); 72 ~GenoConv_ F1() {}72 ~GenoConv_f1() {} 73 73 }; 74 74 -
cpp/frams/genetics/f9/conv_f9.cpp
r125 r139 10 10 #define APPLY_DETERMINISTIC_BODY_NOISE //this representation easily produces perfectly vertical sticks that would stay upright forever. In most cases such infinite perfection is not desired, so we make the construct less perfect by perturbing its coordinates. 11 11 12 GenoConv_ F90::GenoConv_F90()12 GenoConv_f90::GenoConv_f90() 13 13 { 14 14 name = "Turtle3D-ortho encoding"; … … 25 25 //const char* turtle_commandsZ_f9="0000-+"; 26 26 27 SString GenoConv_ F90::convert(SString &in, MultiMap *map)27 SString GenoConv_f90::convert(SString &in, MultiMap *map) 28 28 { 29 29 vector<XYZ_LOC> vertices; … … 55 55 } 56 56 57 int GenoConv_ F90::addSegment(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex,int recently_added)57 int GenoConv_f90::addSegment(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex,int recently_added) 58 58 { 59 59 if (vertices.size()<1) … … 77 77 } 78 78 79 int GenoConv_ F90::findVertexAt(vector<XYZ_LOC> &vertices,const XYZ_LOC &vertex)79 int GenoConv_f90::findVertexAt(vector<XYZ_LOC> &vertices,const XYZ_LOC &vertex) 80 80 { 81 81 for(int i=0;i<vertices.size();i++) … … 85 85 86 86 87 int GenoConv_ F90::addNewVertex(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex)87 int GenoConv_f90::addNewVertex(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex) 88 88 { 89 89 Part *p=new Part; … … 110 110 } 111 111 112 void GenoConv_ F90::setColors(Model &m) //sets fixed (independent from genes) colors and widths on a model, purely for aesthetic purposes112 void GenoConv_f90::setColors(Model &m) //sets fixed (independent from genes) colors and widths on a model, purely for aesthetic purposes 113 113 { 114 114 //a rainbow on Joints: from the first one red, through middle green, to blue or violet - last … … 145 145 } 146 146 147 void GenoConv_ F90::perturbPartLocations(Model &m) //deterministic "body noise", see APPLY_DETERMINISTIC_BODY_NOISE147 void GenoConv_f90::perturbPartLocations(Model &m) //deterministic "body noise", see APPLY_DETERMINISTIC_BODY_NOISE 148 148 { 149 149 for(int i=0;i<m.getPartCount();i++) -
cpp/frams/genetics/f9/conv_f9.h
r125 r139 29 29 30 30 // The f9->f0 converter 31 class GenoConv_ F90: public GenoConverter31 class GenoConv_f90: public GenoConverter 32 32 { 33 33 public: 34 GenoConv_ F90();34 GenoConv_f90(); 35 35 36 //implementation GenoConverter method36 //implementation of the GenoConverter method 37 37 SString convert(SString &in, MultiMap *map); 38 38 -
cpp/frams/genetics/f9/oper_f9.h
r120 r139 18 18 int crossOver(char *&g1,char *&g2,float& chg1,float& chg2); 19 19 unsigned long style(const char *g, int pos); 20 c har* getSimplest() {return "R";}20 const char* getSimplest() {return "R";} 21 21 22 22 double mut_prob; //mutation probability -
cpp/frams/genetics/gen-config-GDK.h
r138 r139 12 12 */ 13 13 14 #define USE_GENCONV_ F1015 //#define USE_GENCONV_ F2116 //#define USE_GENCONV_ F3017 //#define USE_GENCONV_ F4018 //#define USE_GENCONV_ F41_TEST19 //#define USE_GENCONV_ F5020 #define USE_GENCONV_ F9014 #define USE_GENCONV_f10 15 //#define USE_GENCONV_f21 16 //#define USE_GENCONV_f30 17 //#define USE_GENCONV_f40 18 //#define USE_GENCONV_f41_TEST 19 //#define USE_GENCONV_f50 20 #define USE_GENCONV_f90 21 21 22 //#define USE_GENMAN_ F023 //#define USE_GENMAN_ F124 //#define USE_GENMAN_ F225 //#define USE_GENMAN_ F326 //#define USE_GENMAN_ F427 //#define USE_GENMAN_ F528 #define USE_GENMAN_ F922 //#define USE_GENMAN_f0 23 //#define USE_GENMAN_f1 24 //#define USE_GENMAN_f2 25 //#define USE_GENMAN_f3 26 //#define USE_GENMAN_f4 27 //#define USE_GENMAN_f5 28 #define USE_GENMAN_f9 -
cpp/frams/genetics/genman.cpp
r138 r139 11 11 12 12 13 #ifdef USE_GENMAN_ F013 #ifdef USE_GENMAN_f0 14 14 #include "f0/oper_f0.h" 15 15 #endif 16 #ifdef USE_GENMAN_ F0FUZZY16 #ifdef USE_GENMAN_f0FUZZY 17 17 #include "f0/oper_f0Fuzzy.h" 18 18 #endif 19 #ifdef USE_GENMAN_ F119 #ifdef USE_GENMAN_f1 20 20 #include "f1/oper_f1.h" 21 21 #endif 22 #ifdef USE_GENMAN_ F222 #ifdef USE_GENMAN_f2 23 23 #include "f2/oper_f2.h" 24 24 #endif 25 #ifdef USE_GENMAN_ F225 #ifdef USE_GENMAN_f2 26 26 #include "f3/oper_f3.h" 27 27 #endif 28 #ifdef USE_GENMAN_ F428 #ifdef USE_GENMAN_f4 29 29 #include "f4/oper_f4.h" 30 30 #endif 31 #ifdef USE_GENMAN_ F531 #ifdef USE_GENMAN_f5 32 32 #include "f5/oper_f5.h" 33 33 #endif 34 #ifdef USE_GENMAN_ F634 #ifdef USE_GENMAN_f6 35 35 #include "f6/oper_f6.h" 36 36 #endif 37 #ifdef USE_GENMAN_ F737 #ifdef USE_GENMAN_f7 38 38 #include "f7/oper_f7.h" 39 39 #endif 40 #ifdef USE_GENMAN_ F840 #ifdef USE_GENMAN_f8 41 41 #include "f8/oper_f8.h" 42 42 #endif 43 #ifdef USE_GENMAN_ F943 #ifdef USE_GENMAN_f9 44 44 #include "f9/oper_f9.h" 45 #endif 46 #ifdef USE_GENMAN_fF 47 #include "fF/oper_fF.h" 45 48 #endif 46 49 … … 101 104 clearStats(); 102 105 103 #ifdef USE_GENMAN_ F0106 #ifdef USE_GENMAN_f0 104 107 geno_fx_list.push_back(new Geno_f0); 105 108 #endif 106 #ifdef USE_GENMAN_ F0FUZZY109 #ifdef USE_GENMAN_f0FUZZY 107 110 geno_fx_list.push_back(new Geno_f0Fuzzy); 108 111 #endif 109 #ifdef USE_GENMAN_ F1112 #ifdef USE_GENMAN_f1 110 113 geno_fx_list.push_back(new Geno_f1); 111 114 #endif 112 #ifdef USE_GENMAN_ F2115 #ifdef USE_GENMAN_f2 113 116 geno_fx_list.push_back(new Geno_f2); 114 117 #endif 115 #ifdef USE_GENMAN_ F3118 #ifdef USE_GENMAN_f3 116 119 geno_fx_list.push_back(new Geno_f3); 117 120 #endif 118 #ifdef USE_GENMAN_ F4121 #ifdef USE_GENMAN_f4 119 122 geno_fx_list.push_back(new Geno_f4); 120 123 #endif 121 #ifdef USE_GENMAN_ F5124 #ifdef USE_GENMAN_f5 122 125 geno_fx_list.push_back(new Geno_f5); 123 126 #endif 124 #ifdef USE_GENMAN_ F6127 #ifdef USE_GENMAN_f6 125 128 geno_fx_list.push_back(new Geno_f6); 126 129 #endif 127 #ifdef USE_GENMAN_ F7130 #ifdef USE_GENMAN_f7 128 131 geno_fx_list.push_back(new Geno_f7); 129 132 #endif 130 #ifdef USE_GENMAN_ F8133 #ifdef USE_GENMAN_f8 131 134 geno_fx_list.push_back(new Geno_f8); 132 135 #endif 133 #ifdef USE_GENMAN_ F9136 #ifdef USE_GENMAN_f9 134 137 geno_fx_list.push_back(new GenoOper_f9); 138 #endif 139 #ifdef USE_GENMAN_fF 140 geno_fx_list.push_back(new GenoOper_fF); 135 141 #endif 136 142 -
cpp/frams/genetics/oper_fx.h
r121 r139 160 160 161 161 /**\return a pointer to the simplest genotype string*/ 162 virtual c har* getSimplest() {return NULL;}162 virtual const char* getSimplest() {return NULL;} 163 163 164 164 /**You may want to have your genotype colored. This method provides desired character styles for genes. -
cpp/frams/util/3d.h
r121 r139 62 62 void getAngles(const Pt3D& X,const Pt3D& dir); 63 63 void vectorProduct(const Pt3D& a,const Pt3D& b); 64 Pt3D vectorProduct(const Pt3D& p) const {return (*this)*p;} 65 Pt3D entrywiseProduct(const Pt3D &p) const {return Pt3D(x*p.x,y*p.y,z*p.z);} ///< also known as Hadamard product or Schur product 66 double dotProduct(const Pt3D& p) const {return x*p.x+y*p.y+z*p.z;} 64 67 bool normalize(); 65 68 };
Note: See TracChangeset
for help on using the changeset viewer.