private static CadVertex ForEachBezierSegs4 <T>( CadVertex p0, CadVertex p1, CadVertex p2, CadVertex p3, int s, Action <CadVertex, CadVertex, T> action, T param) { double t = 0; double d = 1.0 / (double)s; t = d; int n = 4; CadVertex t0 = p0; CadVertex t1 = p0; while (t <= 1.0) { t1 = default; t1 += p0 * BezierFuncs.BernsteinBasisF(n - 1, 0, t); t1 += p1 * BezierFuncs.BernsteinBasisF(n - 1, 1, t); t1 += p2 * BezierFuncs.BernsteinBasisF(n - 1, 2, t); t1 += p3 * BezierFuncs.BernsteinBasisF(n - 1, 3, t); action(t0, t1, param); t0 = t1; t += d; } return(t1); }
public static CadVertex DrawBezier4( CadVertex p0, CadVertex p1, CadVertex p2, CadVertex p3, int s, DrawContext dc, DrawPen pen) { double t = 0; double d = 1.0 / (double)s; t = d; int n = 4; CadVertex t0 = p0; CadVertex t1 = p0; while (t <= 1.0) { t1 = default; t1 += p0 * BezierFuncs.BernsteinBasisF(n - 1, 0, t); t1 += p1 * BezierFuncs.BernsteinBasisF(n - 1, 1, t); t1 += p2 * BezierFuncs.BernsteinBasisF(n - 1, 2, t); t1 += p3 * BezierFuncs.BernsteinBasisF(n - 1, 3, t); dc.Drawing.DrawLine(pen, t0.vector, t1.vector); t0 = t1; t += d; } return(t1); }
private static CadVertex ForEachBezierPoints4 <T>( CadVertex p0, CadVertex p1, CadVertex p2, CadVertex p3, int scnt, bool excludeEdge, Action <CadVertex, T> action, T param) { double t = 0; double d = 1.0 / (double)scnt; double e = 1.0; t = d; int n = 4; CadVertex t0 = p0; CadVertex t1 = p0; if (excludeEdge) { e -= d; } else { action(t0, param); } while (t <= e) { t1 = default(CadVertex); t1 += p0 * BezierFuncs.BernsteinBasisF(n - 1, 0, t); t1 += p1 * BezierFuncs.BernsteinBasisF(n - 1, 1, t); t1 += p2 * BezierFuncs.BernsteinBasisF(n - 1, 2, t); t1 += p3 * BezierFuncs.BernsteinBasisF(n - 1, 3, t); action(t1, param); t += d; } return(t1); }