/* drawing an equilateral triangle. First method, calculate all co-ordinates. inflexible */ #include "library.h" const double pi = acos(-1.0); void main() { make_window(500,500); set_pen_color(color::red); set_pen_width(3); const double x1 = 250, y1 = 50; move_to(x1, y1); const double x2 = 400, y2 = 50 + 150*tan(60.0 * pi / 180.0); draw_to(x2, y2); const double x3 = 100, y3 = y2; draw_to(x3, y3); draw_to(x1, y1); } /* When it seemed not to work because we gave tan an input of 60 (it expects radians not degrees), this is what we did to debug it. Make the computer do all the work. void main() { print("asin(1.0) = "); print(asin(1.0)); new_line(); // should be 90 degrees make_window(500,500); set_pen_color(color::red); set_pen_width(3); const double x1 = 250, y1 = 50; move_to(x1, y1); print("x1, y1 = "); print(x1); print(", "); print(y1); new_line(); const double x2 = 400, y2 = 50 + 150*tan(60.0 * pi / 180.0); draw_to(x2, y2); print("x2, y2 = "); print(x2); print(", "); print(y2); new_line(); const double x3 = 100, y3 = y2; draw_to(x3, y3); print("x3, y3 = "); print(x3); print(", "); print(y3); new_line(); draw_to(x1, y1); } */