/// <summary> /// Вычисляет квадрат расстояния между двумя точками. /// </summary> /// /// <param name="anotherPoint">Точка, до которой вычисляется расстояние.</param> /// /// <returns>Вычисляет квадрат расстояния между этой и точкой /// <paramref name="anotherPoint"/>.</returns> /// public double SquaredDistanceTo( DoublePoint anotherPoint ) { double dx = X - anotherPoint.X; double dy = Y - anotherPoint.Y; return dx * dx + dy * dy; }
/// <summary> /// Вычисляет эвклидово расстояние между точками. /// </summary> /// /// <param name="anotherPoint">Точка, до которой вычисляется расстояние.</param> /// /// <returns>Вычисляет эвклидово расстояние между этой и точкой /// <paramref name="anotherPoint"/>.</returns> /// public double DistanceTo( DoublePoint anotherPoint ) { double dx = X - anotherPoint.X; double dy = Y - anotherPoint.Y; return System.Math.Sqrt( dx * dx + dy * dy ); }
/// <summary> /// Division operator - divides coordinates of the specified point by scalar value. /// </summary> /// /// <param name="point">Point to divide coordinates of.</param> /// <param name="factor">Division factor.</param> /// /// <returns>Returns new point which coordinates equal to coordinates of /// the specified point divided by specified value.</returns> /// public static DoublePoint Divide( DoublePoint point, double factor ) { return new DoublePoint( point.X / factor, point.Y / factor ); }
/// <summary> /// Multiplication operator - multiplies coordinates of the specified point by scalar value. /// </summary> /// /// <param name="point">Point to multiply coordinates of.</param> /// <param name="factor">Multiplication factor.</param> /// /// <returns>Returns new point which coordinates equal to coordinates of /// the specified point multiplied by specified value.</returns> /// public static DoublePoint Multiply( DoublePoint point, double factor ) { return new DoublePoint( point.X * factor, point.Y * factor ); }
/// <summary> /// Subtraction operator - subtracts scalar from the specified point. /// </summary> /// /// <param name="point">Point to decrease coordinates of.</param> /// <param name="valueToSubtract">Value to subtract from coordinates of the specified point.</param> /// /// <returns>Returns new point which coordinates equal to coordinates of /// the specified point decreased by specified value.</returns> /// public static DoublePoint Subtract( DoublePoint point, double valueToSubtract ) { return new DoublePoint( point.X - valueToSubtract, point.Y - valueToSubtract ); }
/// <summary> /// Addition operator - adds scalar to the specified point. /// </summary> /// /// <param name="point">Point to increase coordinates of.</param> /// <param name="valueToAdd">Value to add to coordinates of the specified point.</param> /// /// <returns>Returns new point which coordinates equal to coordinates of /// the specified point increased by specified value.</returns> /// public static DoublePoint Add( DoublePoint point, double valueToAdd ) { return new DoublePoint( point.X + valueToAdd, point.Y + valueToAdd ); }
/// <summary> /// Subtraction operator - subtracts values of two points. /// </summary> /// /// <param name="point1">Point to subtract from.</param> /// <param name="point2">Point to subtract.</param> /// /// <returns>Returns new point which coordinates equal to difference of corresponding /// coordinates of specified points.</returns> /// public static DoublePoint Subtract( DoublePoint point1, DoublePoint point2 ) { return new DoublePoint( point1.X - point2.X, point1.Y - point2.Y ); }
/// <summary> /// Addition operator - adds values of two points. /// </summary> /// /// <param name="point1">First point for addition.</param> /// <param name="point2">Second point for addition.</param> /// /// <returns>Returns new point which coordinates equal to sum of corresponding /// coordinates of specified points.</returns> /// public static DoublePoint Add( DoublePoint point1, DoublePoint point2 ) { return new DoublePoint( point1.X + point2.X, point1.Y + point2.Y ); }