Example #1
0
 /// <summary>
 /// Constructs an MBR encapsulating the coordinate pair <paramref name="p"/>.
 /// </summary>
 /// <param name="p">A point.</param>
 public Mbr(ICoordinatePair <double> p)
 {
     if (null == p)
     {
         throw new ArgumentNullException("p");
     }
     Contract.EndContractBlock();
     X = new Range(p.X);
     Y = new Range(p.Y);
 }
Example #2
0
 /// <summary>
 /// Creates a point with the same coordinates as the given point.
 /// </summary>
 /// <param name="p">A coordinate pair.</param>
 public Point2(ICoordinatePair <TValue> p)
 {
     if (p == null)
     {
         throw new ArgumentNullException("p");
     }
     Contract.EndContractBlock();
     X = p.X;
     Y = p.Y;
 }
Example #3
0
 /// <summary>
 /// Creates a 2D vector.
 /// </summary>
 /// <param name="v">The coordinate tuple to copy values from.</param>
 public Vector2(ICoordinatePair <double> v)
 {
     if (null == v)
     {
         throw new ArgumentNullException("v");
     }
     Contract.EndContractBlock();
     X = v.X;
     Y = v.Y;
 }
Example #4
0
 /// <summary>
 /// Creates a point with the same coordinates as the given <paramref name="point"/>.
 /// </summary>
 /// <param name="point">A coordinate pair.</param>
 public Point2(ICoordinatePair <double> point)
 {
     if (null == point)
     {
         throw new ArgumentNullException("point");
     }
     Contract.EndContractBlock();
     X = point.X;
     Y = point.Y;
 }
Example #5
0
 /// <summary>
 /// Constructs an MBR encapsulating the coordinate pairs <paramref name="a"/> and <paramref name="b"/>.
 /// </summary>
 /// <param name="a">A point.</param>
 /// <param name="b">A point.</param>
 public Mbr(ICoordinatePair <double> a, ICoordinatePair <double> b)
 {
     if (a == null)
     {
         throw new ArgumentNullException("a");
     }
     if (b == null)
     {
         throw new ArgumentNullException("b");
     }
     Contract.EndContractBlock();
     X = new Range(a.X, b.X);
     Y = new Range(a.Y, b.Y);
 }
Example #6
0
        public void equal_coordinate_pair()
        {
            var a = new Point2(1, 2);
            var b = new Point2(3, 4);
            var c = new Point2(3, 4);
            ICoordinatePair <double> nil = null;

            Assert.False(a.Equals((ICoordinatePair <double>)b));
            Assert.False(a.Equals((ICoordinatePair <double>)c));
            Assert.False(b.Equals((ICoordinatePair <double>)a));
            Assert.True(b.Equals((ICoordinatePair <double>)c));
            Assert.False(c.Equals((ICoordinatePair <double>)a));
            Assert.True(c.Equals((ICoordinatePair <double>)b));
            Assert.False(a.Equals(nil));
        }
Example #7
0
 /// <inheritdoc/>
 [Pure] public bool Equals(ICoordinatePair <double> other)
 {
     return(!ReferenceEquals(null, other) && X == other.X && Y == other.Y);
 }