Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Plane
使用黑塞範式的平面。
說明
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.
Note: In a boolean context, a plane will evaluate to false if all its components equal 0. Otherwise, a plane will always evaluate to true.
教學
屬性
|
||
|
||
|
||
|
||
|
建構子
Plane() |
|
方法
distance_to(point: Vector3) const |
|
get_center() const |
|
intersect_3(b: Plane, c: Plane) const |
|
intersects_ray(from: Vector3, dir: Vector3) const |
|
intersects_segment(from: Vector3, to: Vector3) const |
|
is_equal_approx(to_plane: Plane) const |
|
is_finite() const |
|
is_point_over(point: Vector3) const |
|
normalized() const |
|
運算子
operator !=(right: Plane) |
|
operator *(right: Transform3D) |
|
operator ==(right: Plane) |
|
常數
PLANE_YZ = Plane(1, 0, 0, 0) 🔗
在 Y 軸和 Z 軸上延伸的平面(法向量指向 +X)。
PLANE_XZ = Plane(0, 1, 0, 0) 🔗
在 X 軸和 Z 軸上延伸的平面(法向量朝向 +Y)。
PLANE_XY = Plane(0, 0, 1, 0) 🔗
在 X 軸和 Y 軸上延伸的平面(法向量朝向 +Z)。
屬性說明
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.
Vector3 normal = Vector3(0, 0, 0) 🔗
The 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 的 X 分量。
平面法向量 normal 的 Y 分量。
平面法向量 normal 的 Z 分量。
建構子說明
建構預設初始化的 Plane,所有分量都設定為 0。
建構給定 Plane 的副本。
Plane Plane(a: float, b: float, c: float, d: float)
根據四個參數建立一個平面。產生的平面的 normal 的三個分量是 a、b、和 c,且該平面與原點的距離為 d。
根據法向量建立一個平面。該平面將與原點相交。
該平面的 normal 必須是一個單位向量。
Plane Plane(normal: Vector3, d: float)
根據法向量和平面與原點的距離建立一個平面。
平面的 normal 必須是一個單位向量。
Plane Plane(normal: Vector3, point: Vector3)
從法向量和平面上的一個點建立一個平面。
平面的 normal 必須是一個單位向量。
Plane Plane(point1: Vector3, point2: Vector3, point3: Vector3)
根據順時針順序給出的三個點建立一個平面。
方法說明
float distance_to(point: Vector3) const 🔗
返回從該平面到位置 point 的最短距離。如果該點在平面上方,則距離將為正。如果在下方,則距離將為負。
返回平面的中心。
bool has_point(point: Vector3, tolerance: float = 1e-05) const 🔗
如果 point 在該平面內,則返回 true。比較將使用一個自訂的最小 tolerance 閾值。
Variant intersect_3(b: Plane, c: Plane) const 🔗
返回 b、c、該平面這三個平面的交點。如果沒有找到交點,則返回 null。
Variant intersects_ray(from: Vector3, dir: Vector3) const 🔗
返回由位置 from 和方向法線 dir 組成的射線與該平面的交點。如果沒有找到交點,則返回 null。
Variant intersects_segment(from: Vector3, to: Vector3) const 🔗
返回從位置 from 到位置 to 的線段與該平面的交點。如果沒有找到交點,則返回 null。
bool is_equal_approx(to_plane: Plane) const 🔗
如果該平面和 to_plane 近似相等,則返回 true,判斷近似相等的方法是通過在每個分量上運作 @GlobalScope.is_equal_approx()。
如果該平面是有限的,則返回 true,判斷方法是在每個分量上呼叫 @GlobalScope.is_finite()。
bool is_point_over(point: Vector3) const 🔗
如果 point 位於平面上方,則返回 true。
返回該平面正規化 normal 後的副本(法線成為單位向量)。如果 normal 無法正規化(長度為零),則返回 Plane(0, 0, 0, 0)。
Vector3 project(point: Vector3) const 🔗
返回 point 在該平面中的正交投影。
運算子說明
bool operator !=(right: Plane) 🔗
如果平面不相等,則返回 true。
注意:由於浮點數精度誤差,請考慮改用 is_equal_approx(),會更可靠。
Plane operator *(right: Transform3D) 🔗
Inversely transforms (multiplies) the Plane by the given Transform3D transformation matrix.
plane * transform is equivalent to transform.affine_inverse() * plane. See Transform3D.affine_inverse().
bool operator ==(right: Plane) 🔗
如果平面完全相等,則返回 true。
注意:由於浮點數精度誤差,請考慮改用 is_equal_approx(),會更可靠。
返回與 + 不存在時相同的值。單目 + 沒有作用,但有時可以使你的程式碼更具可讀性。
返回該 Plane 的負值。和寫 Plane(-p.normal, -p.d) 相同。該操作翻轉了法線向量的方向,也翻轉了距離值,得到的 Plane 位於同一個位置,但是朝向相反的方向。