Map_Test.cpp
Go to the documentation of this file.
00001 // Copyright (c) 2013-2014 by Wayne C. Gramlich.  All rights reserved.
00002 
00003 #include <assert.h>
00004 
00005 #include "Arc.hpp"
00006 #include "CV.hpp"
00007 #include "File.hpp"
00008 #include "Map.hpp"
00009 #include "String.hpp"
00010 #include "Tag.hpp"
00011 
00012 extern void Map__build(Map map);
00013 
00014 int main(int arguments_size, char * arguments[]) {
00015     Map map1 = Map__create(".", "Map_Test_Map",
00016       (void *)0, Fiducials__arc_announce, Fiducials__tag_announce,
00017       (String_Const)0, "main:Map__new");
00018     unsigned int visit = map1->visit;
00019 
00020     double pi = 3.14159265358979323846264;
00021     double degrees_to_radians = pi / 180.0;
00022 
00023     // Some angles (in radians) to use:
00024     double angle0   =   0.0 * degrees_to_radians;
00025     double angle10  =  10.0 * degrees_to_radians;
00026     double angle20  =  20.0 * degrees_to_radians;
00027     double angle30  =  30.0 * degrees_to_radians;
00028     double angle40  =  40.0 * degrees_to_radians;
00029     double angle45  =  45.0 * degrees_to_radians;
00030     double angle90  =  90.0 * degrees_to_radians;
00031     double angle135 = 135.0 * degrees_to_radians;
00032     double angle180 = 180.0 * degrees_to_radians;
00033 
00034     double square_root_200 = hypot(10.0, 10.0);
00035     double square_root_50 = hypot(5.0, 5.0);
00036 
00037     // The test map looks as follows:
00038     //
00039 
00040     //  3---2
00041     //  |\ /|
00042     //  | 4 |
00043     //  |/ \|
00044     //  0---1
00045 
00046     unsigned int tag_size = 1.0;
00047     Tag * tag0 = Map__tag_lookup(map1, 0);
00048     tag0->initialize(0.0, 0.0, 0.0, tag_size, visit);
00049     Tag * tag1 = Map__tag_lookup(map1, 1);
00050     tag1->initialize(0.0, 0.0, 0.0, tag_size, visit);
00051     Tag * tag2 = Map__tag_lookup(map1, 2);
00052     tag2->initialize(0.0, 0.0, 0.0, tag_size, visit);
00053     Tag * tag3 = Map__tag_lookup(map1, 3);
00054     tag3->initialize(0.0, 0.0, 0.0, tag_size, visit);
00055     Tag * tag4 = Map__tag_lookup(map1, 4);
00056     tag4->initialize(0.0, 0.0, 0.0, tag_size, visit);
00057 
00058     // The tags are twisted by the tag id x 10 degerees.  Thus, tag
00059     // 0 has no twist, tag 1 is 10 degerees, ..., and tag 4 is 40 degrees.
00060 
00061     // Sides:
00062     double d = 10.0;
00063     new Arc(tag0, 0.0 + 0.0,           d, tag1, -angle180 + angle10, 0.0);
00064     new Arc(tag1, -angle90 + angle10,  d, tag2,  angle90  + angle20, 0.0);
00065     new Arc(tag0, -angle90,            d, tag3,  angle90  + angle30, 0.0);
00066     new Arc(tag2, -angle180 + angle20, d, tag3,  0.0      + angle30, 0.0);
00067 
00068     // Arcs to center:
00069     d = square_root_50;
00070     new Arc(tag0, -angle45,            d, tag4,  angle135 + angle40, 0.0);
00071     new Arc(tag1, -angle135 + angle10, d, tag4,  angle135 + angle40, 0.0);
00072     new Arc(tag2, -angle45  + angle20, d, tag4,  -angle45 + angle40, 0.0);
00073     new Arc(tag3,  angle45  + angle30, d, tag4, -angle135 + angle40, 0.0);
00074 
00075     // Large diagonals:
00076     d = square_root_200;
00077     //Arc__create(tag0, ??, square_root_200, tag2, ??, 0.0);
00078     //Arc__create(tag1, ??, square_root_200, tag3, ??, 0.0);
00079 
00080     Map__update(map1, (CV_Image)0, 0);
00081 
00082     Map__save(map1);
00083 
00084     Map map2 = Map__create(".", "Map_Test_Map",
00085       (void *)0, Fiducials__arc_announce, Fiducials__tag_announce,
00086       (String_Const)0, "main:Map__new");
00087 
00088     assert (Map__equals(map1, map2));
00089 
00090     std::vector<Location*> locations;
00091     Map__svg_write(map1, "Map_Test", locations);
00092 
00093     return 0;
00094 }
00095 
00096 void Map__build(Map map) {
00097 }


fiducial_lib
Author(s): Wayne Gramlich
autogenerated on Thu Jun 6 2019 18:08:04