Show / Hide Table of Contents

Class Point

Represents an thread-safe mutable positive-infinite enumerable of coordinates that correspond to a location in a space (Space<C> object).

Inheritance
System.Object
Point
Implements
System.Collections.Generic.IEnumerable<System.Int32>
System.Collections.IEnumerable
System.ICloneable
Namespace: MultidimLib
Syntax
public sealed class Point : IEnumerable<int>, IEnumerable, ICloneable

Constructors

Point(IEnumerable<Int32>)

Initializes a new point (Point) with the provided coordinates. If no coordinate is provided, then the point is initialized with a unique coordinate equals to 0.

Declaration
public Point(IEnumerable<int> coordinates)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Int32> coordinates

The point's coordinates.

Point(Int32[])

Calls the Point(IEnumerable<Int32>) constructor.

Declaration
public Point(params int[] coordinates)
Parameters
Type Name Description
System.Int32[] coordinates

The coordinates to be passed onto the Point(IEnumerable<Int32>) constructor.

Properties

Item[Int32]

Gets or sets the coordinate value at the specified index. When getting, if the specified coordinate index is greater than the number of representative coordinates, it returns 0. In the same way when setting, it emulates every intermediate coordinate to be 0 until the coordinate at the specified index is reched.

Declaration
public int this[int coordinateIndex] { get; set; }
Parameters
Type Name Description
System.Int32 coordinateIndex

The 0-based index of the coordinate to get or set its value.

Property Value
Type Description
System.Int32

The coordinate at the specified index.

Exceptions
Type Condition
PointException

Thrown when the provided coordinate index is lower than 0.

Methods

Clone()

Makes a copy of the current point.

Declaration
public Point Clone()

Count()

Counts and returns the number of representative coordinates of the current point, which are the first one and each next coordinate found until the last one different from 0.

Declaration
public int Count()

DistanceTo(Point)

Computes the euclidean distance from a provided reference point to the current point.

Declaration
public double DistanceTo(Point referencePoint)
Parameters
Type Name Description
Point referencePoint

The point to which to calculate the euclidean distance from the current point.

DistanceToOrigin()

Computes the euclidean distance from a point at coordinate 0 to the current point.

Declaration
public double DistanceToOrigin()

Equals(Point)

Determines whether a provided point is equal to the current point by checking each points' individual representative coordinates (value equality).

Declaration
public bool Equals(Point point)
Parameters
Type Name Description
Point point

The point against which to compare equality.

Equals(Object)

Determines whether a provided object is the current point (reference equality).

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object against which to compare equality.

Overrides
System.Object.Equals(System.Object)

FromString(String)

Initializes a new point (Point object) by parsing a specified string of the form: "(c_0, c_1, ..., c_n)" where c_0 is the first point's coordinate, c_1 the second one, and c_n the n-th one. White space is irrelevant. If the specified string is empty or white space, this method returns null.

Declaration
public static Point FromString(string pointString)
Parameters
Type Name Description
System.String pointString

The point's string to be parsed.

Exceptions
Type Condition
PointException

Thrown when the specified point's string does not match the pattern.

ToString()

Returns a string representation of the current point formed as: "(c_0, c_1, ..., c_n)" where c_0 is the first point's representative coordinate, c_1 the second one, and c_n the n-th one.

Declaration
public override string ToString()
Overrides
System.Object.ToString()

Explicit Interface Implementations

IEnumerable<Int32>.GetEnumerator()

Returns an enumerator that iterates over the representative coordinates of the current point.

Declaration
public IEnumerator<int> IEnumerable<int>.GetEnumerator()

Extension Methods

Initialization.C<T>(T)
Initialization.P(IEnumerable<Int32>)
Back to top MultidimLib from Ecuador.