Files
godot-docs-l10n/classes/zh_Hans/class_plane.rst

522 lines
23 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_Plane:
Plane
=====
使用黑塞范式的平面。
.. rst-class:: classref-introduction-group
描述
----
代表归一化的平面方程。\ :ref:`normal<class_Plane_property_normal>` 是平面的法线(归一化的 a、b、c:ref:`d<class_Plane_property_d>` 是原点到平面的距离(沿“法线”方向)。平面的“上方”是平面朝向法线方向的一面。
.. rst-class:: classref-introduction-group
教程
----
- :doc:`数学文档索引 <../tutorials/math/index>`
.. rst-class:: classref-reftable-group
属性
----
.. table::
:widths: auto
+-------------------------------+--------------------------------------------+----------------------+
| :ref:`float<class_float>` | :ref:`d<class_Plane_property_d>` | ``0.0`` |
+-------------------------------+--------------------------------------------+----------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`normal<class_Plane_property_normal>` | ``Vector3(0, 0, 0)`` |
+-------------------------------+--------------------------------------------+----------------------+
| :ref:`float<class_float>` | :ref:`x<class_Plane_property_x>` | ``0.0`` |
+-------------------------------+--------------------------------------------+----------------------+
| :ref:`float<class_float>` | :ref:`y<class_Plane_property_y>` | ``0.0`` |
+-------------------------------+--------------------------------------------+----------------------+
| :ref:`float<class_float>` | :ref:`z<class_Plane_property_z>` | ``0.0`` |
+-------------------------------+--------------------------------------------+----------------------+
.. rst-class:: classref-reftable-group
构造函数
--------
.. table::
:widths: auto
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ from\: :ref:`Plane<class_Plane>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ a\: :ref:`float<class_float>`, b\: :ref:`float<class_float>`, c\: :ref:`float<class_float>`, d\: :ref:`float<class_float>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ normal\: :ref:`Vector3<class_Vector3>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ normal\: :ref:`Vector3<class_Vector3>`, d\: :ref:`float<class_float>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ normal\: :ref:`Vector3<class_Vector3>`, point\: :ref:`Vector3<class_Vector3>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`Plane<class_Plane_constructor_Plane>`\ (\ point1\: :ref:`Vector3<class_Vector3>`, point2\: :ref:`Vector3<class_Vector3>`, point3\: :ref:`Vector3<class_Vector3>`\ ) |
+---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`distance_to<class_Plane_method_distance_to>`\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`get_center<class_Plane_method_get_center>`\ (\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has_point<class_Plane_method_has_point>`\ (\ point\: :ref:`Vector3<class_Vector3>`, tolerance\: :ref:`float<class_float>` = 1e-05\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`intersect_3<class_Plane_method_intersect_3>`\ (\ b\: :ref:`Plane<class_Plane>`, c\: :ref:`Plane<class_Plane>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`intersects_ray<class_Plane_method_intersects_ray>`\ (\ from\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`intersects_segment<class_Plane_method_intersects_segment>`\ (\ from\: :ref:`Vector3<class_Vector3>`, to\: :ref:`Vector3<class_Vector3>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Plane_method_is_equal_approx>`\ (\ to_plane\: :ref:`Plane<class_Plane>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_finite<class_Plane_method_is_finite>`\ (\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_point_over<class_Plane_method_is_point_over>`\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`normalized<class_Plane_method_normalized>`\ (\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`project<class_Plane_method_project>`\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| |
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-reftable-group
运算符
------
.. table::
:widths: auto
+---------------------------+--------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Plane_operator_neq_Plane>`\ (\ right\: :ref:`Plane<class_Plane>`\ ) |
+---------------------------+--------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`operator *<class_Plane_operator_mul_Transform3D>`\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ ) |
+---------------------------+--------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Plane_operator_eq_Plane>`\ (\ right\: :ref:`Plane<class_Plane>`\ ) |
+---------------------------+--------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`operator unary+<class_Plane_operator_unplus>`\ (\ ) |
+---------------------------+--------------------------------------------------------------------------------------------------------------+
| :ref:`Plane<class_Plane>` | :ref:`operator unary-<class_Plane_operator_unminus>`\ (\ ) |
+---------------------------+--------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
常量
----
.. _class_Plane_constant_PLANE_YZ:
.. rst-class:: classref-constant
**PLANE_YZ** = ``Plane(1, 0, 0, 0)`` :ref:`🔗<class_Plane_constant_PLANE_YZ>`
在 Y 轴和 Z 轴上延伸的平面(法向量指向 +X
.. _class_Plane_constant_PLANE_XZ:
.. rst-class:: classref-constant
**PLANE_XZ** = ``Plane(0, 1, 0, 0)`` :ref:`🔗<class_Plane_constant_PLANE_XZ>`
在 X 轴和 Z 轴上延伸的平面(法向量朝向 +Y
.. _class_Plane_constant_PLANE_XY:
.. rst-class:: classref-constant
**PLANE_XY** = ``Plane(0, 0, 1, 0)`` :ref:`🔗<class_Plane_constant_PLANE_XY>`
在 X 轴和 Y 轴上延伸的平面(法向量朝向 +Z
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
属性说明
--------
.. _class_Plane_property_d:
.. rst-class:: classref-property
:ref:`float<class_float>` **d** = ``0.0`` :ref:`🔗<class_Plane_property_d>`
从原点到平面的距离,按照 :ref:`normal<class_Plane_property_normal>` 取值(根据其方向和长度)。原点与平面的实际绝对距离可以通过 ``abs(d) / normal.length()`` 计算(如果 :ref:`normal<class_Plane_property_normal>` 长度为零,则该 **Plane** 表示的不是有效平面)。
在平面 ``ax + by + cz = d`` 的标量方程中,这是 ``d``\ ,而 ``(a, b, c)`` 坐标由 :ref:`normal<class_Plane_property_normal>` 属性表示。
.. rst-class:: classref-item-separator
----
.. _class_Plane_property_normal:
.. rst-class:: classref-property
:ref:`Vector3<class_Vector3>` **normal** = ``Vector3(0, 0, 0)`` :ref:`🔗<class_Plane_property_normal>`
该平面的法线,通常为单位向量。不应该为零向量,因为 :ref:`normal<class_Plane_property_normal>` 为零的 **Plane** 代表的不是有效平面。
在平面 ``ax + by + cz = d`` 的标量方程中,这是向量 ``(a, b, c)``\ ,其中 ``d``:ref:`d<class_Plane_property_d>` 属性。
.. rst-class:: classref-item-separator
----
.. _class_Plane_property_x:
.. rst-class:: classref-property
:ref:`float<class_float>` **x** = ``0.0`` :ref:`🔗<class_Plane_property_x>`
平面法向量 :ref:`normal<class_Plane_property_normal>` 的 X 分量。
.. rst-class:: classref-item-separator
----
.. _class_Plane_property_y:
.. rst-class:: classref-property
:ref:`float<class_float>` **y** = ``0.0`` :ref:`🔗<class_Plane_property_y>`
平面法向量 :ref:`normal<class_Plane_property_normal>` 的 Y 分量。
.. rst-class:: classref-item-separator
----
.. _class_Plane_property_z:
.. rst-class:: classref-property
:ref:`float<class_float>` **z** = ``0.0`` :ref:`🔗<class_Plane_property_z>`
平面法向量 :ref:`normal<class_Plane_property_normal>` 的 Z 分量。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
构造函数说明
------------
.. _class_Plane_constructor_Plane:
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ ) :ref:`🔗<class_Plane_constructor_Plane>`
构造默认初始化的 **Plane**\ ,所有分量都设置为 ``0``\ 。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ from\: :ref:`Plane<class_Plane>`\ )
构造给定 **Plane** 的副本。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ a\: :ref:`float<class_float>`, b\: :ref:`float<class_float>`, c\: :ref:`float<class_float>`, d\: :ref:`float<class_float>`\ )
根据四个参数创建一个平面。产生的平面的 :ref:`normal<class_Plane_property_normal>` 的三个分量是 ``a``\ 、\ ``b````c``\ ,且该平面与原点的距离为 ``d``\ 。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ normal\: :ref:`Vector3<class_Vector3>`\ )
根据法向量创建一个平面。该平面将与原点相交。
该平面的 ``normal`` 必须是一个单位向量。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ normal\: :ref:`Vector3<class_Vector3>`, d\: :ref:`float<class_float>`\ )
根据法向量和平面与原点的距离创建一个平面。
平面的 ``normal`` 必须是一个单位向量。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ normal\: :ref:`Vector3<class_Vector3>`, point\: :ref:`Vector3<class_Vector3>`\ )
从法向量和平面上的一个点创建一个平面。
平面的 ``normal`` 必须是一个单位向量。
.. rst-class:: classref-item-separator
----
.. rst-class:: classref-constructor
:ref:`Plane<class_Plane>` **Plane**\ (\ point1\: :ref:`Vector3<class_Vector3>`, point2\: :ref:`Vector3<class_Vector3>`, point3\: :ref:`Vector3<class_Vector3>`\ )
根据顺时针顺序给出的三个点创建一个平面。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _class_Plane_method_distance_to:
.. rst-class:: classref-method
:ref:`float<class_float>` **distance_to**\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Plane_method_distance_to>`
返回从该平面到位置 ``point`` 的最短距离。如果该点在平面上方,则距离将为正。如果在下方,则距离将为负。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_get_center:
.. rst-class:: classref-method
:ref:`Vector3<class_Vector3>` **get_center**\ (\ ) |const| :ref:`🔗<class_Plane_method_get_center>`
返回平面的中心。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_has_point:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **has_point**\ (\ point\: :ref:`Vector3<class_Vector3>`, tolerance\: :ref:`float<class_float>` = 1e-05\ ) |const| :ref:`🔗<class_Plane_method_has_point>`
如果 ``point`` 在该平面内,则返回 ``true``\ 。比较将使用一个自定义的最小 ``tolerance`` 阈值。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_intersect_3:
.. rst-class:: classref-method
:ref:`Variant<class_Variant>` **intersect_3**\ (\ b\: :ref:`Plane<class_Plane>`, c\: :ref:`Plane<class_Plane>`\ ) |const| :ref:`🔗<class_Plane_method_intersect_3>`
返回 ``b``\ 、\ ``c``\ 、该平面这三个平面的交点。如果没有找到交点,则返回 ``null``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_intersects_ray:
.. rst-class:: classref-method
:ref:`Variant<class_Variant>` **intersects_ray**\ (\ from\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Plane_method_intersects_ray>`
返回由位置 ``from`` 和方向法线 ``dir`` 组成的射线与该平面的交点。如果没有找到交点,则返回 ``null``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_intersects_segment:
.. rst-class:: classref-method
:ref:`Variant<class_Variant>` **intersects_segment**\ (\ from\: :ref:`Vector3<class_Vector3>`, to\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Plane_method_intersects_segment>`
返回从位置 ``from`` 到位置 ``to`` 的线段与该平面的交点。如果没有找到交点,则返回 ``null``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_is_equal_approx:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_equal_approx**\ (\ to_plane\: :ref:`Plane<class_Plane>`\ ) |const| :ref:`🔗<class_Plane_method_is_equal_approx>`
如果该平面和 ``to_plane`` 近似相等,则返回 ``true``\ ,判断近似相等的方法是通过在每个分量上运行 :ref:`@GlobalScope.is_equal_approx()<class_@GlobalScope_method_is_equal_approx>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_is_finite:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_finite**\ (\ ) |const| :ref:`🔗<class_Plane_method_is_finite>`
如果该平面是有限的,则返回 ``true``\ ,判断方法是在每个分量上调用 :ref:`@GlobalScope.is_finite()<class_@GlobalScope_method_is_finite>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_is_point_over:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_point_over**\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Plane_method_is_point_over>`
如果 ``point`` 位于平面上方,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_normalized:
.. rst-class:: classref-method
:ref:`Plane<class_Plane>` **normalized**\ (\ ) |const| :ref:`🔗<class_Plane_method_normalized>`
返回该平面归一化 :ref:`normal<class_Plane_property_normal>` 后的副本(法线成为单位向量)。如果 :ref:`normal<class_Plane_property_normal>` 无法归一化(长度为零),则返回 ``Plane(0, 0, 0, 0)``\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_method_project:
.. rst-class:: classref-method
:ref:`Vector3<class_Vector3>` **project**\ (\ point\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_Plane_method_project>`
返回 ``point`` 在该平面中的正交投影。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
运算符说明
----------
.. _class_Plane_operator_neq_Plane:
.. rst-class:: classref-operator
:ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`Plane<class_Plane>`\ ) :ref:`🔗<class_Plane_operator_neq_Plane>`
如果平面不相等,则返回 ``true``\ 。
\ **注意:**\ 由于浮点数精度误差,请考虑改用 :ref:`is_equal_approx()<class_Plane_method_is_equal_approx>`\ ,会更可靠。
.. rst-class:: classref-item-separator
----
.. _class_Plane_operator_mul_Transform3D:
.. rst-class:: classref-operator
:ref:`Plane<class_Plane>` **operator ***\ (\ right\: :ref:`Transform3D<class_Transform3D>`\ ) :ref:`🔗<class_Plane_operator_mul_Transform3D>`
将 **Plane** 逆向变换(乘以)给定的 :ref:`Transform3D<class_Transform3D>` 变换矩阵。
\ ``plane * transform`` 相当于 ``transform.affine_inverse() * plane``\ 。请参阅 :ref:`Transform3D.affine_inverse()<class_Transform3D_method_affine_inverse>`\ 。
.. rst-class:: classref-item-separator
----
.. _class_Plane_operator_eq_Plane:
.. rst-class:: classref-operator
:ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`Plane<class_Plane>`\ ) :ref:`🔗<class_Plane_operator_eq_Plane>`
如果平面完全相等,则返回 ``true``\ 。
\ **注意:**\ 由于浮点数精度误差,请考虑改用 :ref:`is_equal_approx()<class_Plane_method_is_equal_approx>`\ ,会更可靠。
.. rst-class:: classref-item-separator
----
.. _class_Plane_operator_unplus:
.. rst-class:: classref-operator
:ref:`Plane<class_Plane>` **operator unary+**\ (\ ) :ref:`🔗<class_Plane_operator_unplus>`
返回与 ``+`` 不存在时相同的值。单目 ``+`` 没有作用,但有时可以使你的代码更具可读性。
.. rst-class:: classref-item-separator
----
.. _class_Plane_operator_unminus:
.. rst-class:: classref-operator
:ref:`Plane<class_Plane>` **operator unary-**\ (\ ) :ref:`🔗<class_Plane_operator_unminus>`
返回该 **Plane** 的负值。和写 ``Plane(-p.normal, -p.d)`` 相同。该操作翻转了法线向量的方向,也翻转了距离值,得到的 Plane 位于同一个位置,但是朝向相反的方向。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
.. |void| replace:: :abbr:`void (无返回值。)`