Plane

黑森范式的平面。

描述

表示一个归一化的平面方程。normal是平面的法线(a,b,c归一化),d是从原点到平面的距离(在“法线”方向)。“超过”或“超过”平面被认为是平面朝向法线指向的一侧。

属性

float

d

0.0

Vector3

normal

Vector3(0, 0, 0)

float

x

0.0

float

y

0.0

float

z

0.0

构造函数

Plane

Plane()

Plane

Plane(from: Plane)

Plane

Plane(a: float, b: float, c: float, d: float)

Plane

Plane(normal: Vector3)

Plane

Plane(normal: Vector3, d: float)

Plane

Plane(normal: Vector3, point: Vector3)

Plane

Plane(point1: Vector3, point2: Vector3, point3: Vector3)

方法

float

distance_to(point: Vector3) const

Vector3

get_center() const

bool

has_point(point: Vector3, tolerance: float = 1e-05) const

Variant

intersect_3(b: Plane, c: Plane) const

Variant

intersects_ray(from: Vector3, dir: Vector3) const

Variant

intersects_segment(from: Vector3, to: Vector3) const

bool

is_equal_approx(to_plane: Plane) const

bool

is_finite() const

bool

is_point_over(point: Vector3) const

Plane

normalized() const

Vector3

project(point: Vector3) const

运算符


常量

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)。


属性说明

float d = 0.0 🔗

原点到平面的距离,用normal表示(根据其方向和大小)。原点到平面的实际绝对距离可以计算为abs(d)/normar. long()(如果normal的长度为零,则此Plane不代表有效平面)。

在平面ax+by+cz=d的标量方程中,这是d,而(a, b,c)坐标由normal属性表示。


Vector3 normal = Vector3(0, 0, 0) 🔗

平面的法线,通常是单位向量。不应该是零向量,因为具有这种normalPlane不代表有效平面。

在平面ax+by+cz=d的标量方程中,这是向量(a, b,c),其中dd属性。


float x = 0.0 🔗

平面normal向量的X分量。


float y = 0.0 🔗

平面normal向量的Y分量。


float z = 0.0 🔗

平面normal向量的Z分量。


构造函数说明

Plane Plane() 🔗

构造一个默认初始化的Plane,所有组件都设置为0


Plane Plane(from: Plane)

构造一个Plane作为给定Plane的副本。


Plane Plane(a: float, b: float, c: float, d: float)

从四个参数创建一个平面。生成平面的normal的三个分量是abc,平面与原点的距离为d


Plane Plane(normal: Vector3)

从法向量创建一个平面。该平面将与原点相交。

平面的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的最短距离。如果点在平面上方,距离为正。如果低于,距离为负。


Vector3 get_center() const 🔗

返回平面的中心。


bool has_point(point: Vector3, tolerance: float = 1e-05) const 🔗

如果point在平面内,则返回true。比较使用自定义的最小tolerance阈值。


Variant intersect_3(b: Plane, c: Plane) const 🔗

返回三个平面bc和这个平面的交点。如果没有找到交点,则返回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()


bool is_finite() const 🔗

如果此平面是有限的,则通过调用每个组件上的@GlobalScope.is_finite()返回true


bool is_point_over(point: Vector3) const 🔗

如果point位于平面上方,则返回true


Plane normalized() const 🔗

返回平面的副本,具有归一化的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) 🔗

Plane与给定的Transform3D变换矩阵进行逆变换(相乘)。

平面*变换等价于变换affine_inverse()*平面参见Transform3D.affine_inverse()


bool operator ==(right: Plane) 🔗

如果平面完全相等,则返回true

注:由于浮点精度误差,考虑改用is_equal_approx(),这样更可靠。


Plane operator unary+() 🔗

返回与+不存在相同的值。一元+什么也不做,但有时它可以使您的代码更具可读性。


Plane operator unary-() 🔗

返回Plane的负值。这与编写Plane(-p.普通,-p. d)相同。此操作翻转法向量的方向,也翻转距离值,导致一个Plane在同一个地方,但面向相反的方向。