Struct Point
Universal type for a set of two-dimensional coordinates.
Inherited Members
Namespace: TheXDS.MCART.Types
Assembly: MCART.dll
Syntax
public struct Point : IVector, IEquatable<IVector>, IEquatable<Vector2>, IFormattable, IEquatable<Point>
Constructors
| Edit this page View SourcePoint()
Initializes a new instance of the Point structure.
Declaration
public Point()
Point(double, double)
Universal type for a set of two-dimensional coordinates.
Declaration
public Point(double x, double y)
Parameters
| Type | Name | Description |
|---|---|---|
| double | x | The x coordinate. |
| double | y | The y coordinate. |
Fields
| Edit this page View SourceNowhere
Gets a point that does not represent any position. This field is read-only.
Declaration
public static readonly Point Nowhere
Field Value
| Type | Description |
|---|---|
| Point |
Origin
Gets a point at the origin. This field is read-only.
Declaration
public static readonly Point Origin
Field Value
| Type | Description |
|---|---|
| Point | A Point with its coordinates at the origin. |
Properties
| Edit this page View SourceX
X coordinate.
Declaration
public double X { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Y
Y coordinate.
Declaration
public double Y { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Methods
| Edit this page View SourceAngle()
Calculates the angle formed by the line connecting the origin and this Point with respect to the horizontal X axis.
Declaration
public readonly double Angle()
Returns
| Type | Description |
|---|---|
| double | The calculated angle. |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override readonly bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceEquals(IVector?)
Compares the equality of the vectors.
Declaration
public readonly bool Equals(IVector? other)
Parameters
| Type | Name | Description |
|---|---|---|
| IVector | other | The IVector to compare against. |
Returns
| Type | Description |
|---|---|
| bool | true if all vectors of both objects are equal; false otherwise. |
Equals(Point)
Compares the equality of the point vectors.
Declaration
public readonly bool Equals(Point other)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | other | The Point to compare against. |
Returns
| Type | Description |
|---|---|
| bool | true if all vectors of both points are equal; otherwise, false. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | The hash code for this instance. |
Overrides
| Edit this page View SourceMagnitude()
Calculates the magnitude of the coordinates.
Declaration
public readonly double Magnitude()
Returns
| Type | Description |
|---|---|
| double | The resulting magnitude between the point and the origin. |
Magnitude(double, double)
Calculates the magnitude of the coordinates from the specified coordinates.
Declaration
public readonly double Magnitude(double fromX, double fromY)
Parameters
| Type | Name | Description |
|---|---|---|
| double | fromX | X coordinate of the origin. |
| double | fromY | Y coordinate of the origin. |
Returns
| Type | Description |
|---|---|
| double | The resulting magnitude between the point and the specified coordinates. |
Magnitude(Point)
Calculates the magnitude of the coordinates from the specified point.
Declaration
public readonly double Magnitude(Point fromPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | fromPoint | Reference point for calculating the magnitude. |
Returns
| Type | Description |
|---|---|
| double | The resulting magnitude between both points. |
Parse(string)
Creates a Point from a string.
Declaration
public static Point Parse(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The value from which to create a Point. |
Returns
| Type | Description |
|---|---|
| Point | The created Point. |
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown if the conversion fails. |
ToString()
Converts this object to its string representation.
Declaration
public override readonly string ToString()
Returns
| Type | Description |
|---|---|
| string | A string representation of this object. |
Overrides
| Edit this page View SourceToString(string?)
Converts this object to its string representation.
Declaration
public readonly string ToString(string? format)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | Format to use. |
Returns
| Type | Description |
|---|---|
| string | A string representation of this object. |
ToString(string?, IFormatProvider?)
Converts this object to its string representation.
Declaration
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | Format to use. |
| IFormatProvider | formatProvider | Optional parameter. Culture-specific format provider to use for formatting this object's string representation. If omitted, CurrentCulture will be used. |
Returns
| Type | Description |
|---|---|
| string | A string representation of this object. |
TryParse(string, out Point)
Attempts to create a Point from a string.
Declaration
public static bool TryParse(string value, out Point point)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The value from which to create a Point. |
| Point | point | The created Point. |
Returns
| Type | Description |
|---|---|
| bool |
WithinBox(in double, in double, in double, in double)
Determines if the point is within the rectangle defined by the specified coordinates.
Declaration
public readonly bool WithinBox(in double x1, in double y1, in double x2, in double y2)
Parameters
| Type | Name | Description |
|---|---|---|
| double | x1 | The first X coordinate. |
| double | y1 | The first Y coordinate. |
| double | x2 | The second X coordinate. |
| double | y2 | The second Y coordinate. |
Returns
| Type | Description |
|---|---|
| bool |
WithinBox(in Point, in Point)
Determines if the point is within the rectangle formed by the specified points.
Declaration
public readonly bool WithinBox(in Point p1, in Point p2)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p1 | Point 1. |
| Point | p2 | Point 2. |
Returns
| Type | Description |
|---|---|
| bool |
WithinBox(in Range<double>, in Range<double>)
Determines if the point is within the rectangle defined by the specified ranges.
Declaration
public readonly bool WithinBox(in Range<double> x, in Range<double> y)
Parameters
| Type | Name | Description |
|---|---|---|
| Range<double> | x | Range of values for the X axis. |
| Range<double> | y | Range of values for the Y axis. |
Returns
| Type | Description |
|---|---|
| bool |
WithinBox(in Size)
Determines if the point is within the rectangle defined by the specified size.
Declaration
public readonly bool WithinBox(in Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | Size of the rectangle. |
Returns
| Type | Description |
|---|---|
| bool |
WithinBox(in Size, in Point)
Determines if the point is within the rectangle defined by the specified coordinates.
Declaration
public readonly bool WithinBox(in Size size, in Point topLeft)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | Size of the rectangle. |
| Point | topLeft | Coordinates of the top-left corner. |
Returns
| Type | Description |
|---|---|
| bool |
WithinCircle(in Point, in double)
Determines if the point is within the specified circle.
Declaration
public readonly bool WithinCircle(in Point center, in double radius)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | center | Center point of the circle. |
| double | radius | Radius of the circle. |
Returns
| Type | Description |
|---|---|
| bool |
Operators
| Edit this page View Sourceoperator +(Point, double)
Performs addition on a point.
Declaration
public static Point operator +(Point l, double r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| double | r | Addition operand. |
Returns
| Type | Description |
|---|---|
| Point | A new Point whose vectors are the sum of the original
vectors + |
operator +(Point, IVector)
Performs addition on points.
Declaration
public static Point operator +(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| IVector | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The sum of the vectors of the points. |
operator +(Point, Point)
Performs addition on points.
Declaration
public static Point operator +(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The sum of the vectors of the points. |
operator --(Point)
Decrements the point's vectors by 1.
Declaration
public static Point operator --(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p | Point to decrement. |
Returns
| Type | Description |
|---|---|
| Point | A point with its vectors decremented by 1. |
operator /(Point, double)
Performs scalar division on the point.
Declaration
public static Point operator /(Point l, double r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| double | r | Division operand. |
Returns
| Type | Description |
|---|---|
| Point | A new Point with vectors being the quotient of
original vectors / |
operator /(Point, IVector)
Performs division operation on points.
Declaration
public static Point operator /(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| IVector | r | Vector operand. |
Returns
| Type | Description |
|---|---|
| Point | The quotient of the vectors of the point and vector. |
operator /(Point, Point)
Performs division operation on points.
Declaration
public static Point operator /(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The quotient of the vectors of the points. |
operator ==(Point, IVector)
Compares the equality of the point vectors with a 2D vector.
Declaration
public static bool operator ==(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point to compare. |
| IVector | r | 2D vector to compare against. |
Returns
| Type | Description |
|---|---|
| bool | true if all vectors of both points are equal; otherwise, false. |
operator ==(Point, Point)
Compares the equality of the point vectors.
Declaration
public static bool operator ==(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Object to compare. |
| Point | r | Object to compare against. |
Returns
| Type | Description |
|---|---|
| bool |
implicit operator Point(Point)
Declaration
public static implicit operator Point(Point x)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | x | The Point to convert. |
Returns
| Type | Description |
|---|---|
| Point |
implicit operator Point(Vector2)
Declaration
public static implicit operator Point(Vector2 p)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | p | Vector2 value to be converted. |
Returns
| Type | Description |
|---|---|
| Point |
implicit operator Point(Point)
Declaration
public static implicit operator Point(Point x)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | x | The Point to convert. |
Returns
| Type | Description |
|---|---|
| Point |
implicit operator Vector2(Point)
Declaration
public static implicit operator Vector2(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p | Point value to be converted. |
Returns
| Type | Description |
|---|---|
| Vector2 |
operator ++(Point)
Increments the point's vectors by 1.
Declaration
public static Point operator ++(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p | Point to increment. |
Returns
| Type | Description |
|---|---|
| Point | A point with its vectors incremented by 1. |
operator !=(Point, IVector)
Compares the difference of the point vectors with a 2D vector.
Declaration
public static bool operator !=(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point to compare. |
| IVector | r | 2D vector to compare against. |
Returns
| Type | Description |
|---|---|
| bool | true if the vectors of both points are different; otherwise, false. |
operator !=(Point, Point)
Compares the difference of the point vectors.
Declaration
public static bool operator !=(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| bool | true if the vectors of both points are different; otherwise, false. |
operator %(Point, double)
Performs a modulus operation on the point.
Declaration
public static Point operator %(Point l, double r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| double | r | Modulus operand. |
Returns
| Type | Description |
|---|---|
| Point | A new Point whose vectors are the modulus of the
original vectors % |
operator %(Point, IVector)
Performs modulus operation on points.
Declaration
public static Point operator %(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| IVector | r | Vector operand. |
Returns
| Type | Description |
|---|---|
| Point | The modulus of the vectors of the point and vector. |
operator %(Point, Point)
Performs modulus operation on points.
Declaration
public static Point operator %(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The modulus of the vectors of the points. |
operator *(Point, double)
Performs scalar multiplication on the point.
Declaration
public static Point operator *(Point l, double r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| double | r | Multiplication operand. |
Returns
| Type | Description |
|---|---|
| Point | A new Point with vectors being the product of
original vectors * |
operator *(Point, IVector)
Performs multiplication operation on points.
Declaration
public static Point operator *(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| IVector | r | Vector operand. |
Returns
| Type | Description |
|---|---|
| Point | The product of the vectors of the point and vector. |
operator *(Point, Point)
Performs multiplication operation on points.
Declaration
public static Point operator *(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The product of the vectors of the points. |
operator -(Point, double)
Performs subtraction operation on the point.
Declaration
public static Point operator -(Point l, double r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| double | r | Subtraction operand. |
Returns
| Type | Description |
|---|---|
| Point | A new Point with vectors being the difference of
original vectors - |
operator -(Point, IVector)
Performs subtraction on points.
Declaration
public static Point operator -(Point l, IVector r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| IVector | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The difference of the vectors of the points. |
operator -(Point, Point)
Performs subtraction on points.
Declaration
public static Point operator -(Point l, Point r)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | l | Point 1. |
| Point | r | Point 2. |
Returns
| Type | Description |
|---|---|
| Point | The difference of the vectors of the points. |
operator -(Point)
Inverts the sign of the point's vectors.
Declaration
public static Point operator -(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p | Point to operate on. |
Returns
| Type | Description |
|---|---|
| Point | A point with inverted vector signs. |
operator +(Point)
Converts the point's vectors to positive values.
Declaration
public static Point operator +(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | p | Point to operate on. |
Returns
| Type | Description |
|---|---|
| Point | A point with positive vectors. |