Documentation
¶
Overview ¶
Package Plane provides a plane in Hessian normal form.
Index ¶
- Variables
- func Center(p NormalD) Vector3.XYZ
- func DistanceToPoint(point Vector3.XYZ, p NormalD) Float.X
- func HasPoint(point Vector3.XYZ, p NormalD) bool
- func Intersect3(a, b, c NormalD) (Vector3.XYZ, bool)
- func IntersectsRay(p NormalD, from, dir Vector3.XYZ) (Vector3.XYZ, bool)
- func IntersectsSegment(p NormalD, from, to Vector3.XYZ) (Vector3.XYZ, bool)
- func IsApproximatelyEqual(p, other NormalD) bool
- func IsFinite(p NormalD) bool
- func IsPointOver(p NormalD, point Vector3.XYZ) bool
- func Project(point Vector3.XYZ, p NormalD) Vector3.XYZ
- type NormalD
Constants ¶
This section is empty.
Variables ¶
var ( YZ = NormalD{Normal: Vector3.XYZ{1, 0, 0}} // A plane that extends in the Y and Z axes (normal vector points +X). XZ = NormalD{Normal: Vector3.XYZ{0, 1, 0}} // A plane that extends in the X and Z axes (normal vector points +Y). XY = NormalD{Normal: Vector3.XYZ{0, 0, 1}} // A plane that extends in the X and Y axes (normal vector points +Z). )
Functions ¶
func DistanceToPoint ¶
DistanceToPoint returns the shortest distance from the plane to the position point. If the point is above the plane, the distance will be positive. If below, the distance will be negative.
func HasPoint ¶
HasPoint returns true if point is inside the plane. Comparison uses a custom minimum tolerance threshold.
func Intersect3 ¶
Intersect3 returns the intersection point of the three planes b, c and this plane. If no intersection is found, false is returned.
func IntersectsRay ¶
IntersectsRay returns the intersection point of a ray consisting of the position from and the direction normal dir with this plane. If no intersection is found, false is returned.
func IntersectsSegment ¶
IntersectsSegment returns the intersection point of a segment from position from to position to with this plane. If no intersection is found, false is returned.
func IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this plane and other are approximately equal, by running IsApproximatelyEqual on each component.
func IsFinite ¶
IsFinite returns true if this plane is finite, by calling IsFinite on each component.
func IsPointOver ¶
IsPointOver returns true if point is located above the plane.
Types ¶
type NormalD ¶
type NormalD = struct { // Normal of the plane, typically a unit vector. Shouldn't be a zero vector as // Plane with such normal does not represent a valid plane. // // In the scalar equation of the plane ax + by + cz = d, this is the // vector (a, b, c), where d is the d property. Normal Vector3.XYZ // D is the distance from the origin to the plane, expressed in terms of normal // (according to its direction and magnitude). Actual absolute distance from the // origin to the plane can be calculated as Abs(d) / normal.Length() (if normal // has zero length then this Plane does not represent a valid plane). // // In the scalar equation of the plane ax + by + cz = d, this is d, while the (a, b, c) coordinates are represented by the // normal property. D Float.X }
NormalD represents a normalized plane equation. normal is the normal of the plane (a, b, c normalized), and d is the distance from the origin to the plane (in the direction of "normal"). "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing.
func New ¶
New creates a plane from the four parameters. The three components of the resulting plane's normal are a, b and c, and the plane has a distance of d from the origin.
func NormalPoint ¶
NormalPoint creates a plane from the normal vector and a point on the plane.
The normal of the plane must be a unit vector.
func Normalized ¶
Normalized returns a copy of the plane, with normalized normal (so it's a unit vector). Returns a zero value if normal can't be normalized (it has zero length).