import{_ as s,c as i,o as a,a4 as t}from"./chunks/framework.DpC1ZpOZ.js";const E=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","lastUpdated":false},"headers":[],"relativePath":"zht/api/mp_math/point.md","filePath":"zht/api/mp_math/point.md"}'),n={name:"zht/api/mp_math/point.md"},l=t(`

mbcp.mp_math.point

説明: 本模块定义了三维空间中点的类。

class Point3

func __init__(self, x: float, y: float, z: float)

説明: 笛卡尔坐标系中的点。

變數説明:

源碼於GitHub上查看
python
def __init__(self, x: float, y: float, z: float):
    """
        笛卡尔坐标系中的点。
        Args:
            x ([\`float\`](https://docs.python.org/3/library/functions.html#float)): x 坐标
            y (\`float\`): y 坐标
            z (\`float\`): z 坐标
        """
    self.x = x
    self.y = y
    self.z = z

func approx(self, other: Point3, epsilon: float = APPROX) -> bool

説明: 判断两个点是否近似相等。

變數説明:

返回: bool: 是否近似相等

源碼於GitHub上查看
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
    """
        判断两个点是否近似相等。
        Args:
            other ([\`Point3\`](./point#class-point3)): 另一个点
            epsilon ([\`float\`](https://docs.python.org/3/library/functions.html#float)): 误差
        Returns:
            [\`bool\`](https://docs.python.org/3/library/functions.html#bool): 是否近似相等
        """
    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

func self + other: Vector3 => Point3

源碼於GitHub上查看
python
@overload
def __add__(self, other: 'Vector3') -> 'Point3':
    ...

@overload

func self + other: Point3 => Point3

源碼於GitHub上查看
python
@overload
def __add__(self, other: 'Point3') -> 'Point3':
    ...

func self + other

説明: P + V -> P P + P -> P

變數説明:

返回: Point3: 新的点

源碼於GitHub上查看
python
def __add__(self, other):
    """
        P + V -> P
        P + P -> P
        Args:
            other ([\`Vector3\`](./vector#class-vector3) | [\`Point3\`](./point#class-point3)): 另一个点或向量
        Returns:
            [\`Point3\`](./point#class-point3): 新的点
        """
    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

func __eq__(self, other)

説明: 判断两个点是否相等。

變數説明:

返回: bool: 是否相等

源碼於GitHub上查看
python
def __eq__(self, other):
    """
        判断两个点是否相等。
        Args:
            other ([\`Point3\`](./point#class-point3)): 另一个点
        Returns:
            [\`bool\`](https://docs.python.org/3/library/functions.html#bool): 是否相等
        """
    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

func self - other: Point3 => Vector3

説明: P - P -> V

P - V -> P 已在 Vector3 中实现

變數説明:

返回: Vector3: 新的向量

源碼於GitHub上查看
python
def __sub__(self, other: 'Point3') -> 'Vector3':
    """
        P - P -> V

        P - V -> P  已在 [\`Vector3\`](./vector#class-vector3) 中实现
        Args:
            other ([\`Point3\`](./point#class-point3)): 另一个点
        Returns:
            [\`Vector3\`](./vector#class-vector3): 新的向量
        """
    from .vector import Vector3
    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,39),h=[l];function p(e,k,o,r,d,c){return a(),i("div",null,h)}const y=s(n,[["render",p]]);export{E as __pageData,y as default};