Point2f

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

Constructors

Point2f

#Since v5.0
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.

public Point2f(
x,
X component of vector.
y
Y component of vector.
)

Point2f

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

Properties

IsValid

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

Unset

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

X

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

Y

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

Indexers

this[]

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

Methods

Add

#
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)

public static Point2f Add(
point,
A point.
vector
A vector.
)
A new point that results from the addition of point and vector.

Add

#
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)

public static Point2f Add(
vector,
A vector.
point
A point.
)
A new point that results from the addition of point and vector.

CompareTo

#Since v5.0
Compares this Point2f with another Point2f.

Coordinates evaluation priority is first X, then Y.

[ConstOperation] public int CompareTo(
other
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

#
Computes the distance between two points.
[ConstOperation] public double DistanceTo(
other
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
Computes the squared distance between two points.
[ConstOperation] public double DistanceToSquared(
other
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

#
Divides a Point2f by a scalar.

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

public static Point2f Divide(
point,
A point.
t
A number.
)
A new point that is coordinate-wise divided by t.

EpsilonEquals

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

Equals

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

Equals

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

GetHashCode

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

Multiply

#
Multiplies a Point2f by a scalar.

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

public static Point2f Multiply(
t,
A number.
point
A point.
)
A new point that is coordinate-wise multiplied by t.

Multiply

#
Multiplies a Point2f by a scalar.

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

public static Point2f Multiply(
point,
A point.
t
A number.
)
A new point that is coordinate-wise multiplied by t.

Negate

#
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)

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

Subtract

#
Subtracts a vector from a point.

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

public static Point2f Subtract(
point,
A point.
vector
A vector.
)
A new point that is the difference of point minus vector.

Subtract

#
Subtracts the second point from the first point.

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

public static Vector2f Subtract(
point1,
A point (minuend).
point2
A point (subtrahend).
)
A new vector that is point1 coordinate-wise subtracted by point2.
Explicit

IComparable.CompareTo

#
[ConstOperation] int IComparable.CompareTo(
obj
)

ToString

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

ToString

#Since v7.0
Formats the value of the current instance using the specified format.
[ConstOperation] public string ToString(
format,
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
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.