Class Point
Structure for representing a pair of coordinates of double, decimal, double or int type.
Inheritance
Namespace: ISynergy.Framework.Core.Points
Assembly: ISynergy.Framework.Core.dll
Syntax
public class Point : IComparable<Point>
Remarks
The structure is used to store a pair of numeric point coordinates with single precision.
Sample usage:
// assigning coordinates in the constructor
Point p1 = new Point( 10, 20 );
// creating a point and assigning coordinates later
Point p2;
p2.X = 30;
p2.Y = 40;
// calculating distance between two points
double distance = p1.DistanceTo( p2 );
Constructors
View SourcePoint(Decimal, Decimal, Boolean, Int32)
Initializes a new instance of the Point structure.
Declaration
public Point(decimal x, decimal y, bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | x | X axis coordinate. |
System.Decimal | y | Y axis coordinate. |
System.Boolean | round | |
System.Int32 | decimals |
Point(Double, Double, Boolean, Int32)
Initializes a new instance of the Point structure.
Declaration
public Point(double x, double y, bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | X axis coordinate. |
System.Double | y | Y axis coordinate. |
System.Boolean | round | |
System.Int32 | decimals |
Point(Int32, Int32, Boolean, Int32)
Initializes a new instance of the Point structure.
Declaration
public Point(int x, int y, bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | X axis coordinate. |
System.Int32 | y | Y axis coordinate. |
System.Boolean | round | |
System.Int32 | decimals |
Point(Int64, Int64, Boolean, Int32)
Initializes a new instance of the Point structure.
Declaration
public Point(long x, long y, bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | x | X axis coordinate. |
System.Int64 | y | Y axis coordinate. |
System.Boolean | round | |
System.Int32 | decimals |
Point(Single, Single, Boolean, Int32)
Initializes a new instance of the Point structure.
Declaration
public Point(float x, float y, bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | X axis coordinate. |
System.Single | y | Y axis coordinate. |
System.Boolean | round | |
System.Int32 | decimals |
Properties
View SourceX
X coordinate.
Declaration
public double X { get; }
Property Value
Type | Description |
---|---|
System.Double |
Y
Y coordinate.
Declaration
public double Y { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
View SourceAdd(Point, Point)
Addition operator - adds values of two points.
Declaration
public static Point Add(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | First point for addition. |
Point | point2 | Second point for addition. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to sum of corresponding coordinates of specified points. |
Add(Point, Double)
Addition operator - adds scalar to the specified point.
Declaration
public static Point Add(Point point, double valueToAdd)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to increase coordinates of. |
System.Double | valueToAdd | Value to add to coordinates of the specified point. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point increased by specified value. |
CompareTo(Point)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | other | An object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Int32 | A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes |
DistanceTo(Point)
Calculate Euclidean distance between two points.
Declaration
public double DistanceTo(Point anotherPoint)
Parameters
Type | Name | Description |
---|---|---|
Point | anotherPoint | Point to calculate distance to. |
Returns
Type | Description |
---|---|
System.Double | Returns Euclidean distance between this point and
|
Divide(Point, Double)
Division operator - divides coordinates of the specified point by scalar value.
Declaration
public static Point Divide(Point point, double factor)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to divide coordinates of. |
System.Double | factor | Division factor. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point divided by specified value. |
Equals(Object)
Check if this instance of Point equal to the specified one.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Another point to check equalty to. |
Returns
Type | Description |
---|---|
System.Boolean | Return true if objects are equal. |
EuclideanNorm(Boolean, Int32)
Calculate Euclidean norm of the vector comprised of the point's coordinates - distance from (0, 0) in other words.
Declaration
public double EuclideanNorm(bool round = false, int decimals = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | round | |
System.Int32 | decimals |
Returns
Type | Description |
---|---|
System.Double | Returns point's distance from (0, 0) point. |
GetHashCode()
Get hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Returns the hash code for this instance. |
Multiply(Point, Double)
Multiplication operator - multiplies coordinates of the specified point by scalar value.
Declaration
public static Point Multiply(Point point, double factor)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to multiply coordinates of. |
System.Double | factor | Multiplication factor. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point multiplied by specified value. |
SquaredDistanceTo(Point)
Calculate squared Euclidean distance between two points.
Declaration
public double SquaredDistanceTo(Point anotherPoint)
Parameters
Type | Name | Description |
---|---|---|
Point | anotherPoint | Point to calculate distance to. |
Returns
Type | Description |
---|---|
System.Double | Returns squared Euclidean distance between this point and
|
Subtract(Point, Point)
Subtraction operator - subtracts values of two points.
Declaration
public static Point Subtract(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | Point to subtract from. |
Point | point2 | Point to subtract. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to difference of corresponding coordinates of specified points. |
Subtract(Point, Double)
Subtraction operator - subtracts scalar from the specified point.
Declaration
public static Point Subtract(Point point, double valueToSubtract)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to decrease coordinates of. |
System.Double | valueToSubtract | Value to subtract from coordinates of the specified point. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point decreased by specified value. |
ToString()
Get string representation of the class.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | Returns string, which contains values of the point in readable form. |
Operators
View SourceAddition(Point, Point)
Addition operator - adds values of two points.
Declaration
public static Point operator +(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | First point for addition. |
Point | point2 | Second point for addition. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to sum of corresponding coordinates of specified points. |
Addition(Point, Double)
Addition operator - adds scalar to the specified point.
Declaration
public static Point operator +(Point point, double valueToAdd)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to increase coordinates of. |
System.Double | valueToAdd | Value to add to coordinates of the specified point. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point increased by specified value. |
Division(Point, Double)
Division operator - divides coordinates of the specified point by scalar value.
Declaration
public static Point operator /(Point point, double factor)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to divide coordinates of. |
System.Double | factor | Division factor. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point divided by specified value. |
Equality(Point, Point)
Equality operator - checks if two points have equal coordinates.
Declaration
public static bool operator ==(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | First point to check. |
Point | point2 | Second point to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if coordinates of specified points are equal. |
Inequality(Point, Point)
Inequality operator - checks if two points have different coordinates.
Declaration
public static bool operator !=(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | First point to check. |
Point | point2 | Second point to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if coordinates of specified points are not equal. |
Multiply(Point, Double)
Multiplication operator - multiplies coordinates of the specified point by scalar value.
Declaration
public static Point operator *(Point point, double factor)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to multiply coordinates of. |
System.Double | factor | Multiplication factor. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point multiplied by specified value. |
Subtraction(Point, Point)
Subtraction operator - subtracts values of two points.
Declaration
public static Point operator -(Point point1, Point point2)
Parameters
Type | Name | Description |
---|---|---|
Point | point1 | Point to subtract from. |
Point | point2 | Point to subtract. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to difference of corresponding coordinates of specified points. |
Subtraction(Point, Double)
Subtraction operator - subtracts scalar from the specified point.
Declaration
public static Point operator -(Point point, double valueToSubtract)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Point to decrease coordinates of. |
System.Double | valueToSubtract | Value to subtract from coordinates of the specified point. |
Returns
Type | Description |
---|---|
Point | Returns new point which coordinates equal to coordinates of the specified point decreased by specified value. |