Show / Hide Table of Contents

    Class Point2D

    The Point2D class can represent a position in 2D space, or a vector in 2D space. Some operations assume that the interpretation is a vector.

    Inheritance
    object
    Point2D
    Inherited Members
    object.GetType()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: DesignData.SDS2.Primitives
    Assembly: DesignData.SDS2.Primitives.dll
    Syntax
    public sealed class Point2D
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Constructors

    Point2D()

    Instantiates a point with X and Y set to zero

    Declaration
    public Point2D()
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Point2D(Point2D)

    Instantiates a point equal to the given point

    Declaration
    public Point2D(Point2D pt)
    Parameters
    Type Name Description
    Point2D pt

    The point whose value to copy

    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Point2D(Vector2D)

    Instantiates a point with the X and Y values of the given vector

    Declaration
    public Point2D(Vector2D vector)
    Parameters
    Type Name Description
    Vector2D vector

    The point whose value to copy

    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Point2D(double, double)

    Instantiates a point with the given X and Y values

    Declaration
    public Point2D(double x, double y)
    Parameters
    Type Name Description
    double x

    The X value for the new point

    double y

    The Y value for the new point

    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Properties

    X

    The X-coordinate of the point

    Declaration
    public double X { get; }
    Property Value
    Type Description
    double
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Y

    The Y-coordinate of the point

    Declaration
    public double Y { get; }
    Property Value
    Type Description
    double
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Methods

    BinEquals(Point2D, double)

    Returns true if this point and the given point fall within the same "bin". A "bin" is a square region of space approximately binSize on a side.

    Declaration
    public bool BinEquals(Point2D other, double binSize)
    Parameters
    Type Name Description
    Point2D other

    The other point

    double binSize

    The size of a bin.

    Returns
    Type Description
    bool
    Remarks

    Unlike EpsilonEquals, BinEquals maintains the transitive rule of equality, but some points which are arbitrarily close together in distance are unequal according got EpsilonEquals, because they fall into different bins.

    EpsilonEquals(Point2D, double)

    Returns true if the squared distance between this point and the given point is less than distance_squared.

    Declaration
    public bool EpsilonEquals(Point2D other, double distanceSquared)
    Parameters
    Type Name Description
    Point2D other

    The other point

    double distanceSquared

    The square of the smallest distance value that should be considered different

    Returns
    Type Description
    bool
    Remarks

    Note that EpsilonEquals can violate the transitivity rule of equality comparison, because there are many groups of points (p, q, r) where p.EpsilonEquals(q) and p.EpsilonEquals(r) but not q.EpsilonEquals(r).

    Equals(object)

    Checks if each element of the points are equal using Double.Equals on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

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

    The point to compare to

    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    ~Point2D()

    The Point2D class can represent a position in 2D space, or a vector in 2D space. Some operations assume that the interpretation is a vector.

    Declaration
    protected ~Point2D()
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    GetHashCode()

    Returns the hash code for this instance. True for instances which are Equals(), otherwise False with high probability. Specific hash values are implementation-dependent.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Interpolate(Point2D, double)

    Performs linear interpolation between this point and the other

    Declaration
    public Point2D Interpolate(Point2D other, double t)
    Parameters
    Type Name Description
    Point2D other

    The other point

    double t

    Controls the mixing between the two points. This function is defined for all values of t, though strictly speaking only values in the interval [0,1] are interpolations, and other values are extrapolations.

    Returns
    Type Description
    Point2D
    Remarks

    This is equal to this + (other - this) * t.

    Note that due to floating point arithmetic, p.project(q, 1.0) may not be exactly equal to q.

    ToString()

    Formats the point into a string. Note that because the values are rounded for display, parsing them to retrieve the X and Y values will not necessarily yield the same point.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Operators

    operator ==(Point2D, Point2D)

    Checks if each element of the points are equal using == on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

    Declaration
    public static bool operator ==(Point2D p, Point2D q)
    Parameters
    Type Name Description
    Point2D p

    The point to compare

    Point2D q

    The point to compare to

    Returns
    Type Description
    bool
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    operator !=(Point2D, Point2D)

    Checks if any element of the points are unequal using != on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

    Declaration
    public static bool operator !=(Point2D p, Point2D q)
    Parameters
    Type Name Description
    Point2D p

    The point to compare

    Point2D q

    The point to compare to

    Returns
    Type Description
    bool
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    operator -(Point2D, Point2D)

    Return a vector which is the difference of the two given points

    Declaration
    public static Vector2D operator -(Point2D arg0, Point2D arg1)
    Parameters
    Type Name Description
    Point2D arg0
    Point2D arg1
    Returns
    Type Description
    Vector2D
    Remarks

    Note that intermediate arithmetic is done in floating point, and thus some operations may have intermediate results that overflow, underflow or experience cancellation error, like all floating-point arithmetic.

    Back to top