Constructor
new Plane(x, y, z, distance)
Constructs a plane.
This constructor does not normalize the components. It assumes that a unit normal vector is provided.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | The X coordinate of the plane's unit normal vector. |
y |
Number | The Y coordinate of the plane's unit normal vector. |
z |
Number | The Z coordinate of the plane's unit normal vector. |
distance |
Number | The plane's distance from the origin. |
- Source:
Members
distance :Number
The plane's distance from the origin.
Type:
- Number
- Source:
normal :Vec3
The normal vector to the plane.
Type:
- Source:
Methods
(static) fromPoints(pa, pb, pc) → {Plane}
Computes a plane that passes through the specified three points.
The plane's normal is the cross product of the
two vectors from pb to pa and pc to pa, respectively. The
returned plane is undefined if any of the specified points are colinear.
Parameters:
Name | Type | Description |
---|---|---|
pa |
Vec3 | The first point. |
pb |
Vec3 | The second point. |
pc |
Vec3 | The third point. |
- Source:
Throws:
-
if pa, pb, or pc is null or undefined.
- Type
- ArgumentError
Returns:
A plane passing through the specified points.
- Type
- Plane
clip(pointA, pointB) → {Array.<Vec3>}
Clips a line segment to this plane.
Parameters:
Name | Type | Description |
---|---|---|
pointA |
Vec3 | The first line segment endpoint. |
pointB |
Vec3 | The second line segment endpoint. |
- Source:
Throws:
-
If either point is null or undefined.
- Type
- ArgumentError
Returns:
An array of two points both on the positive side of the plane. If the direction of the line formed by the
two points is positive with respect to this plane's normal vector, the first point in the array will be
the intersection point on the plane, and the second point will be the original segment end point. If the
direction of the line is negative with respect to this plane's normal vector, the first point in the
array will be the original segment's begin point, and the second point will be the intersection point on
the plane. If the segment does not intersect the plane, null is returned. If the segment is coincident
with the plane, the input points are returned, in their input order.
- Type
- Array.<Vec3>
distanceToPoint(point) → {Number}
Computes the distance between this plane and a point.
Parameters:
Name | Type | Description |
---|---|---|
point |
Vec3 | The point whose distance to compute. |
- Source:
Throws:
-
If the specified point is null or undefined.
- Type
- ArgumentError
Returns:
The computed distance.
- Type
- Number
dot(vector) → {Number}
Computes the dot product of this plane's normal vector with a specified vector.
Since the plane was defined with a unit normal vector, this function returns the distance of the vector from
the plane.
Parameters:
Name | Type | Description |
---|---|---|
vector |
Vec3 | The vector to dot with this plane's normal vector. |
- Source:
Throws:
-
If the specified vector is null or undefined.
- Type
- ArgumentError
Returns:
The computed dot product.
- Type
- Number
intersectsSegment(endPoint1, endPoint2) → {Boolean}
Determines whether a specified line segment intersects this plane.
Parameters:
Name | Type | Description |
---|---|---|
endPoint1 |
Vec3 | The first end point of the line segment. |
endPoint2 |
Vec3 | The second end point of the line segment. |
- Source:
Returns:
true if the line segment intersects this plane, otherwise false.
- Type
- Boolean
intersectsSegmentAt(endPoint1, endPoint2, result) → {Boolean}
Computes the intersection point of this plane with a specified line segment.
Parameters:
Name | Type | Description |
---|---|---|
endPoint1 |
Vec3 | The first end point of the line segment. |
endPoint2 |
Vec3 | The second end point of the line segment. |
result |
Vec3 | A variable in which to return the intersection point of the line segment with this plane. |
- Source:
Returns:
true If the line segment intersects this plane, otherwise false.
- Type
- Boolean
normalize() → {Plane}
Normalizes the components of this plane.
- Source:
Returns:
This plane with its components normalized.
- Type
- Plane
onSameSide(pointA, pointB) → {Number}
Determines whether two points are on the same side of this plane.
Parameters:
Name | Type | Description |
---|---|---|
pointA |
Vec3 | the first point. |
pointB |
Vec3 | the second point. |
- Source:
Throws:
-
If either point is null or undefined.
- Type
- ArgumentError
Returns:
-1 If both points are on the negative side of this plane, +1 if both points are on the
positive side of this plane, 0 if the points are on opposite sides of this plane.
- Type
- Number
transformByMatrix(matrix) → {Plane}
Transforms this plane by a specified matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix | The matrix to apply to this plane. |
- Source:
Throws:
-
If the specified matrix is null or undefined.
- Type
- ArgumentError
Returns:
This plane transformed by the specified matrix.
- Type
- Plane