MCPcopy Create free account
hub / github.com/GilesBathgate/RapCAD / getPolygon

Method getPolygon

src/module/primitivemodule.cpp:48–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48const QList<Point> PrimitiveModule::getPolygon(const decimal& a,const decimal& r,const decimal& n,const decimal& z)
49{
50 QList<Point> poly;
51 if(n==6) {
52 //TODO modify this to cater for all even values of n
53 decimal x=0.0;
54 decimal y=0.0;
55 decimal s2=r*r_sin(r_pi()/n);
56 for(auto i=0; i<n; ++i) {
57 switch(i) {
58 case 0: {
59 y=a;
60 x=-s2;
61 break;
62 }
63 case 1: {
64 x=s2;
65 break;
66 }
67 case 2: {
68 y=0.0;
69 x=r;
70 break;
71 }
72 case 3: {
73 y=-a;
74 x=s2;
75 break;
76 }
77 case 4: {
78 x=-s2;
79 break;
80 }
81 case 5: {
82 y=0.0;
83 x=-r;
84 break;
85 }
86 }
87 poly.append(Point(x,y,z));
88 }
89 return poly;
90 }
91 return getCircle(r,n,z);
92}
93
94void PrimitiveModule::createTriangle(Primitive* p,int a,int b,int c)
95{

Callers

nothing calls this directly

Calls 4

r_sinFunction · 0.85
r_piFunction · 0.85
PointClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected