Point2f

References
Represents the two coordinates of a point in two-dimensional space, using float-precision floating point numbers.

Constructors

Point2f

#Since v5.0
public Point2f(double x, double y)
Initializes a new two-dimensional point from two double-precision floating point numbers as coordinates.

Coordinates will be internally converted to floating point numbers. This might cause precision loss.

x (double)X component of vector.
y (double)Y component of vector.

Point2f

#Since v5.0
public Point2f(float x, float y)
Initializes a new two-dimensional point from two components.
x (float)X component of vector.
y (float)Y component of vector.

Properties

IsValid

#Since v5.0
public bool IsValid { get; }
Gets a value indicating whether this point is considered valid.

Unset

#Since v5.0
public static Point2f Unset { get; }
Gets the standard unset point.

X

#Since v5.0
public float X { get; set; }
Gets or sets the X (first) component of the vector.

Y

#Since v5.0
public float Y { get; set; }
Gets or sets the Y (second) component of the vector.

Indexers

this[]

#
public float this[int index] { get; set; }
Accesses the coordinates of this point.
index (int)Either 0 or 1.
If index is 0, the X (first) coordinate. If index is 1, the Y (second) coordinate.

Methods

Add

#
public static Point2f Add(Point2f point, Vector2f vector)
Sums up a point and a vector, and returns a new point.

(Provided for languages that do not support operator overloading. You can use the + operator otherwise)

point (Point2f)A point.
vector (Vector2f)A vector.
A new point that results from the addition of point and vector.

Add

#
public static Point2f Add(Vector2f vector, Point2f point)
Sums up a point and a vector, and returns a new point.

(Provided for languages that do not support operator overloading. You can use the + operator otherwise)

vector (Vector2f)A vector.
point (Point2f)A point.
A new point that results from the addition of point and vector.

CompareTo

#Since v5.0
[ConstOperation] public int CompareTo(Point2f other)
Compares this Point2f with another Point2f.

Coordinates evaluation priority is first X, then Y.

other (Point2f)The other Point2f to use in comparison.

0: if this is identical to other

-1: if this.X < other.X

-1: if this.X == other.X and this.Y < other.Y

+1: otherwise.

DistanceTo

#
[ConstOperation] public double DistanceTo(Point2f other)
Computes the distance between two points.
other (Point2f)Other point for distance measurement.
The length of the line between this and the other point; or 0 if any of the points is not valid.

DistanceToSquared

#Since v7.14
[ConstOperation] public double DistanceToSquared(Point2f other)
Computes the squared distance between two points.
other (Point2f)Other point for distance measurement.
The squared length of the line between this and the other point; or 0 if any of the points is not valid.

Divide

#
public static Point2f Divide(Point2f point, float t)
Divides a Point2f by a scalar.

(Provided for languages that do not support operator overloading. You can use the / operator otherwise)

point (Point2f)A point.
t (float)A number.
A new point that is coordinate-wise divided by t.

EpsilonEquals

#Since v5.4
[ConstOperation] public bool EpsilonEquals(Point2f other, float epsilon)
Check that all values in other are within epsilon of the values in this
other (Point2f)
epsilon (float)
EpsilonEquals

Equals

#
[ConstOperation] public override bool Equals(object obj)
Determines whether the specified System.Object is a Point2f and has the same values as the present point.
obj (object)The specified object.
true if obj is Point2f and has the same coordinates as this; otherwise false.
ValueType.Equals

Equals

#Since v5.0
[ConstOperation] public bool Equals(Point2f point)
Determines whether the specified Point2f has the same values as the present point.
point (Point2f)The specified point.
true if point has the same coordinates as this; otherwise false.

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Computes a hash number that represents the current point.
A hash code that is not unique for each point.

Multiply

#
public static Point2f Multiply(float t, Point2f point)
Multiplies a Point2f by a scalar.

(Provided for languages that do not support operator overloading. You can use the * operator otherwise)

t (float)A number.
point (Point2f)A point.
A new point that is coordinate-wise multiplied by t.

Multiply

#
public static Point2f Multiply(Point2f point, float t)
Multiplies a Point2f by a scalar.

(Provided for languages that do not support operator overloading. You can use the * operator otherwise)

point (Point2f)A point.
t (float)A number.
A new point that is coordinate-wise multiplied by t.

Negate

#
public static Point2f Negate(Point2f point)
Computes the additive inverse of all coordinates in the point, and returns the new point.

(Provided for languages that do not support operator overloading. You can use the - unary operator otherwise)

point (Point2f)A point.
A point value that, when summed with the point input, yields the origin.

Subtract

#
public static Point2f Subtract(Point2f point, Vector2f vector)
Subtracts a vector from a point.

(Provided for languages that do not support operator overloading. You can use the - operator otherwise)

point (Point2f)A point.
vector (Vector2f)A vector.
A new point that is the difference of point minus vector.

Subtract

#
public static Vector2f Subtract(Point2f point1, Point2f point2)
Subtracts the second point from the first point.

(Provided for languages that do not support operator overloading. You can use the - operator otherwise)

point1 (Point2f)A point (minuend).
point2 (Point2f)A point (subtrahend).
A new vector that is point1 coordinate-wise subtracted by point2.
Explicit

IComparable.CompareTo

#
[ConstOperation] int IComparable.CompareTo(object obj)
obj (object)

ToString

#
[ConstOperation] public override string ToString()
Constructs the string representation for the current point.
The point representation in the form X,Y.

ToString

#Since v7.0
[ConstOperation] public string ToString(string format, IFormatProvider formatProvider)
Formats the value of the current instance using the specified format.
format (string)The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.
formatProvider (IFormatProvider)The provider to use to format the value. -or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
The value of the current instance in the specified format.

Operators

OperationResultDescription
Vector2f+Point2fPoint2fSums up a point and a vector, and returns a new point.
Point2f+Point2fVector2fSums two Point2fs.
Point2f/floatPoint2fDivides a Point2f by a scalar.
Point2f==Point2fboolDetermines whether two Point2f have equal values.
Point2f>Point2fboolDetermines whether the first specified Point2f comes after (has superior sorting value than) the second point.

Coordinates evaluation priority is first X, then Y.

Point2f>=Point2fboolDetermines whether the first specified Point2f comes after (has superior sorting value than) the second point, or it is equal to it.

Coordinates evaluation priority is first X, then Y.

Point2f!=Point2fboolDetermines whether two Point2f have different values.
Point2f<Point2fboolDetermines whether the first specified Point2f comes before (has inferior sorting value than) the second point.

Coordinates evaluation priority is first X, then Y.

Point2f<=Point2fboolDetermines whether the first specified Point2f comes before (has inferior sorting value than) the second point, or it is equal to it.

Coordinates evaluation priority is first X, then Y.

float*Point2fPoint2fMultiplies a Point2f by a scalar.
Point2f*floatPoint2fMultiplies a Point2f by a scalar.
Point2f-Vector2fPoint2fSubtracts a vector from a point.
Point2f-Point2fVector2fSubtracts two Point2fs.
-Point2fPoint2fComputes the additive inverse of all coordinates in the point, and returns the new point.

Convertors

OperationResultDescription
explicitPoint2dPoint2fConverts a double-precision point in a single-precision point. Needs explicit casting to help retain precision.