コード例 #1
0
        public static EdgeDistance ClosestDistanceBetweenTwoCurves(IMathUtility m, ICurve curve0, ICurve curve1)
        {
            var curveDomain = curve1.Domain();

            var solver = new BrentSearch
                             (t =>
            {
                var pt = curve1.PointAt(t);
                return((curve0.ClosestPointOn(pt).Point - pt).Length());
            }
                             , curveDomain[0]
                             , curveDomain[1]
                             );

            solver.Minimize();
            var param = solver.Solution;

            var pt1  = curve1.PointAt(param);
            var pt0  = curve0.ClosestPointOn(pt1).Point;
            var edge = new Edge3(pt1, pt0);

            return(new EdgeDistance(edge, solver.Value));
        }
コード例 #2
0
 public static PointParam ClosestPointOn(this ICurve curve, Vector3 v) => curve.ClosestPointOn(v.X, v.Y, v.Z);
コード例 #3
0
        public static double PointAtDistanceFrom(this ICurve c, Vector3 p0, double distance)
        {
            var ptT0 = c.ClosestPointOn(p0);

            return(PointAtDistanceFrom(c, ptT0.T, distance));
        }
コード例 #4
0
 public static PointDirection3 ClosestPointTangentOn(this ICurve curve, Vector3 v) => curve.PointTangentAt(curve.ClosestPointOn(v.X, v.Y, v.Z).T);
コード例 #5
0
        public static EdgeDistance ClosestDistanceBetweenTwoCurves(IMathUtility m,ICurve curve0, ICurve curve1)
        {
            var curveDomain = curve1.Domain();

            var solver = new BrentSearch
                (t =>
                {
                    var pt = curve1.PointAt(t);
                    return (curve0.ClosestPointOn(pt).Point - pt).Length();
                }
                , curveDomain[0]
                , curveDomain[1]
                );

            solver.Minimize();
            var param = solver.Solution;

            var pt1 = curve1.PointAt(param);
            var pt0 = curve0.ClosestPointOn(pt1).Point;
            var edge = new Edge3(pt1, pt0);
            return new EdgeDistance(edge, solver.Value);
        }