Example #1
0
        public static PathPoint Intersection(PathPoint line1From, PathPoint line1To, PathPoint line2From, PathPoint line2To)
        {
            var line1DeltaX = line1To.X.Value - line1From.X.Value;
            var line1DeltaY = line1To.Y.Value - line1From.Y.Value;
            var line2DeltaX = line2To.X.Value - line2From.X.Value;
            var line2DeltaY = line2To.Y.Value - line2From.Y.Value;
            var fromDeltaX  = line2From.X.Value - line1From.X.Value;
            var fromDeltaY  = line2From.Y.Value - line1From.Y.Value;

            var det = (line2DeltaX * line1DeltaY) - (line2DeltaY * line1DeltaX);

            if (Math.Abs(det) < 0.000001)
            {
                return(PathPoint.Invalid);
            }

            var detinv = 1.0 / det;
            var s      = ((line2DeltaX * fromDeltaY) - (line2DeltaY * fromDeltaX)) * detinv;
            var t      = ((line1DeltaX * fromDeltaY) - (line1DeltaY * fromDeltaX)) * detinv;

            if (s < 0 || s > 1 || t < 0 || t > 1)
            {
                // return PathPoint.Invalid;
            }
            if (s < 0)
            {
                s = 0;
            }
            if (s > 1)
            {
                s = 1;
            }

            return(new PathPoint(line1From.X + (line1DeltaX * s), line1From.Y + (line1DeltaY * s)));
        }
Example #2
0
        public static bool Intersects(PathPoint line1From, PathPoint line1To, PathPoint line2From, PathPoint line2To)
        {
            var line1DeltaX = line1To.X.Value - line1From.X.Value;
            var line1DeltaY = line1To.Y.Value - line1From.Y.Value;
            var line2DeltaX = line2To.X.Value - line2From.X.Value;
            var line2DeltaY = line2To.Y.Value - line2From.Y.Value;
            var fromDeltaX  = line2From.X.Value - line1From.X.Value;
            var fromDeltaY  = line2From.Y.Value - line1From.Y.Value;

            var det = (line2DeltaX * line1DeltaY) - (line2DeltaY * line1DeltaX);

            if (Math.Abs(det) < 0.000001)
            {
                return(false);
            }

            var detinv = 1.0 / det;
            var s      = ((line2DeltaX * fromDeltaY) - (line2DeltaY * fromDeltaX)) * detinv;
            var t      = ((line1DeltaX * fromDeltaY) - (line1DeltaY * fromDeltaX)) * detinv;

            return(s >= 0 && s <= 1 && t >= 0 && t <= 1);
        }
Example #3
0
 public abstract PathPoint Offset(PathPoint destination, double distance);
Example #4
0
 public abstract bool Intersects(PathPoint destination, PathPoint lineFrom, PathPoint lineTo);
Example #5
0
 public abstract Dimension Distance(PathPoint destination);
Example #6
0
 public abstract PathPoint Interpolate(PathPoint destination, double ratio);
Example #7
0
 protected PathSegment(PathSegment prototype)
 {
     m_origin = prototype.m_origin;
 }
Example #8
0
 public PathSegment(JToken json)
 {
     m_origin = new PathPoint(json[JsonNames.Origin]);
 }
Example #9
0
 public PathSegment(PathPoint origin)
 {
     m_origin = origin;
 }
Example #10
0
        public override bool Intersects(PathPoint destination, PathPoint lineFrom, PathPoint lineTo)
        {
            var intersects = Geometry.Intersects(Origin, destination, lineFrom, lineTo);

            return(intersects);
        }
Example #11
0
 public LinePathSegment(PathPoint origin)
     : base(origin)
 {
 }