Beispiel #1
0
        /// <summary>
        /// Returns the square of the perpendicular distance of pt1 from the straight line connecting pt2 and pt3
        /// </summary>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        /// <param name="pt3"></param>
        /// <returns></returns>
        private double TDistance2(FencePoint pt1, FencePoint pt2, FencePoint pt3)
        {
            var d1x = pt3.X - pt2.X;
            var d1y = pt3.Y - pt2.Y;
            var d2x = pt1.X - pt3.X;
            var d2y = pt1.Y - pt3.Y;
            var d3x = pt2.X - pt1.X;
            var d3y = pt2.Y - pt1.Y;
            var s1  = d1x * d1x + d1y * d1y;
            var s2  = d2x * d2x + d2y * d2y;
            var s3  = d3x * d3x + d3y * d3y;

            if (s1 + s2 <= s3)
            {
                return(s2);
            }

            if (s1 + s3 == s2)
            {
                return(s3);
            }

            var d = d1y * d2x - d1x * d2y;

            return(d * d / s1);
        }
Beispiel #2
0
        public void Read(BinaryReader reader)
        {
            var pointsCount = reader.ReadInt32();

            for (var i = 0; i < pointsCount; i++)
            {
                var point = new FencePoint();
                point.Read(reader);

                Points.Add(point);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Determines if the 2D location of this point is the same as the point supplied in other
 /// </summary>
 public bool SameInPlan(FencePoint other) => X == other.X && Y == other.Y;
Beispiel #4
0
 /// <summary>
 /// Determines if this 3D point is the same as the point supplied in other
 /// </summary>
 public bool Equals(FencePoint other) => X == other.X && Y == other.Y && Z == other.Z;
Beispiel #5
0
 /// <summary>
 /// Assign the state of source to this fence point instance
 /// </summary>
 public void Assign(FencePoint source)
 {
     X = source.X;
     Y = source.Y;
     Z = source.Z;
 }
Beispiel #6
0
 /// <summary>
 /// Constuctor taking another FencePoint as an argument. The result is a new clone of the FencePoint
 /// </summary>
 public FencePoint(FencePoint pt) : base()
 {
     Assign(pt);
 }