public class RotaryBarrier { private Vector2D Pos; //The actual position of the barier private float Orient; //Orientation of the whole thing private float in_r; //Radius of the inner circle before extrusion private float ext; //Extrusion Distance beyond the inner circle private int numSides; //probably some number from 3 to 10 or so - undefined below 3 private int MaxSides; private int MinSides; public LineSeg2D[] lines; RotaryBarrier() { //Basic default values MinSides = 3; MaxSides = 20; numSides = 3; Orient = 0; //0 radians is Right-facing in_r = 70; ext = 40; Pos = new Vector2D(0,0); lines = new LineSeg2D[MaxSides]; //storage for the Line Seg data for (int i=0; i MaxSides) numSides = MaxSides; else numSides = i; RecalculateSegs(); //refresh our segments return numSides; } public float GetOrientation() { return Orient; } public void SetOrientation(float o) { Orient = o; RecalculateSegs(); } public Vector2D GetPosition() { return new Vector2D(Pos); } public void SetPosition(Vector2D v) { Pos.Set(v); RecalculateSegs(); } public void SetPosition(float x, float y) { Pos.Set(x,y); RecalculateSegs(); } //maybe this should be private public void RecalculateSegs() { //ok, so loop through the sucker, calculating where the Line Seg points are. float twopi = 6.283185307f; float thetaSep = twopi/numSides; Vector2D[] points = new Vector2D[numSides]; //These represent points on the inner circle float thetaDist = Orient; //start calculating the points from the original Orientation for (int i=0; i