Struct DoublePlane
Representation of a plane in 3D space storing values as doubles.
Namespace: Unity.Geospatial.HighPrecision
Assembly: solution.dll
Syntax
[BurstCompile(CompileSynchronously = true)]
public readonly struct DoublePlane : IEquatable<DoublePlane>, IFormattable
Constructors
DoublePlane(double3, Double)
Construct a DoublePlane instance using its normal
and its
distance
from the origin.
Declaration
public DoublePlane(double3 normal, double distance)
Parameters
Type | Name | Description |
---|---|---|
double3 | normal | The plane's normal vector which is perpendicular to the plane's surface. This is expected to be a unit vector. |
Double | distance | The distance the plane is from the origin.
This distance can be easily determined by extending the |
DoublePlane(double3, double3)
Construct a plane using an arbitrary point
on the plane's surface and the plane's normal
.
Declaration
public DoublePlane(double3 normal, double3 point)
Parameters
Type | Name | Description |
---|---|---|
double3 | normal | The plane's normal vector which is perpendicular to the plane's surface. This is expected to be a unit vector. |
double3 | point | An arbitrary point which is included in the plane's domain. |
DoublePlane(double3, double3, double3)
Construct a DoublePlane instance using three arbitrary points on the plane. The only constraint is that these points cannot be collinear.
Declaration
public DoublePlane(double3 a, double3 b, double3 c)
Parameters
Type | Name | Description |
---|---|---|
double3 | a | First point on the plane. |
double3 | b | Second point on the plane. |
double3 | c | Third point on the plane. |
Properties
Distance
The distance measured from the Plane to the origin, along the Plane's normal.
Declaration
public readonly double Distance { get; }
Property Value
Type | Description |
---|---|
Double |
Flipped
Returns a copy of the plane that faces in the opposite direction.
Declaration
public readonly DoublePlane Flipped { get; }
Property Value
Type | Description |
---|---|
DoublePlane |
Normal
Normal vector of the plane.
Declaration
public readonly double3 Normal { get; }
Property Value
Type | Description |
---|---|
double3 |
Methods
ClosestPointOnPlane(double3)
For a given point returns the closest point on the plane.
Declaration
public readonly double3 ClosestPointOnPlane(double3 point)
Parameters
Type | Name | Description |
---|---|---|
double3 | point | The point to project onto the plane. |
Returns
Type | Description |
---|---|
double3 | A point on the plane that is closest to point. |
Equals(Object)
Validate obj
is a DoublePlane instance and have the same values as this instance.
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | Compare the values with this instance. |
Returns
Type | Description |
---|---|
Boolean | true if both instance have the same values; false otherwise. |
Overrides
Equals(DoublePlane)
Validate an other DoublePlane have the same values as this instance.
Declaration
public readonly bool Equals(DoublePlane other)
Parameters
Type | Name | Description |
---|---|---|
DoublePlane | other | Compare the values with this instance. |
Returns
Type | Description |
---|---|
Boolean | true if both instance have the same values; false otherwise. |
GetDistanceToPoint(double3)
Returns a signed distance from plane to point.
Declaration
public readonly double GetDistanceToPoint(double3 point)
Parameters
Type | Name | Description |
---|---|---|
double3 | point | Get the distance from this point. |
Returns
Type | Description |
---|---|
Double | The distance between this instance with the given |
GetHashCode()
Compute a hash code for the object.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for the current object. |
Overrides
Remarks
- You should not assume that equal hash codes imply object equality.
- You should never persist or use a hash code outside the application domain in which it was created, because the same object may hash differently across application domains, processes, and platforms.
GetSide(double3)
Get on which side a the plane a given point
is.
Declaration
public readonly bool GetSide(double3 point)
Parameters
Type | Name | Description |
---|---|---|
double3 | point | Position to get its relative side. |
Returns
Type | Description |
---|---|
Boolean | true if the point is on the positive side of the plane; false otherwise. |
Raycast(double3, double3)
Intersects a ray with the plane.
Declaration
public readonly double3 Raycast(double3 p1, double3 p2)
Parameters
Type | Name | Description |
---|---|---|
double3 | p1 | One point positioned on the projected ray. |
double3 | p2 | A second point positioned on the projected ray. |
Returns
Type | Description |
---|---|
double3 | The distance along the ray, where it intersects the plane. |
SameSide(double3, double3)
Are two points on the same side of the plane?
Declaration
public readonly bool SameSide(double3 point0, double3 point1)
Parameters
Type | Name | Description |
---|---|---|
double3 | point0 | First point to evaluate. |
double3 | point1 | Get if this second point is on the same side as |
Returns
Type | Description |
---|---|
Boolean |
ToString()
Returns a formatted string for the plane.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String | The formatted string representing this instance. |
Overrides
ToString(String)
Returns a formatted string for the plane.
Declaration
public readonly string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
String | format | A numeric format string. |
Returns
Type | Description |
---|---|
String | The formatted string representing this instance. |
ToString(String, IFormatProvider)
Returns a formatted string for the plane.
Declaration
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
String | format | A numeric format string. |
IFormatProvider | formatProvider | An object that specifies culture-specific formatting. |
Returns
Type | Description |
---|---|
String | The formatted string representing this instance. |
Translate(double3)
Returns a copy of the plane that is moved in space by the given translation.
Declaration
public readonly DoublePlane Translate(double3 translation)
Parameters
Type | Name | Description |
---|---|---|
double3 | translation | The offset in space to move the plane with. |
Returns
Type | Description |
---|---|
DoublePlane | The translated plane. |
Operators
Equality(DoublePlane, DoublePlane)
Validate both DoublePlane have the same values.
Declaration
public static bool operator ==(DoublePlane lhs, DoublePlane rhs)
Parameters
Type | Name | Description |
---|---|---|
DoublePlane | lhs | First instance to compare with. |
DoublePlane | rhs | Compare |
Returns
Type | Description |
---|---|
Boolean | true if both instance have the same values; false otherwise. |
Explicit(DoublePlane to Plane)
Convert a DoublePlane instance to a new single precision Unity Plane instance.
Declaration
public static explicit operator Plane(DoublePlane plane)
Parameters
Type | Name | Description |
---|---|---|
DoublePlane | plane | The instance to convert. |
Returns
Type | Description |
---|---|
Plane | A new Plane instance. |
Explicit(Plane to DoublePlane)
Convert a single precision Unity Plane instance to a new DoublePlane instance.
Declaration
public static explicit operator DoublePlane(Plane plane)
Parameters
Type | Name | Description |
---|---|---|
Plane | plane | The instance to convert. |
Returns
Type | Description |
---|---|
DoublePlane | A new DoublePlane instance. |
Inequality(DoublePlane, DoublePlane)
Validate both DoublePlane have the different values.
Declaration
public static bool operator !=(DoublePlane lhs, DoublePlane rhs)
Parameters
Type | Name | Description |
---|---|---|
DoublePlane | lhs | First instance to compare with. |
DoublePlane | rhs | Compare |
Returns
Type | Description |
---|---|
Boolean | true if at least one value is different on both instances; false if both instance have the same values. |