public override void GetCurvePoints() { this.curvePoints = new List <CurvePoint>(); this.controlPoints = new List <CurvePoint>(); double dtheta = Math.PI * 2 / this.numofPoints; int K = this.numofPoints / 4; for (int i = 0; i < this.numofPoints; ++i) { double theta = i * dtheta; double x = this.xRadius * Math.Cos(theta); double y = this.yRadius * Math.Sin(theta); Vector2d p = this.center + new Vector2d(x, y); CurvePoint cp = new CurvePoint(p, i); this.curvePoints.Add(cp); if (i % K == 0) { this.controlPoints.Add(cp); } } }
public override void GetCurvePoints() { this.curvePoints = new List <CurvePoint>(); this.controlPoints = new List <CurvePoint>(); int K = this.numofPoints / 4; double cx = this.center.x, cy = this.center.y; Vector2d[] B = new Vector2d[4] { new Vector2d(cx - xLen / 2, cy - yLen / 2), new Vector2d(cx + xLen / 2, cy - yLen / 2), new Vector2d(cx + xLen / 2, cy + yLen / 2), new Vector2d(cx - xLen / 2, cy + yLen / 2) }; int index = 0; for (int i = 0; i < 4; ++i) { Vector2d p = B[i], q = B[(i + 1) % 4]; double step = 1.0 / K; for (int j = 0; j < K; ++j) { double r = step * j; Vector2d t = p * (1 - r) + q * r; CurvePoint cp = new CurvePoint(t, index++); this.curvePoints.Add(cp); if (j == 0) { this.controlPoints.Add(cp); } } } }