Plane

class Plane(val normal: Vector3 = Vector3(1.0, 0.0, 0.0), var constant: Double = 0.0)

A two dimensional surface that extends infinitely in 3D space, represented in Hessian normal form by a unit length normal vector and a constant.

The plane is mutable and not thread-safe; confine an instance (and any object graph holding it) to a single thread, exactly as in three.js.

The constructor stores the given normal by reference (it does not copy it). Sharing that vector with another object means later mutations are visible through every alias; use set/setComponents or clone for independent storage.

Constructors

Link copied to clipboard
constructor(normal: Vector3 = Vector3(1.0, 0.0, 0.0), constant: Double = 0.0)

Properties

Link copied to clipboard

The signed distance from the origin to the plane.

Link copied to clipboard

A unit length vector defining the normal of the plane.

Functions

Link copied to clipboard
fun applyMatrix4(matrix: Matrix4, optionalNormalMatrix: Matrix3? = null): Plane

Applies a 4x4 matrix matrix to the plane. The matrix must be an affine, homogeneous transform.

Link copied to clipboard
fun clone(): Plane

Returns a new plane with copied values from this instance.

Link copied to clipboard

Writes a coplanar vector to the plane into target, by calculating the projection of the normal at the origin onto the plane.

Link copied to clipboard
fun copy(plane: Plane): Plane

Copies the values of the given plane plane to this instance.

Link copied to clipboard

Returns the signed distance from the given point to this plane.

Link copied to clipboard

Returns the signed distance from the given sphere to this plane.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Structural equality: true when other is a Plane with an equal normal (via Vector3.equals) and an equal constant (primitive ==, so NaN != NaN).

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun intersectLine(line: Line3, target: Vector3, clampToLine: Boolean = true): Vector3?

Writes the intersection point of the passed line and the plane into target. Returns null if the line does not intersect. Returns the line's starting point if the line is coplanar with the plane.

Link copied to clipboard

Returns true if the given bounding box box intersects with the plane.

Link copied to clipboard

Returns true if the given line segment line intersects with (passes through) the plane.

Link copied to clipboard

Returns true if the given bounding sphere sphere intersects with the plane.

Link copied to clipboard
fun negate(): Plane

Negates both the plane normal and the constant.

Link copied to clipboard

Normalizes the plane normal and adjusts the constant accordingly.

Link copied to clipboard
fun projectPoint(point: Vector3, target: Vector3): Vector3

Projects the given point onto the plane, writing the result into target.

Link copied to clipboard
fun set(normal: Vector3, constant: Double): Plane

Sets the plane components by copying the given values.

Link copied to clipboard

Sets the plane components by defining x, y, z as the plane normal and w as the constant.

Link copied to clipboard

Sets the plane from three coplanar points a, b, c. The winding order is assumed to be counter-clockwise, and determines the direction of the plane normal.

Link copied to clipboard

Sets the plane from the given normal and coplanar point (a point that lies on the plane).

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun translate(offset: Vector3): Plane

Translates the plane by the distance defined by the given offset vector. Note that this only affects the plane constant and will not affect the normal vector.