/// <summary> /// Returns the distance between the two specified points. /// </summary> /// <param name="point1">Point 1.</param> /// <param name="point2">Point 2.</param> /// <returns>The distance between the two points.</returns> public static double Delta(IntPoint2D point1, IntPoint2D point2) { double part1 = Math.Pow((point2.X - point1.X), 2); double part2 = Math.Pow((point2.Y - point1.Y), 2); return(Math.Sqrt(part1 + part2)); }
/// <summary> /// Divides B from A /// </summary> /// <param name="a">A</param> /// <param name="b">B</param> /// <returns></returns> public static IntPoint2D operator /(IntPoint2D a, Int64 b) { if (a == null) { a = new IntPoint2D(); } return(new IntPoint2D(a.X / b, a.Y / b)); }
/// <summary> /// Multiplies A and B /// </summary> /// <param name="a">A</param> /// <param name="b">B</param> /// <returns></returns> public static IntPoint2D operator *(Int64 a, IntPoint2D b) { if (b == null) { b = new IntPoint2D(); } return(new IntPoint2D(a * b.X, a * b.Y)); }
/// <summary> /// Subtracts the specified value. /// </summary> /// <param name="a">Value to subtract</param> /// <returns></returns> public static IntPoint2D operator -(IntPoint2D a) { if (a == null) { a = new IntPoint2D(); } return(new IntPoint2D(-a.X, -a.Y)); }
/// <summary> /// Determines if this point is equal to the specified point. /// </summary> /// <param name="point">The other point.</param> /// <returns>True, if equal; otherwise, false</returns> public bool Equals(IntPoint2D point) { if ((object)point == null) { return(false); } // Return true if the fields match: return(X == point.X && Y == point.Y); }
/// <summary> /// Adds a to b. /// </summary> /// <param name="a">A</param> /// <param name="b">B</param> /// <returns></returns> public static IntPoint2D operator +(IntPoint2D a, IntPoint2D b) { if (a == null) { a = new IntPoint2D(); } if (b == null) { b = new IntPoint2D(); } return(a.Offset(b.X, b.Y)); }
/// <summary> /// Returns a copy of this point offset by X and Y from the specified point. /// </summary> /// <param name="offsets">The specified offsets.</param> /// <returns>An offset copy of this point.</returns> public IntPoint2D Offset(IntPoint2D offsets) { return(Offset(offsets.X, offsets.Y)); }
/// <summary> /// Initializes a new instance of the <see cref="IntPoint2D"/> class. /// </summary> /// <param name="pt">The point to copy.</param> public IntPoint2D(IntPoint2D pt) { X = pt.X; Y = pt.Y; }