-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpolygonclass.cs
More file actions
46 lines (46 loc) · 1.72 KB
/
polygonclass.cs
File metadata and controls
46 lines (46 loc) · 1.72 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
namespace graphicsengine
{
class polygon{
public static List<polygon> allthePolygon = new List<polygon>();
public List<line> lines = new List<line>();
public List<point> points = new List<point>();
public polygon(point [] pointarray){
points.Add(points[0]);
for(int i = 0; i < (points.Count-1);i++){
lines.Add(new line(points[i],points[i+1]));
points.Add(points[i+1]);
}
allthePolygon.Add(this);
}
public polygon(int radius, int n , double offsetx , double offsety, bool numbered = false,bool polar=false){///regular polygon
points.Clear();
if(polar){
for(int i=0;i<(n);i++){
points.Add(new point(i*2*Math.PI/n,radius,offsetx,offsety));
}
}else{
for(int i=0;i<(n);i++){
double x = ( radius * Math.Cos((2*i*Math.PI)/n));
double y = ( radius * Math.Sin((2*i*Math.PI)/n));
points.Add(new point(x + offsetx ,y + offsety));
}
}
line temp;
for(int i = 0; i < (points.Count-1);i++){
temp = (new line(points[i],points[i+1]));
if(numbered){
temp.spcecialchar=Convert.ToChar(Convert.ToString(i));
}
lines.Add(temp);
}
temp = (new line(points[0],points[points.Count-1]));
if(numbered){
temp.spcecialchar=Convert.ToChar(Convert.ToString(points.Count-1));
}
lines.Add(temp);
allthePolygon.Add(this);
}
}
}