Class Point3D
The Point3D class can represent a position in 3D space, or a vector in 3D space. Some operations assume that the interpretation is a vector.
Inheritance
Inherited Members
Namespace: DesignData.SDS2.Primitives
Assembly: DesignData.SDS2.Primitives.dll
Syntax
public sealed class Point3D
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
Point3D()
Instantiates a point with X, Y, and Z all zero
Declaration
public Point3D()
Point3D(Point3D)
Instantiates a point equal to the given point
Declaration
public Point3D(Point3D pt)
Parameters
Type | Name | Description |
---|---|---|
Point3D | pt | The point whose value to copy |
Point3D(Vector3D)
Instantiates a point with the X, Y, and Z values of the given vector
Declaration
public Point3D(Vector3D vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | vector | The point whose value to copy |
Point3D(Double, Double, Double)
Instantiates a point with the given X, Y, and Z values
Declaration
public Point3D(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | The X value for the new point |
System.Double | y | The Y value for the new point |
System.Double | z | The Z value for the new point |
Properties
X
The X-coordinate of the point
Declaration
public double X { get; }
Property Value
Type | Description |
---|---|
System.Double |
Y
The Y-coordinate of the point
Declaration
public double Y { get; }
Property Value
Type | Description |
---|---|
System.Double |
Z
The Z-coordinate of the point
Declaration
public double Z { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
BinEquals(Point3D, Double)
Returns true if this point and the given point fall within the same "bin". A "bin" is a cubic region of space approximately binSize on a side.
Declaration
public bool BinEquals(Point3D other, double binSize)
Parameters
Type | Name | Description |
---|---|---|
Point3D | other | The other point |
System.Double | binSize | The size of a bin. |
Returns
Type | Description |
---|---|
System.Boolean |
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(Point3D, Double)
Returns true if the squared distance between this point and the given point is less than distance_squared.
Declaration
public bool EpsilonEquals(Point3D other, double distanceSquared)
Parameters
Type | Name | Description |
---|---|---|
Point3D | other | The other point |
System.Double | distanceSquared | The square of the smallest distance value that should be considered different |
Returns
Type | Description |
---|---|
System.Boolean |
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 |
---|---|---|
System.Object | obj | The point to compare to |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Finalize()
Declaration
protected void Finalize()
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 |
---|---|
System.Int32 |
Overrides
Interpolate(Point3D, Double)
Performs linear interpolation between this point and the other
Declaration
public Point3D Interpolate(Point3D other, double t)
Parameters
Type | Name | Description |
---|---|---|
Point3D | other | The other point |
System.Double | t | Controls the mixing between the two points. This function is defined
for all values of |
Returns
Type | Description |
---|---|
Point3D |
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, Y, and Z values will not necessarily yield the same point.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
Equality(Point3D, Point3D)
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 ==(Point3D p, Point3D q)
Parameters
Type | Name | Description |
---|---|---|
Point3D | p | The point to compare |
Point3D | q | The point to compare to |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(Point3D, Point3D)
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 !=(Point3D p, Point3D q)
Parameters
Type | Name | Description |
---|---|---|
Point3D | p | The point to compare |
Point3D | q | The point to compare to |
Returns
Type | Description |
---|---|
System.Boolean |
Subtraction(Point3D, Point3D)
Return a vector which is the difference of the two given points
Declaration
public static Vector3D operator -(Point3D arg0, Point3D arg1)
Parameters
Type | Name | Description |
---|---|---|
Point3D | arg0 | |
Point3D | arg1 |
Returns
Type | Description |
---|---|
Vector3D |