protected void DrawCircle(ref Circle2 circle) { int count = 40; float delta = 2f * Mathf.PI / count; Vector3 prev = circle.Eval(0); for (int i = 1; i <= count; ++i) { Vector3 curr = circle.Eval(i * delta); Gizmos.DrawLine(prev, curr); prev = curr; } }
protected void DrawCircle(Vector2 center, float radius) { Circle2 circle = new Circle2(ref center, radius); int count = 40; float delta = 2f * Mathf.PI / count; Vector3 prev = circle.Eval(0); for (int i = 1; i <= count; ++i) { Vector3 curr = circle.Eval(i * delta); Gizmos.DrawLine(prev, curr); prev = curr; } }
public static VectorLine Draw3D(this Circle2 self, float y, Color color, float time = 0) { Vector3[] v3Point = new Vector3[CIRCLE_POINTS]; float unit = Mathf.PI * 2 / (v3Point.Length - 1); for (int i = 0; i < v3Point.Length - 1; ++i) { var point = self.Eval(i * unit); v3Point[i] = new Vector3(point.x, y, point.y); } v3Point[v3Point.Length - 1] = v3Point[0]; var ret = time == 0 ? VectorLine.SetLine3D(color, v3Point) : VectorLine.SetLine3D(color, time, v3Point); ret.name = "CircleLine"; return(ret); }
public static Vector3[] CalcSectorPoints3D(this Circle2 self, float y, float from, float to, int amountOfPoints) { Vector3[] v3Point = new Vector3[amountOfPoints]; float unit = Mathf.Abs(from - to) / (v3Point.Length - 3); float PI2 = Mathf.PI * 2; for (int i = 0; i < v3Point.Length - 2; ++i) { var f = i * unit + from; if (f < 0) { f += PI2; } if (f > PI2) { f -= PI2; } var point = self.Eval(f); v3Point[i] = new Vector3(point.x, y, point.y); } v3Point[v3Point.Length - 2] = new Vector3(self.Center.x, y, self.Center.y); v3Point[v3Point.Length - 1] = v3Point[0]; return(v3Point); }