Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Motordriver mbed HALLFX_ENCODER Servo
letters.h
00001 /* 00002 typedef struct { 00003 double x; 00004 double y; 00005 int pen; 00006 } Transition; 00007 00008 typedef struct { 00009 Transition points[10]; 00010 } Letter; 00011 00012 Letter let_a = { .points = { {0.0, 0.0, 0}, {0.25, 0.25, 1}, {1.0, 1.175, 1}, {1.75, .25, 1}, {.625, 1.0, 0}, {1.375, 1.0, 1}, {2.0, 0.0, 0} } }; 00013 Letter let_h = { .points = { {0.0, 0.0, 0}, {0.0, 2.0, 1}, {2.0, 2.0, 0}, {2.0, 0.0, 1}, {0.0, 1.0, 0}, {2.0, 1.0, 1}, {2.0, 0.0, 0} } }; 00014 Letter let_l = { .points = { {0.0, 0.0, 0}, {0.25, 0.25, 1}, {0.25, 1.75, 1}, {0.25, 0.25, 0}, {1.25, 0.25, 1}, {2.0, 0.0, 0}}}; 00015 Letter let_e = { .points = { {0.0, 0.0, 0}, {0.25, 0.25, 1}, {0.25, 1.75, 1}, {1, 1.75, 1}, {0.25, 1, 0}, {1, 1, 1}, {0.25, 0.25, 0}, {1, 0.25, 1}, {2.0, 0.0, 0}}}; 00016 Letter let_o = { .points = { {0.0, 0.0, 0}, {0.25, 0.25, 1}, {0.25, 1.75, 1}, {1, 1.75, 1}, {1, 0.25, 1}, {0.25, 0.25, 1}, {2.0, 0.0, 0}}}; 00017 */ 00018 00019 #include <math.h> 00020 #define PI 3.1415926535 00021 00022 class Transition { 00023 public: 00024 double x_init; 00025 double x_final; 00026 double y_init; 00027 double y_final; 00028 int draw; 00029 00030 Transition (double x_i, double y_i, double x_f, double y_f, int d) { 00031 x_init = x_i; 00032 x_final = x_f; 00033 y_init = y_i; 00034 y_final = y_f; 00035 draw = d; 00036 } 00037 00038 Transition () {} 00039 00040 double desired_angle() { 00041 return atan2(y_final - y_init, x_final - x_init) * 180.0 / PI; 00042 } 00043 00044 double distance() { 00045 return sqrt(pow(y_final - y_init, 2) + pow(x_final - x_init, 2)); 00046 } 00047 }; 00048 00049 Transition h1(0,0,.25,.25,false); 00050 Transition h2(.25,.25,.25,1.75,true); 00051 Transition h3(.25,1.75,.25,1,false); 00052 Transition h4(.25,1,1,1,true); 00053 Transition h5(1,1,1,1.75,false); 00054 Transition h6(1,1.75,1,.25,true); 00055 Transition h7(1,.25,2,0,false); 00056 00057 Transition let_h[7] = { h1, h2, h3, h4, h5, h6, h7 }; 00058 00059 Transition e1(0,0,1,1.75,false); 00060 Transition e2(1,1.75,0.25,1.75,true); 00061 Transition e3(0.25,1.75,.25,.25,true); 00062 Transition e4(.25,.25,1,.25,true); 00063 Transition e5(1,.25,.25,1,false); 00064 Transition e6(.25,1,1,1,true); 00065 Transition e7(1,1,2,0,false); 00066 00067 Transition let_e[7] = { e1, e2, e3, e4, e5, e6, e7 }; 00068 00069 Transition l1(0,0,0.25,1.75,false); 00070 Transition l2(0.25,1.75,0.25,0.25,true); 00071 Transition l3(0.25,0.25,1.25,0.25,true); 00072 Transition l4(1.25,0.25,2,0,false); 00073 00074 Transition let_l[4] = { l1, l2, l3, l4 }; 00075 00076 Transition o1(0,0,.25,.25,false); 00077 Transition o2(.25,.25,.25,1.75,true); 00078 Transition o3(.25,1.75,1.75,1.75,true); 00079 Transition o4(1.75,1.75,1.75,.25,true); 00080 Transition o5(1.75,.25,.25,.25,true); 00081 Transition o6(.25,.25,2,0,false); 00082 00083 Transition let_o[6] = { o1, o2, o3, o4, o5, o6 };
Generated on Sat Jul 16 2022 18:01:08 by
1.7.2