Making an octagon out of right triangles

Hello all,

One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."

Making such a class isn't difficult. I wrote it as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Simple_window.h"

class right_triangle : public Shape {
public:
	
	right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh) 
	 { add(Point (p));}

	void draw_lines () const
	{
		fl_line(point(0).x, point(0).y, point(0).x, point(0).y+_long, point(0).x+_short, point(0).y+_long);
		fl_line(point(0).x+_short, point(0).y+_long, point(0).x, point(0).y);
	}

private:
	Point c;
	int _long, _short;
};

//*********************************

int main()
{
    Simple_window win(Point(100,100), 700,500, "Octagon"); 

	Point p(200,200);
	int l = 80, sh = 60;
	right_triangle rt(p,l,sh);

	win.attach(rt);
	win.wait_for_button();
}


But it sounds that making an octagon using eight right triangles isn't possible!
What's your thoughts please?
Last edited on
Google image search.

How about http://www.turnedbygeorge.com/sitebuildercontent/sitebuilderpictures/Patterns/459045TriangleOctagonDetail.jpg

It is not an "octagon", but it definitely has octagonal features.
Last edited on
Thank you. Yes, that's right. I do the exercise.
Topic archived. No new replies allowed.