/// <summary> /// Creates the slice from the given data /// </summary> /// <param name="transform"> Reference to the transform of the holder plane. </param> /// <param name="normal"> Normal vector of the holder plane in local coordinates. </param> /// <param name="refPoint"> A point on the holder plane. </param> /// <param name="polygons"> The polygons, which came from the mesh slicer program. </param> /// <param name="lastInd"> The last index of the trigonometric polynomials. </param> public Slice(Transform transform, Vector3 normal, Vector3 refPoint, List <Polygon> polygons, int lastInd) : base(normal, refPoint, transform) { curves = new List <FourierCurve>(); saCache = new Dictionary <FourierCurve, float>(); foreach (Polygon polygon in polygons) { FourierCurve curve = new FourierCurve(polygon, lastInd); curves.Add(curve); saCache.Add(curve, 2 * Mathf.PI * Random.value); } }
public static void DrawCurve(FourierCurve curve, Vector3 localX, Vector3 localY, Vector3 refPoint, Color col) { int n = 100; Gizmos.color = col; float stride = 2 * Mathf.PI / n; for (int t = 0; t < n; t++) { Vector3 vec1 = curve.EvalX(stride * t) * localX + curve.EvalY(stride * t) * localY + refPoint; Vector3 vec2 = curve.EvalX(stride * (t + 1)) * localX + curve.EvalY(stride * (t + 1)) * localY + refPoint; Gizmos.DrawLine(vec1, vec2); } }