//throw away the segments [0,u] and [v,1] of the segment /// <summary> /// Returns the trimmed curve /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public ICurve Trim(double u, double v) { AdjustParamTo01(ref u); AdjustParamTo01(ref v); if (u > v) { return(Trim(v, u)); } if (u > 1.0 - ApproximateComparer.Tolerance) { return(new CubicBezierSegment(b[3], b[3], b[3], b[3])); } Point[] b1 = new Point[3]; Point[] b2 = new Point[2]; Point pv = Casteljau(u, b1, b2); //this will be the trim to [v,1] CubicBezierSegment trimByU = new CubicBezierSegment(pv, b2[1], b1[2], b[3]); //1-v is not zero here because we have handled already the case v=1 Point pu = trimByU.Casteljau((v - u) / (1.0 - u), b1, b2); return(new CubicBezierSegment(trimByU.b[0], b1[0], b2[0], pu)); }
//throw away the segments [0,u] and [v,1] of the segment /// <summary> /// Returns the trimmed curve /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public ICurve Trim(double u, double v) { AdjustParamTo01(ref u); AdjustParamTo01(ref v); if (u > v) return Trim(v, u); if (u > 1.0 - ApproximateComparer.Tolerance) return new CubicBezierSegment(b[3], b[3], b[3], b[3]); Point[] b1 = new Point[3]; Point[] b2 = new Point[2]; Point pv = Casteljau(u, b1, b2); //this will be the trim to [v,1] CubicBezierSegment trimByU = new CubicBezierSegment(pv, b2[1], b1[2], b[3]); //1-v is not zero here because we have handled already the case v=1 Point pu = trimByU.Casteljau((v - u) / (1.0 - u), b1, b2); return new CubicBezierSegment(trimByU.b[0], b1[0], b2[0], pu); }