diff --git a/404.html b/404.html index 2554cb3..be1a2ff 100644 --- a/404.html +++ b/404.html @@ -15,7 +15,7 @@
- + \ No newline at end of file diff --git a/api-ex.html b/api-ex.html index 62cefdd..2a6d90b 100644 --- a/api-ex.html +++ b/api-ex.html @@ -545,7 +545,7 @@ }

Page Frontmatter

{
   "outline": "deep"
 }

More

Check out the documentation for the full list of runtime APIs.

- + \ No newline at end of file diff --git a/api/index.html b/api/index.html index 208d596..5a6900b 100644 --- a/api/index.html +++ b/api/index.html @@ -18,7 +18,7 @@
Skip to content
- + \ No newline at end of file diff --git a/api/mp_math/angle.html b/api/mp_math/angle.html index 75bdcf4..158cda1 100644 --- a/api/mp_math/angle.html +++ b/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

参数:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

源代码
python
def __init__(self, value: float, is_radian: bool=False):
+    
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

说明: 任意角度。

参数:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
源代码
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -27,96 +27,96 @@
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

返回:

  • 余角
源代码
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

说明: 余角:两角的和为90°。

返回: 余角

源代码
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

返回:

  • 补角
源代码
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

说明: 补角:两角的和为180°。

返回: 补角

源代码
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

返回:

  • 弧度
源代码
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

说明: 角度。

返回: 弧度

源代码
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

返回:

  • 最小正角度
源代码
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

说明: 最小正角。

返回: 最小正角度

源代码
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

返回:

  • 最大负角度
源代码
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

说明: 最大负角。

返回: 最大负角度

源代码
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

返回:

  • 正弦值
源代码
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

说明: 正弦值。

返回: 正弦值

源代码
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

返回:

  • 余弦值
源代码
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

说明: 余弦值。

返回: 余弦值

源代码
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

返回:

  • 正切值
源代码
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

说明: 正切值。

返回: 正切值

源代码
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

返回:

  • 余切值
源代码
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

说明: 余切值。

返回: 余切值

源代码
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

返回:

  • 正割值
源代码
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

说明: 正割值。

返回: 正割值

源代码
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

返回:

  • 余割值
源代码
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

说明: 余割值。

返回: 余割值

源代码
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源代码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源代码
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源代码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源代码
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源代码
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源代码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源代码
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源代码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源代码
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源代码
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源代码
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

源代码
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

源代码
python
def __truediv__(self, other):
+    ...

method self / other

源代码
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)
- + \ No newline at end of file diff --git a/api/mp_math/const.html b/api/mp_math/const.html index 86ab636..545baf8 100644 --- a/api/mp_math/const.html +++ b/api/mp_math/const.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/api/mp_math/equation.html b/api/mp_math/equation.html index 947617d..95e61d7 100644 --- a/api/mp_math/equation.html +++ b/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

参数:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

返回:

  • 偏导函数

引发:

  • ValueError 无效变量类型
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

说明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

返回: 偏导函数

参数:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

引发:

  • ValueError 无效变量类型
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -47,16 +47,16 @@
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

参数:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

说明: 曲线方程。

参数:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -66,7 +66,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

参数:

  • *t:

  • 参数:

源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:
源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -79,7 +79,7 @@
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
         return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
- + \ No newline at end of file diff --git a/api/mp_math/index.html b/api/mp_math/index.html index cbc7ef9..2451d5a 100644 --- a/api/mp_math/index.html +++ b/api/mp_math/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/api/mp_math/line.html b/api/mp_math/line.html index 65d7e30..3b4ae6f 100644 --- a/api/mp_math/line.html +++ b/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

参数:

  • point: 直线上的一点

  • direction: 直线的方向向量

源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

说明: 三维空间中的直线。由一个点和一个方向向量确定。

参数:

  • point: 直线上的一点
  • direction: 直线的方向向量
源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -25,7 +25,7 @@
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

参数:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

说明: 判断两条直线是否近似相等。

返回: 是否近似相等

参数:

  • other: 另一条直线
  • epsilon: 误差
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -34,7 +34,7 @@
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

参数:

  • other: 另一条直线

返回:

  • 夹角弧度

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

说明: 计算直线和直线之间的夹角。

返回: 夹角弧度

参数:

  • other: 另一条直线

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -44,7 +44,7 @@
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

参数:

  • other: 平行直线或点

返回:

  • 距离

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

说明: 计算直线和直线或点之间的距离。

返回: 距离

参数:

  • other: 平行直线或点

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -67,7 +67,7 @@
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

参数:

  • other: 另一条直线

返回:

  • 交点

引发:

  • ValueError 直线平行

  • ValueError 直线不共面

源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

说明: 计算两条直线的交点。

返回: 交点

参数:

  • other: 另一条直线

引发:

  • ValueError 直线平行
  • ValueError 直线不共面
源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -82,7 +82,7 @@
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

参数:

  • point: 指定点

返回:

  • 垂线
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

说明: 计算直线经过指定点p的垂线。

返回: 垂线

参数:

  • point: 指定点
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -90,7 +90,7 @@
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

参数:

  • t: 参数t

返回:

源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

说明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

返回: 点

参数:

  • t: 参数t
源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -98,13 +98,13 @@
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

返回:

  • x(t), y(t), z(t)
源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

说明: 获取直线的参数方程。

返回: x(t), y(t), z(t)

源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

参数:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似平行
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

说明: 判断两条直线是否近似平行。

返回: 是否近似平行

参数:

  • other: 另一条直线
  • epsilon: 误差
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -113,7 +113,7 @@
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

参数:

  • other: 另一条直线

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

说明: 判断两条直线是否平行。

返回: 是否平行

参数:

  • other: 另一条直线
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -121,7 +121,7 @@
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

参数:

  • other: 另一条直线

返回:

  • 是否共线
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

说明: 判断两条直线是否共线。

返回: 是否共线

参数:

  • other: 另一条直线
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -129,7 +129,7 @@
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

参数:

  • point: 点

返回:

  • 是否在直线上
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

说明: 判断点是否在直线上。

返回: 是否在直线上

参数:

  • point: 点
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -137,7 +137,7 @@
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

参数:

  • other: 另一条直线

返回:

  • 是否共面
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

说明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

返回: 是否共面

参数:

  • other: 另一条直线
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -146,7 +146,7 @@
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

说明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -159,7 +159,7 @@
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

参数:

  • p1: 点1

  • p2: 点2

返回:

  • 直线
源代码
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

说明: 工厂函数 由两点构造直线。

返回: 直线

参数:

  • p1: 点1
  • p2: 点2
源代码
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -170,7 +170,7 @@
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

参数:

  • other: 另一条直线

返回:

  • 交点
源代码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

说明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

返回: 交点

参数:

  • other: 另一条直线
源代码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -183,7 +183,7 @@
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

  • other:
源代码
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

说明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

  • other:
源代码
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -195,7 +195,7 @@
 
         """
     return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
- + \ No newline at end of file diff --git a/api/mp_math/mp_math_typing.html b/api/mp_math/mp_math_typing.html index 94a3adc..1939efc 100644 --- a/api/mp_math/mp_math_typing.html +++ b/api/mp_math/mp_math_typing.html @@ -18,7 +18,7 @@
Skip to content

var RealNumber = int | float

  • 类型: TypeAlias

var Number = RealNumber | complex

  • 类型: TypeAlias

var Var = SingleVar | ArrayVar

  • 类型: TypeAlias

var OneSingleVarFunc = Callable[[SingleVar], SingleVar]

  • 类型: TypeAlias

var OneArrayFunc = Callable[[ArrayVar], ArrayVar]

  • 类型: TypeAlias

var OneVarFunc = OneSingleVarFunc | OneArrayFunc

  • 类型: TypeAlias

var TwoSingleVarsFunc = Callable[[SingleVar, SingleVar], SingleVar]

  • 类型: TypeAlias

var TwoArraysFunc = Callable[[ArrayVar, ArrayVar], ArrayVar]

  • 类型: TypeAlias

var TwoVarsFunc = TwoSingleVarsFunc | TwoArraysFunc

  • 类型: TypeAlias

var ThreeSingleVarsFunc = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

  • 类型: TypeAlias

var ThreeArraysFunc = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

  • 类型: TypeAlias

var ThreeVarsFunc = ThreeSingleVarsFunc | ThreeArraysFunc

  • 类型: TypeAlias

var MultiSingleVarsFunc = Callable[..., SingleVar]

  • 类型: TypeAlias

var MultiArraysFunc = Callable[..., ArrayVar]

  • 类型: TypeAlias

var MultiVarsFunc = MultiSingleVarsFunc | MultiArraysFunc

  • 类型: TypeAlias
- + \ No newline at end of file diff --git a/api/mp_math/plane.html b/api/mp_math/plane.html index d917112..a4b963b 100644 --- a/api/mp_math/plane.html +++ b/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

参数:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
+    
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

说明: 平面方程:ax + by + cz + d = 0

参数:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -29,7 +29,7 @@
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

参数:

  • other: 另一个平面

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

说明: 判断两个平面是否近似相等。

返回: 是否近似相等

参数:

  • other: 另一个平面
源代码
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -47,7 +47,7 @@
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

参数:

  • other: 另一个平面

返回:

  • 夹角弧度

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

说明: 计算平面与平面之间的夹角。

返回: 夹角弧度

参数:

  • other: 另一个平面

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -62,7 +62,7 @@
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

参数:

  • other: 另一个平面或点

返回:

  • 距离

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

说明: 计算平面与平面或点之间的距离。

返回: 距离

参数:

  • other: 另一个平面或点

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -77,7 +77,7 @@
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

参数:

  • other: 另一个平面

返回:

  • 两平面的交线
源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

说明: 计算两平面的交线。

返回: 两平面的交线

参数:

  • other: 另一个平面
源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -102,7 +102,7 @@
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

参数:

  • other: 不与平面平行或在平面上的直线

返回:

  • 交点

引发:

  • ValueError 平面与直线平行或重合
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

说明: 计算平面与直线的交点。

返回: 交点

参数:

  • other: 不与平面平行或在平面上的直线

引发:

  • ValueError 平面与直线平行或重合
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -116,7 +116,7 @@
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

参数:

  • point: 指定点

返回:

  • 所求平面
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

说明: 计算平行于该平面且过指定点的平面。

返回: 所求平面

参数:

  • point: 指定点
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -124,7 +124,7 @@
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

参数:

  • other: 另一个平面

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

说明: 判断两个平面是否平行。

返回: 是否平行

参数:

  • other: 另一个平面
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -132,14 +132,14 @@
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

返回:

  • 法向量
源代码
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

说明: 平面的法向量。

返回: 法向量

源代码
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

参数:

  • point: 平面上的一点

  • normal: 法向量

返回:

  • 平面
源代码
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

说明: 工厂函数 由点和法向量构造平面(点法式构造)。

返回: 平面

参数:

  • point: 平面上的一点
  • normal: 法向量
源代码
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -151,7 +151,7 @@
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

参数:

  • p1: 点1

  • p2: 点2

  • p3: 点3

返回:

  • 平面
源代码
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

说明: 工厂函数 由三点构造平面。

返回: 平面

参数:

  • p1: 点1
  • p2: 点2
  • p3: 点3
源代码
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -165,7 +165,7 @@
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

参数:

  • l1: 直线1

  • l2: 直线2

返回:

  • 平面
源代码
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

说明: 工厂函数 由两直线构造平面。

返回: 平面

参数:

  • l1: 直线1
  • l2: 直线2
源代码
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -179,7 +179,7 @@
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

参数:

  • point: 面上一点

  • line: 面上直线,不包含点

返回:

  • 平面
源代码
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

说明: 工厂函数 由点和直线构造平面。

返回: 平面

参数:

  • point: 面上一点
  • line: 面上直线,不包含点
源代码
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -189,11 +189,11 @@
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源代码
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源代码
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源代码
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源代码
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

参数:

  • other:

返回:

  • 不平行平面的交线,平面平行返回None
源代码
python
def __and__(self, other):
+    ...

method __and__(self, other)

说明: 取两平面的交集(人话:交线)

返回: 不平行平面的交线,平面平行返回None

参数:

  • other:
源代码
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -210,10 +210,10 @@
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源代码
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源代码
python
def __rand__(self, other: 'Line3') -> 'Point3':
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源代码
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源代码
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)
- + \ No newline at end of file diff --git a/api/mp_math/point.html b/api/mp_math/point.html index 600bf8b..4c4b94c 100644 --- a/api/mp_math/point.html +++ b/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Point3

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

笛卡尔坐标系中的点。

参数:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

源代码
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Point3

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

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

参数:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
源代码
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

参数:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

返回: 是否近似相等

参数:

  • other:
  • epsilon:
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -37,11 +37,11 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源代码
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

参数:

  • other:
源代码
python
def __add__(self, other):
+    ...

method self + other

说明: P + V -> P P + P -> P

参数:

  • other:
源代码
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -49,14 +49,14 @@
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

参数:

  • other:
源代码
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

参数:

  • other:
源代码
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

参数:

  • other:
源代码
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

说明: P - P -> V

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

参数:

  • other:
源代码
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -68,7 +68,7 @@
         """
     from .vector import Vector3
     return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
- + \ No newline at end of file diff --git a/api/mp_math/segment.html b/api/mp_math/segment.html index 9d9ffb2..0cbae2d 100644 --- a/api/mp_math/segment.html +++ b/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

说明: 三维空间中的线段。 :param p1: :param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -31,7 +31,7 @@
     self.length = self.direction.length
     '中心点'
     self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
- + \ No newline at end of file diff --git a/api/mp_math/utils.html b/api/mp_math/utils.html index 7ba994e..2e355da 100644 --- a/api/mp_math/utils.html +++ b/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

func clamp() -> float

区间限定函数

参数:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

返回:

  • 限制后的值
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

func clamp() -> float

说明: 区间限定函数

返回: 限制后的值

参数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,7 +28,7 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

参数:

  • x: 数1

  • y: 数2

  • epsilon: 误差

返回:

  • 是否近似相等
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

说明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

返回: 是否近似相等

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -38,7 +38,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

参数:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

说明: 获取数的符号。

返回: 符号 + - ""

参数:

  • x: 数
  • only_neg: 是否只返回负数的符号
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -51,7 +51,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

参数:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

说明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

返回: 符号 + - ""

参数:

  • x: 数
  • only_neg: 是否只返回负数的符号
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -67,8 +67,8 @@
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

源代码
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

源代码
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

源代码
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

源代码
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -78,10 +78,10 @@
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

源代码
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源代码
python
def __ne__(self, other):
+            self.raise_type_error(other)

method raise_type_error(self, other)

源代码
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源代码
python
def __ne__(self, other):
     return not self.__eq__(other)
- + \ No newline at end of file diff --git a/api/mp_math/vector.html b/api/mp_math/vector.html index 4b965b4..0d8bd54 100644 --- a/api/mp_math/vector.html +++ b/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Vector3

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

3维向量

参数:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

源代码
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Vector3

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

说明: 3维向量

参数:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
源代码
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

参数:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

说明: 判断两个向量是否近似相等。

返回: 是否近似相等

参数:

  • other:
  • epsilon:
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -37,7 +37,7 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

参数:

  • other: 另一个向量

返回:

  • 夹角
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

说明: 计算两个向量之间的夹角。

返回: 夹角

参数:

  • other: 另一个向量
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -45,7 +45,7 @@
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

参数:

  • other:

返回:

  • 行列式的结果
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

说明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

返回: 行列式的结果

参数:

  • other:
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -65,7 +65,7 @@
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

参数:

  • other: 另一个向量

  • epsilon: 允许的误差

返回:

  • 是否近似平行
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

说明: 判断两个向量是否近似平行。

返回: 是否近似平行

参数:

  • other: 另一个向量
  • epsilon: 允许的误差
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -74,7 +74,7 @@
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

参数:

  • other: 另一个向量

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

说明: 判断两个向量是否平行。

返回: 是否平行

参数:

  • other: 另一个向量
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -82,7 +82,7 @@
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

说明: 将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
     """
         将向量归一化。
 
@@ -91,32 +91,32 @@
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

源代码
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

源代码
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

返回:

源代码
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

说明: 向量的模。

返回: 模

源代码
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

返回:

  • 单位向量
源代码
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

说明: 获取该向量的单位向量。

返回: 单位向量

源代码
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

源代码
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

源代码
python
@overload
+    return self / self.length

method __abs__(self)

源代码
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

源代码
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

参数:

  • other:
源代码
python
def __add__(self, other):
+    ...

method self + other

说明: V + P -> P

V + V -> V

参数:

  • other:
源代码
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -131,7 +131,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

参数:

  • other:

返回:

  • 是否相等
源代码
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

说明: 判断两个向量是否相等。

返回: 是否相等

参数:

  • other:
源代码
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -139,7 +139,7 @@
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

源代码
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

说明: P + V -> P

别去点那边实现了。 :param other: :return:

源代码
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -147,11 +147,11 @@
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源代码
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源代码
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

源代码
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

参数:

  • other:
源代码
python
def __sub__(self, other):
+    ...

method self - other

说明: V - P -> P

V - V -> V

参数:

  • other:
源代码
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -165,7 +165,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

参数:

  • other:
源代码
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

说明: P - V -> P

参数:

  • other:
源代码
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -176,11 +176,11 @@
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源代码
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源代码
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

  • other:
源代码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

说明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

  • other:
源代码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -193,18 +193,18 @@
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源代码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

参数:

  • other:
源代码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源代码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

说明: 点乘。

参数:

  • other:
源代码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源代码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源代码
python
def __neg__(self):
+    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源代码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源代码
python
def __neg__(self):
     return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 类型: Vector3

  • 说明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 类型: Vector3

  • 说明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 类型: Vector3

  • 说明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 类型: Vector3

  • 说明: z轴单位向量

- + \ No newline at end of file diff --git a/api/particle/index.html b/api/particle/index.html index 68b1671..eba8ff2 100644 --- a/api/particle/index.html +++ b/api/particle/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/api/presets/index.html b/api/presets/index.html index c9e3bf5..1382c01 100644 --- a/api/presets/index.html +++ b/api/presets/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/api/presets/model/index.html b/api/presets/model/index.html index 6f4d6a2..687e011 100644 --- a/api/presets/model/index.html +++ b/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

参数:

  • radius:

  • density:

返回:

  • List[Point3]: 球体上的点集。
源代码
python
@staticmethod
+    
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

说明: 生成球体上的点集。

返回: List[Point3]: 球体上的点集。

参数:

  • radius:
  • density:
源代码
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -35,7 +35,7 @@
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
     return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
- + \ No newline at end of file diff --git a/assets/api_mp_math_angle.md.HvtyV1VE.js b/assets/api_mp_math_angle.md.B8w0LP6o.js similarity index 82% rename from assets/api_mp_math_angle.md.HvtyV1VE.js rename to assets/api_mp_math_angle.md.B8w0LP6o.js index 481299c..7b43490 100644 --- a/assets/api_mp_math_angle.md.HvtyV1VE.js +++ b/assets/api_mp_math_angle.md.B8w0LP6o.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

参数:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

源代码
python
def __init__(self, value: float, is_radian: bool=False):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

说明: 任意角度。

参数:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
源代码
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -8,92 +8,92 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

返回:

  • 余角
源代码
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

说明: 余角:两角的和为90°。

返回: 余角

源代码
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

返回:

  • 补角
源代码
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

说明: 补角:两角的和为180°。

返回: 补角

源代码
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

返回:

  • 弧度
源代码
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

说明: 角度。

返回: 弧度

源代码
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

返回:

  • 最小正角度
源代码
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

说明: 最小正角。

返回: 最小正角度

源代码
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

返回:

  • 最大负角度
源代码
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

说明: 最大负角。

返回: 最大负角度

源代码
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

返回:

  • 正弦值
源代码
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

说明: 正弦值。

返回: 正弦值

源代码
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

返回:

  • 余弦值
源代码
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

说明: 余弦值。

返回: 余弦值

源代码
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

返回:

  • 正切值
源代码
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

说明: 正切值。

返回: 正切值

源代码
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

返回:

  • 余切值
源代码
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

说明: 余切值。

返回: 余切值

源代码
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

返回:

  • 正割值
源代码
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

说明: 正割值。

返回: 正割值

源代码
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

返回:

  • 余割值
源代码
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

说明: 余割值。

返回: 余割值

源代码
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源代码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源代码
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源代码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源代码
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源代码
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源代码
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源代码
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源代码
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源代码
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源代码
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源代码
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

源代码
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

源代码
python
def __truediv__(self, other):
+    ...

method self / other

源代码
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; + return AnyAngle(self.radian / other, is_radian=True)
`,78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/api_mp_math_angle.md.HvtyV1VE.lean.js b/assets/api_mp_math_angle.md.B8w0LP6o.lean.js similarity index 58% rename from assets/api_mp_math_angle.md.HvtyV1VE.lean.js rename to assets/api_mp_math_angle.md.B8w0LP6o.lean.js index 3589a07..ca34d60 100644 --- a/assets/api_mp_math_angle.md.HvtyV1VE.lean.js +++ b/assets/api_mp_math_angle.md.B8w0LP6o.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n("",89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n("",78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/api_mp_math_equation.md.C2RSv9WY.js b/assets/api_mp_math_equation.md.Bx4yJe6o.js similarity index 83% rename from assets/api_mp_math_equation.md.C2RSv9WY.js rename to assets/api_mp_math_equation.md.Bx4yJe6o.js index 1f306b3..a1170c8 100644 --- a/assets/api_mp_math_equation.md.C2RSv9WY.js +++ b/assets/api_mp_math_equation.md.Bx4yJe6o.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

参数:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

返回:

  • 偏导函数

引发:

  • ValueError 无效变量类型
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

说明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

返回: 偏导函数

参数:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

引发:

  • ValueError 无效变量类型
源代码
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -28,16 +28,16 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源代码
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源代码
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

参数:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

说明: 曲线方程。

参数:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
源代码
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -47,7 +47,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

参数:

  • *t:

  • 参数:

源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:
源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -59,4 +59,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     if len(t) == 1:
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
-        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; + return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/api_mp_math_equation.md.C2RSv9WY.lean.js b/assets/api_mp_math_equation.md.Bx4yJe6o.lean.js similarity index 85% rename from assets/api_mp_math_equation.md.C2RSv9WY.lean.js rename to assets/api_mp_math_equation.md.Bx4yJe6o.lean.js index 72ef7c6..c988365 100644 --- a/assets/api_mp_math_equation.md.C2RSv9WY.lean.js +++ b/assets/api_mp_math_equation.md.Bx4yJe6o.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n("",24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n("",23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/api_mp_math_line.md.BPnyTp_q.js b/assets/api_mp_math_line.md.B1s7_FXM.js similarity index 73% rename from assets/api_mp_math_line.md.BPnyTp_q.js rename to assets/api_mp_math_line.md.B1s7_FXM.js index b6fcabc..c69e848 100644 --- a/assets/api_mp_math_line.md.BPnyTp_q.js +++ b/assets/api_mp_math_line.md.B1s7_FXM.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

参数:

  • point: 直线上的一点

  • direction: 直线的方向向量

源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

说明: 三维空间中的直线。由一个点和一个方向向量确定。

参数:

  • point: 直线上的一点
  • direction: 直线的方向向量
源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -6,7 +6,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

参数:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

说明: 判断两条直线是否近似相等。

返回: 是否近似相等

参数:

  • other: 另一条直线
  • epsilon: 误差
源代码
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -15,7 +15,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

参数:

  • other: 另一条直线

返回:

  • 夹角弧度

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

说明: 计算直线和直线之间的夹角。

返回: 夹角弧度

参数:

  • other: 另一条直线

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -25,7 +25,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

参数:

  • other: 平行直线或点

返回:

  • 距离

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

说明: 计算直线和直线或点之间的距离。

返回: 距离

参数:

  • other: 平行直线或点

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -48,7 +48,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

参数:

  • other: 另一条直线

返回:

  • 交点

引发:

  • ValueError 直线平行

  • ValueError 直线不共面

源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

说明: 计算两条直线的交点。

返回: 交点

参数:

  • other: 另一条直线

引发:

  • ValueError 直线平行
  • ValueError 直线不共面
源代码
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

参数:

  • point: 指定点

返回:

  • 垂线
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

说明: 计算直线经过指定点p的垂线。

返回: 垂线

参数:

  • point: 指定点
源代码
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -71,7 +71,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

参数:

  • t: 参数t

返回:

源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

说明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

返回: 点

参数:

  • t: 参数t
源代码
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -79,13 +79,13 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

返回:

  • x(t), y(t), z(t)
源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

说明: 获取直线的参数方程。

返回: x(t), y(t), z(t)

源代码
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

参数:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似平行
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

说明: 判断两条直线是否近似平行。

返回: 是否近似平行

参数:

  • other: 另一条直线
  • epsilon: 误差
源代码
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -94,7 +94,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

参数:

  • other: 另一条直线

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

说明: 判断两条直线是否平行。

返回: 是否平行

参数:

  • other: 另一条直线
源代码
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -102,7 +102,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

参数:

  • other: 另一条直线

返回:

  • 是否共线
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

说明: 判断两条直线是否共线。

返回: 是否共线

参数:

  • other: 另一条直线
源代码
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -110,7 +110,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

参数:

  • point: 点

返回:

  • 是否在直线上
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

说明: 判断点是否在直线上。

返回: 是否在直线上

参数:

  • point: 点
源代码
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -118,7 +118,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

参数:

  • other: 另一条直线

返回:

  • 是否共面
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

说明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

返回: 是否共面

参数:

  • other: 另一条直线
源代码
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -127,7 +127,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

说明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源代码
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -140,7 +140,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

参数:

  • p1: 点1

  • p2: 点2

返回:

  • 直线
源代码
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

说明: 工厂函数 由两点构造直线。

返回: 直线

参数:

  • p1: 点1
  • p2: 点2
源代码
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -151,7 +151,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

参数:

  • other: 另一条直线

返回:

  • 交点
源代码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

说明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

返回: 交点

参数:

  • other: 另一条直线
源代码
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -164,7 +164,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

  • other:
源代码
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

说明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

参数:

  • other:
源代码
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -175,4 +175,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_line.md.BPnyTp_q.lean.js b/assets/api_mp_math_line.md.B1s7_FXM.lean.js similarity index 85% rename from assets/api_mp_math_line.md.BPnyTp_q.lean.js rename to assets/api_mp_math_line.md.B1s7_FXM.lean.js index cc6392a..e425cef 100644 --- a/assets/api_mp_math_line.md.BPnyTp_q.lean.js +++ b/assets/api_mp_math_line.md.B1s7_FXM.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n("",119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n("",105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_plane.md.DLhf2OdI.js b/assets/api_mp_math_plane.md.BiW2-xb_.js similarity index 83% rename from assets/api_mp_math_plane.md.DLhf2OdI.js rename to assets/api_mp_math_plane.md.BiW2-xb_.js index 2678270..cc67880 100644 --- a/assets/api_mp_math_plane.md.DLhf2OdI.js +++ b/assets/api_mp_math_plane.md.BiW2-xb_.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

参数:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

说明: 平面方程:ax + by + cz + d = 0

参数:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
源代码
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -10,7 +10,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

参数:

  • other: 另一个平面

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

说明: 判断两个平面是否近似相等。

返回: 是否近似相等

参数:

  • other: 另一个平面
源代码
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -28,7 +28,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

参数:

  • other: 另一个平面

返回:

  • 夹角弧度

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

说明: 计算平面与平面之间的夹角。

返回: 夹角弧度

参数:

  • other: 另一个平面

引发:

  • TypeError 不支持的类型
源代码
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -43,7 +43,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

参数:

  • other: 另一个平面或点

返回:

  • 距离

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

说明: 计算平面与平面或点之间的距离。

返回: 距离

参数:

  • other: 另一个平面或点

引发:

  • TypeError 不支持的类型
源代码
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -58,7 +58,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

参数:

  • other: 另一个平面

返回:

  • 两平面的交线
源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

说明: 计算两平面的交线。

返回: 两平面的交线

参数:

  • other: 另一个平面
源代码
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -83,7 +83,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

参数:

  • other: 不与平面平行或在平面上的直线

返回:

  • 交点

引发:

  • ValueError 平面与直线平行或重合
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

说明: 计算平面与直线的交点。

返回: 交点

参数:

  • other: 不与平面平行或在平面上的直线

引发:

  • ValueError 平面与直线平行或重合
源代码
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -97,7 +97,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

参数:

  • point: 指定点

返回:

  • 所求平面
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

说明: 计算平行于该平面且过指定点的平面。

返回: 所求平面

参数:

  • point: 指定点
源代码
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -105,7 +105,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

参数:

  • other: 另一个平面

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

说明: 判断两个平面是否平行。

返回: 是否平行

参数:

  • other: 另一个平面
源代码
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -113,14 +113,14 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

返回:

  • 法向量
源代码
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

说明: 平面的法向量。

返回: 法向量

源代码
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

参数:

  • point: 平面上的一点

  • normal: 法向量

返回:

  • 平面
源代码
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

说明: 工厂函数 由点和法向量构造平面(点法式构造)。

返回: 平面

参数:

  • point: 平面上的一点
  • normal: 法向量
源代码
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -132,7 +132,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

参数:

  • p1: 点1

  • p2: 点2

  • p3: 点3

返回:

  • 平面
源代码
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

说明: 工厂函数 由三点构造平面。

返回: 平面

参数:

  • p1: 点1
  • p2: 点2
  • p3: 点3
源代码
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

参数:

  • l1: 直线1

  • l2: 直线2

返回:

  • 平面
源代码
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

说明: 工厂函数 由两直线构造平面。

返回: 平面

参数:

  • l1: 直线1
  • l2: 直线2
源代码
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -160,7 +160,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

参数:

  • point: 面上一点

  • line: 面上直线,不包含点

返回:

  • 平面
源代码
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

说明: 工厂函数 由点和直线构造平面。

返回: 平面

参数:

  • point: 面上一点
  • line: 面上直线,不包含点
源代码
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -170,11 +170,11 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源代码
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源代码
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源代码
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源代码
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

参数:

  • other:

返回:

  • 不平行平面的交线,平面平行返回None
源代码
python
def __and__(self, other):
+    ...

method __and__(self, other)

说明: 取两平面的交集(人话:交线)

返回: 不平行平面的交线,平面平行返回None

参数:

  • other:
源代码
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -191,6 +191,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源代码
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源代码
python
def __rand__(self, other: 'Line3') -> 'Point3':
-    return self.cal_intersection_point3(other)
`,116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; + raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源代码
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源代码
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/api_mp_math_plane.md.DLhf2OdI.lean.js b/assets/api_mp_math_plane.md.BiW2-xb_.lean.js similarity index 85% rename from assets/api_mp_math_plane.md.DLhf2OdI.lean.js rename to assets/api_mp_math_plane.md.BiW2-xb_.lean.js index f2f27fd..434353e 100644 --- a/assets/api_mp_math_plane.md.DLhf2OdI.lean.js +++ b/assets/api_mp_math_plane.md.BiW2-xb_.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n("",116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n("",103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/api_mp_math_point.md.0dOKpGzi.js b/assets/api_mp_math_point.md.Cl5vX84g.js similarity index 74% rename from assets/api_mp_math_point.md.0dOKpGzi.js rename to assets/api_mp_math_point.md.Cl5vX84g.js index 12ce1d5..163f362 100644 --- a/assets/api_mp_math_point.md.0dOKpGzi.js +++ b/assets/api_mp_math_point.md.Cl5vX84g.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},h=t(`

class Point3

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

笛卡尔坐标系中的点。

参数:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

源代码
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},l=t(`

class Point3

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

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

参数:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
源代码
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

参数:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

返回: 是否近似相等

参数:

  • other:
  • epsilon:
源代码
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -18,11 +18,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源代码
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

参数:

  • other:
源代码
python
def __add__(self, other):
+    ...

method self + other

说明: P + V -> P P + P -> P

参数:

  • other:
源代码
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -30,14 +30,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

参数:

  • other:
源代码
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

参数:

  • other:
源代码
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

参数:

  • other:
源代码
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

说明: P - P -> V

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

参数:

  • other:
源代码
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -48,4 +48,4 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_point.md.0dOKpGzi.lean.js b/assets/api_mp_math_point.md.Cl5vX84g.lean.js similarity index 70% rename from assets/api_mp_math_point.md.0dOKpGzi.lean.js rename to assets/api_mp_math_point.md.Cl5vX84g.lean.js index 2052d03..0d932bd 100644 --- a/assets/api_mp_math_point.md.0dOKpGzi.lean.js +++ b/assets/api_mp_math_point.md.Cl5vX84g.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},h=t("",35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},l=t("",34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_segment.md.9QWXtPbn.js b/assets/api_mp_math_segment.md.C6i78ST1.js similarity index 82% rename from assets/api_mp_math_segment.md.9QWXtPbn.js rename to assets/api_mp_math_segment.md.C6i78ST1.js index 4eab4c2..8e16b56 100644 --- a/assets/api_mp_math_segment.md.9QWXtPbn.js +++ b/assets/api_mp_math_segment.md.C6i78ST1.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

说明: 三维空间中的线段。 :param p1: :param p2:

源代码
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -11,4 +11,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     '长度'
     self.length = self.direction.length
     '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; + self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_segment.md.9QWXtPbn.lean.js b/assets/api_mp_math_segment.md.C6i78ST1.lean.js similarity index 57% rename from assets/api_mp_math_segment.md.9QWXtPbn.lean.js rename to assets/api_mp_math_segment.md.C6i78ST1.lean.js index d7a0a0b..5f0b88a 100644 --- a/assets/api_mp_math_segment.md.9QWXtPbn.lean.js +++ b/assets/api_mp_math_segment.md.C6i78ST1.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_utils.md.DdkUph5B.js b/assets/api_mp_math_utils.md.B902hNw4.js similarity index 77% rename from assets/api_mp_math_utils.md.DdkUph5B.js rename to assets/api_mp_math_utils.md.B902hNw4.js index fe3378f..2503b47 100644 --- a/assets/api_mp_math_utils.md.DdkUph5B.js +++ b/assets/api_mp_math_utils.md.B902hNw4.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n(`

func clamp() -> float

区间限定函数

参数:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

返回:

  • 限制后的值
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n(`

func clamp() -> float

说明: 区间限定函数

返回: 限制后的值

参数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,7 +9,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

参数:

  • x: 数1

  • y: 数2

  • epsilon: 误差

返回:

  • 是否近似相等
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

说明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

返回: 是否近似相等

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差
源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -19,7 +19,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

参数:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

说明: 获取数的符号。

返回: 符号 + - ""

参数:

  • x: 数
  • only_neg: 是否只返回负数的符号
源代码
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -32,7 +32,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

参数:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

说明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

返回: 符号 + - ""

参数:

  • x: 数
  • only_neg: 是否只返回负数的符号
源代码
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -48,8 +48,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

源代码
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

源代码
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

源代码
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

源代码
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -59,6 +59,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

源代码
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源代码
python
def __ne__(self, other):
-    return not self.__eq__(other)
`,37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + self.raise_type_error(other)

method raise_type_error(self, other)

源代码
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源代码
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_utils.md.DdkUph5B.lean.js b/assets/api_mp_math_utils.md.B902hNw4.lean.js similarity index 70% rename from assets/api_mp_math_utils.md.DdkUph5B.lean.js rename to assets/api_mp_math_utils.md.B902hNw4.lean.js index 8559b88..01c767a 100644 --- a/assets/api_mp_math_utils.md.DdkUph5B.lean.js +++ b/assets/api_mp_math_utils.md.B902hNw4.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n("",37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n("",33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_vector.md.Bodba8jG.js b/assets/api_mp_math_vector.md.CoooOTww.js similarity index 81% rename from assets/api_mp_math_vector.md.Bodba8jG.js rename to assets/api_mp_math_vector.md.CoooOTww.js index 0428b35..976c252 100644 --- a/assets/api_mp_math_vector.md.Bodba8jG.js +++ b/assets/api_mp_math_vector.md.CoooOTww.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t(`

class Vector3

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

3维向量

参数:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

源代码
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t(`

class Vector3

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

说明: 3维向量

参数:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
源代码
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

参数:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

说明: 判断两个向量是否近似相等。

返回: 是否近似相等

参数:

  • other:
  • epsilon:
源代码
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -18,7 +18,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

参数:

  • other: 另一个向量

返回:

  • 夹角
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

说明: 计算两个向量之间的夹角。

返回: 夹角

参数:

  • other: 另一个向量
源代码
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -26,7 +26,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

参数:

  • other:

返回:

  • 行列式的结果
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

说明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

返回: 行列式的结果

参数:

  • other:
源代码
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -46,7 +46,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

参数:

  • other: 另一个向量

  • epsilon: 允许的误差

返回:

  • 是否近似平行
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

说明: 判断两个向量是否近似平行。

返回: 是否近似平行

参数:

  • other: 另一个向量
  • epsilon: 允许的误差
源代码
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -55,7 +55,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

参数:

  • other: 另一个向量

返回:

  • 是否平行
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

说明: 判断两个向量是否平行。

返回: 是否平行

参数:

  • other: 另一个向量
源代码
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

说明: 将向量归一化。

自体归一化,不返回值。

源代码
python
def normalize(self):
     """
         将向量归一化。
 
@@ -72,32 +72,32 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

源代码
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

源代码
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

返回:

源代码
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

说明: 向量的模。

返回: 模

源代码
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

返回:

  • 单位向量
源代码
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

说明: 获取该向量的单位向量。

返回: 单位向量

源代码
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

源代码
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

源代码
python
@overload
+    return self / self.length

method __abs__(self)

源代码
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

源代码
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

参数:

  • other:
源代码
python
def __add__(self, other):
+    ...

method self + other

说明: V + P -> P

V + V -> V

参数:

  • other:
源代码
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -112,7 +112,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

参数:

  • other:

返回:

  • 是否相等
源代码
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

说明: 判断两个向量是否相等。

返回: 是否相等

参数:

  • other:
源代码
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -120,7 +120,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

源代码
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

说明: P + V -> P

别去点那边实现了。 :param other: :return:

源代码
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -128,11 +128,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源代码
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源代码
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

源代码
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

参数:

  • other:
源代码
python
def __sub__(self, other):
+    ...

method self - other

说明: V - P -> P

V - V -> V

参数:

  • other:
源代码
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

参数:

  • other:
源代码
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

说明: P - V -> P

参数:

  • other:
源代码
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -157,11 +157,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源代码
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源代码
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

  • other:
源代码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

说明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

参数:

  • other:
源代码
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -174,14 +174,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源代码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

参数:

  • other:
源代码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源代码
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

说明: 点乘。

参数:

  • other:
源代码
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源代码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源代码
python
def __neg__(self):
-    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 类型: Vector3

  • 说明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 类型: Vector3

  • 说明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 类型: Vector3

  • 说明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 类型: Vector3

  • 说明: z轴单位向量

`,133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源代码
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源代码
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 类型: Vector3

  • 说明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 类型: Vector3

  • 说明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 类型: Vector3

  • 说明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 类型: Vector3

  • 说明: z轴单位向量

`,125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.Bodba8jG.lean.js b/assets/api_mp_math_vector.md.CoooOTww.lean.js similarity index 85% rename from assets/api_mp_math_vector.md.Bodba8jG.lean.js rename to assets/api_mp_math_vector.md.CoooOTww.lean.js index 43c5e0a..b68d55a 100644 --- a/assets/api_mp_math_vector.md.Bodba8jG.lean.js +++ b/assets/api_mp_math_vector.md.CoooOTww.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t("",133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t("",125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_presets_model_index.md.YrmtLmca.js b/assets/api_presets_model_index.md.kSDvd14X.js similarity index 90% rename from assets/api_presets_model_index.md.YrmtLmca.js rename to assets/api_presets_model_index.md.kSDvd14X.js index d66832e..6efed50 100644 --- a/assets/api_presets_model_index.md.YrmtLmca.js +++ b/assets/api_presets_model_index.md.kSDvd14X.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

参数:

  • radius:

  • density:

返回:

  • List[Point3]: 球体上的点集。
源代码
python
@staticmethod
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

说明: 生成球体上的点集。

返回: List[Point3]: 球体上的点集。

参数:

  • radius:
  • density:
源代码
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -15,4 +15,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o
     x_array = radius * np.sin(phi_list) * np.cos(theta_list)
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/api_presets_model_index.md.YrmtLmca.lean.js b/assets/api_presets_model_index.md.kSDvd14X.lean.js similarity index 71% rename from assets/api_presets_model_index.md.YrmtLmca.lean.js rename to assets/api_presets_model_index.md.kSDvd14X.lean.js index adc84e0..433fffa 100644 --- a/assets/api_presets_model_index.md.YrmtLmca.lean.js +++ b/assets/api_presets_model_index.md.kSDvd14X.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n("",9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n("",8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/en_api_mp_math_angle.md.fmci6qlC.js b/assets/en_api_mp_math_angle.md.DmK_A9xI.js similarity index 84% rename from assets/en_api_mp_math_angle.md.fmci6qlC.js rename to assets/en_api_mp_math_angle.md.DmK_A9xI.js index f47c3d4..46d588d 100644 --- a/assets/en_api_mp_math_angle.md.fmci6qlC.js +++ b/assets/en_api_mp_math_angle.md.DmK_A9xI.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),e={name:"en/api/mp_math/angle.md"},t=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

Arguments:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

Source code
python
def __init__(self, value: float, is_radian: bool=False):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),e={name:"en/api/mp_math/angle.md"},t=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

Description: 任意角度。

Arguments:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
Source code
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -8,92 +8,92 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const c
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

Return:

  • 余角
Source code
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

Description: 余角:两角的和为90°。

Return: 余角

Source code
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

Return:

  • 补角
Source code
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

Description: 补角:两角的和为180°。

Return: 补角

Source code
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

Return:

  • 弧度
Source code
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

Description: 角度。

Return: 弧度

Source code
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

Return:

  • 最小正角度
Source code
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

Description: 最小正角。

Return: 最小正角度

Source code
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

Return:

  • 最大负角度
Source code
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

Description: 最大负角。

Return: 最大负角度

Source code
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

Return:

  • 正弦值
Source code
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

Description: 正弦值。

Return: 正弦值

Source code
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

Return:

  • 余弦值
Source code
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

Return:

  • 正切值
Source code
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

Description: 正切值。

Return: 正切值

Source code
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

Return:

  • 余切值
Source code
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

Description: 余切值。

Return: 余切值

Source code
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

Return:

  • 正割值
Source code
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

Description: 正割值。

Return: 正割值

Source code
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

Return:

  • 余割值
Source code
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

Description: 余割值。

Return: 余割值

Source code
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

Source code
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

Source code
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

Source code
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

Source code
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

Source code
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

Source code
python
def __truediv__(self, other):
+    ...

method self / other

Source code
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,89),l=[t];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; + return AnyAngle(self.radian / other, is_radian=True)
`,78),l=[t];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/en_api_mp_math_angle.md.fmci6qlC.lean.js b/assets/en_api_mp_math_angle.md.DmK_A9xI.lean.js similarity index 85% rename from assets/en_api_mp_math_angle.md.fmci6qlC.lean.js rename to assets/en_api_mp_math_angle.md.DmK_A9xI.lean.js index 3b6207d..789df0d 100644 --- a/assets/en_api_mp_math_angle.md.fmci6qlC.lean.js +++ b/assets/en_api_mp_math_angle.md.DmK_A9xI.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),e={name:"en/api/mp_math/angle.md"},t=n("",89),l=[t];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),e={name:"en/api/mp_math/angle.md"},t=n("",78),l=[t];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const F=s(e,[["render",h]]);export{c as __pageData,F as default}; diff --git a/assets/en_api_mp_math_equation.md.BwRlBW4s.js b/assets/en_api_mp_math_equation.md.BHF2EYD-.js similarity index 83% rename from assets/en_api_mp_math_equation.md.BwRlBW4s.js rename to assets/en_api_mp_math_equation.md.BHF2EYD-.js index e693d2a..73b09ec 100644 --- a/assets/en_api_mp_math_equation.md.BwRlBW4s.js +++ b/assets/en_api_mp_math_equation.md.BHF2EYD-.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Arguments:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

Return:

  • 偏导函数

Raises:

  • ValueError 无效变量类型
Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

Description: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Return: 偏导函数

Arguments:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

Raises:

  • ValueError 无效变量类型
Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -28,16 +28,16 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

Source code
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

Source code
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

Arguments:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

Description: 曲线方程。

Arguments:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -47,7 +47,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

Arguments:

  • *t:

  • 参数:

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:
Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -59,4 +59,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u
     if len(t) == 1:
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
-        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; + return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; diff --git a/assets/en_api_mp_math_equation.md.BwRlBW4s.lean.js b/assets/en_api_mp_math_equation.md.BHF2EYD-.lean.js similarity index 86% rename from assets/en_api_mp_math_equation.md.BwRlBW4s.lean.js rename to assets/en_api_mp_math_equation.md.BHF2EYD-.lean.js index 4c7a6bf..78e1a43 100644 --- a/assets/en_api_mp_math_equation.md.BwRlBW4s.lean.js +++ b/assets/en_api_mp_math_equation.md.BHF2EYD-.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n("",24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),l={name:"en/api/mp_math/equation.md"},t=n("",23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{u as __pageData,y as default}; diff --git a/assets/en_api_mp_math_line.md.B1oAhkHS.js b/assets/en_api_mp_math_line.md.B9L-UwK8.js similarity index 74% rename from assets/en_api_mp_math_line.md.B1oAhkHS.js rename to assets/en_api_mp_math_line.md.B9L-UwK8.js index ed13bff..0e78282 100644 --- a/assets/en_api_mp_math_line.md.B1oAhkHS.js +++ b/assets/en_api_mp_math_line.md.B9L-UwK8.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),l={name:"en/api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

Arguments:

  • point: 直线上的一点

  • direction: 直线的方向向量

Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),t={name:"en/api/mp_math/line.md"},l=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

Description: 三维空间中的直线。由一个点和一个方向向量确定。

Arguments:

  • point: 直线上的一点
  • direction: 直线的方向向量
Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -6,7 +6,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

Arguments:

  • other: 另一条直线

  • epsilon: 误差

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

Description: 判断两条直线是否近似相等。

Return: 是否近似相等

Arguments:

  • other: 另一条直线
  • epsilon: 误差
Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -15,7 +15,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

Arguments:

  • other: 另一条直线

Return:

  • 夹角弧度

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

Description: 计算直线和直线之间的夹角。

Return: 夹角弧度

Arguments:

  • other: 另一条直线

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -25,7 +25,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

Arguments:

  • other: 平行直线或点

Return:

  • 距离

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

Description: 计算直线和直线或点之间的距离。

Return: 距离

Arguments:

  • other: 平行直线或点

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -48,7 +48,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return:

  • 交点

Raises:

  • ValueError 直线平行

  • ValueError 直线不共面

Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

Description: 计算两条直线的交点。

Return: 交点

Arguments:

  • other: 另一条直线

Raises:

  • ValueError 直线平行
  • ValueError 直线不共面
Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

Arguments:

  • point: 指定点

Return:

  • 垂线
Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

Description: 计算直线经过指定点p的垂线。

Return: 垂线

Arguments:

  • point: 指定点
Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -71,7 +71,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Arguments:

  • t: 参数t

Return:

Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

Description: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Return: 点

Arguments:

  • t: 参数t
Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -79,13 +79,13 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

Return:

  • x(t), y(t), z(t)
Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

Description: 获取直线的参数方程。

Return: x(t), y(t), z(t)

Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

Arguments:

  • other: 另一条直线

  • epsilon: 误差

Return:

  • 是否近似平行
Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

Description: 判断两条直线是否近似平行。

Return: 是否近似平行

Arguments:

  • other: 另一条直线
  • epsilon: 误差
Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -94,7 +94,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

Arguments:

  • other: 另一条直线

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

Description: 判断两条直线是否平行。

Return: 是否平行

Arguments:

  • other: 另一条直线
Source code
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -102,7 +102,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return:

  • 是否共线
Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

Description: 判断两条直线是否共线。

Return: 是否共线

Arguments:

  • other: 另一条直线
Source code
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -110,7 +110,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

Arguments:

  • point: 点

Return:

  • 是否在直线上
Source code
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

Description: 判断点是否在直线上。

Return: 是否在直线上

Arguments:

  • point: 点
Source code
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -118,7 +118,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Arguments:

  • other: 另一条直线

Return:

  • 是否共面
Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

Description: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Return: 是否共面

Arguments:

  • other: 另一条直线
Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -127,7 +127,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

Description: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -140,7 +140,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

Arguments:

  • p1: 点1

  • p2: 点2

Return:

  • 直线
Source code
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

Description: 工厂函数 由两点构造直线。

Return: 直线

Arguments:

  • p1: 点1
  • p2: 点2
Source code
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -151,7 +151,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Arguments:

  • other: 另一条直线

Return:

  • 交点
Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

Description: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Return: 交点

Arguments:

  • other: 另一条直线
Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -164,7 +164,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

Description: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -175,4 +175,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,119),h=[t];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; + return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,105),e=[l];function h(p,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",h]]);export{E as __pageData,c as default}; diff --git a/assets/en_api_mp_math_line.md.B1oAhkHS.lean.js b/assets/en_api_mp_math_line.md.B9L-UwK8.lean.js similarity index 57% rename from assets/en_api_mp_math_line.md.B1oAhkHS.lean.js rename to assets/en_api_mp_math_line.md.B9L-UwK8.lean.js index bd73715..7e81d3b 100644 --- a/assets/en_api_mp_math_line.md.B1oAhkHS.lean.js +++ b/assets/en_api_mp_math_line.md.B9L-UwK8.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),l={name:"en/api/mp_math/line.md"},t=n("",119),h=[t];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"en/api/mp_math/line.md","filePath":"en/api/mp_math/line.md"}'),t={name:"en/api/mp_math/line.md"},l=n("",105),e=[l];function h(p,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",h]]);export{E as __pageData,c as default}; diff --git a/assets/en_api_mp_math_plane.md.D3xHJy8e.js b/assets/en_api_mp_math_plane.md.BkRMq93h.js similarity index 83% rename from assets/en_api_mp_math_plane.md.D3xHJy8e.js rename to assets/en_api_mp_math_plane.md.BkRMq93h.js index 38887e1..6317eec 100644 --- a/assets/en_api_mp_math_plane.md.D3xHJy8e.js +++ b/assets/en_api_mp_math_plane.md.BkRMq93h.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

Arguments:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

Description: 平面方程:ax + by + cz + d = 0

Arguments:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -10,7 +10,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

Arguments:

  • other: 另一个平面

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

Description: 判断两个平面是否近似相等。

Return: 是否近似相等

Arguments:

  • other: 另一个平面
Source code
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -28,7 +28,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

Arguments:

  • other: 另一个平面

Return:

  • 夹角弧度

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

Description: 计算平面与平面之间的夹角。

Return: 夹角弧度

Arguments:

  • other: 另一个平面

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -43,7 +43,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

Arguments:

  • other: 另一个平面或点

Return:

  • 距离

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

Description: 计算平面与平面或点之间的距离。

Return: 距离

Arguments:

  • other: 另一个平面或点

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -58,7 +58,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

Arguments:

  • other: 另一个平面

Return:

  • 两平面的交线
Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

Description: 计算两平面的交线。

Return: 两平面的交线

Arguments:

  • other: 另一个平面
Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -83,7 +83,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

Arguments:

  • other: 不与平面平行或在平面上的直线

Return:

  • 交点

Raises:

  • ValueError 平面与直线平行或重合
Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

Description: 计算平面与直线的交点。

Return: 交点

Arguments:

  • other: 不与平面平行或在平面上的直线

Raises:

  • ValueError 平面与直线平行或重合
Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -97,7 +97,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

Arguments:

  • point: 指定点

Return:

  • 所求平面
Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

Description: 计算平行于该平面且过指定点的平面。

Return: 所求平面

Arguments:

  • point: 指定点
Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -105,7 +105,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

Description: 判断两个平面是否平行。

Return: 是否平行

Arguments:

  • other: 另一个平面
Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -113,14 +113,14 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

Return:

  • 法向量
Source code
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

Description: 平面的法向量。

Return: 法向量

Source code
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

Arguments:

  • point: 平面上的一点

  • normal: 法向量

Return:

  • 平面
Source code
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

Description: 工厂函数 由点和法向量构造平面(点法式构造)。

Return: 平面

Arguments:

  • point: 平面上的一点
  • normal: 法向量
Source code
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -132,7 +132,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

Arguments:

  • p1: 点1

  • p2: 点2

  • p3: 点3

Return:

  • 平面
Source code
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

Description: 工厂函数 由三点构造平面。

Return: 平面

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3
Source code
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

Arguments:

  • l1: 直线1

  • l2: 直线2

Return:

  • 平面
Source code
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

Description: 工厂函数 由两直线构造平面。

Return: 平面

Arguments:

  • l1: 直线1
  • l2: 直线2
Source code
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -160,7 +160,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

Arguments:

  • point: 面上一点

  • line: 面上直线,不包含点

Return:

  • 平面
Source code
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

Description: 工厂函数 由点和直线构造平面。

Return: 平面

Arguments:

  • point: 面上一点
  • line: 面上直线,不包含点
Source code
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -170,11 +170,11 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

Source code
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

Source code
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

Source code
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

Source code
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

Arguments:

  • other:

Return:

  • 不平行平面的交线,平面平行返回None
Source code
python
def __and__(self, other):
+    ...

method __and__(self, other)

Description: 取两平面的交集(人话:交线)

Return: 不平行平面的交线,平面平行返回None

Arguments:

  • other:
Source code
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -191,6 +191,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
-    return self.cal_intersection_point3(other)
`,116),t=[h];function p(e,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; + raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,103),t=[h];function p(e,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_plane.md.D3xHJy8e.lean.js b/assets/en_api_mp_math_plane.md.BkRMq93h.lean.js similarity index 85% rename from assets/en_api_mp_math_plane.md.D3xHJy8e.lean.js rename to assets/en_api_mp_math_plane.md.BkRMq93h.lean.js index b1f0e83..e48f76b 100644 --- a/assets/en_api_mp_math_plane.md.D3xHJy8e.lean.js +++ b/assets/en_api_mp_math_plane.md.BkRMq93h.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n("",116),t=[h];function p(e,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},h=n("",103),t=[h];function p(e,k,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_point.md.P1GRdc2H.js b/assets/en_api_mp_math_point.md.S7QlcMfS.js similarity index 77% rename from assets/en_api_mp_math_point.md.P1GRdc2H.js rename to assets/en_api_mp_math_point.md.S7QlcMfS.js index dfd3fc3..2e3a6ff 100644 --- a/assets/en_api_mp_math_point.md.P1GRdc2H.js +++ b/assets/en_api_mp_math_point.md.S7QlcMfS.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),n={name:"en/api/mp_math/point.md"},h=t(`

class Point3

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

笛卡尔坐标系中的点。

Arguments:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

Source code
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),n={name:"en/api/mp_math/point.md"},l=t(`

class Point3

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

Description: 笛卡尔坐标系中的点。

Arguments:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
Source code
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

Arguments:

  • other:

  • epsilon:

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Return: 是否近似相等

Arguments:

  • other:
  • epsilon:
Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -18,11 +18,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

Source code
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

method self + other

Description: P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -30,14 +30,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

Arguments:

  • other:
Source code
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

Description: 判断两个点是否相等。

Arguments:

  • other:
Source code
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

Arguments:

  • other:
Source code
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

Description: P - P -> V

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

Arguments:

  • other:
Source code
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -48,4 +48,4 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_mp_math_point.md.P1GRdc2H.lean.js b/assets/en_api_mp_math_point.md.S7QlcMfS.lean.js similarity index 71% rename from assets/en_api_mp_math_point.md.P1GRdc2H.lean.js rename to assets/en_api_mp_math_point.md.S7QlcMfS.lean.js index 90dba7c..f995429 100644 --- a/assets/en_api_mp_math_point.md.P1GRdc2H.lean.js +++ b/assets/en_api_mp_math_point.md.S7QlcMfS.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),n={name:"en/api/mp_math/point.md"},h=t("",35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"en/api/mp_math/point.md","filePath":"en/api/mp_math/point.md"}'),n={name:"en/api/mp_math/point.md"},l=t("",34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_mp_math_segment.md.DqDvJpQR.js b/assets/en_api_mp_math_segment.md.CxreVgqR.js similarity index 84% rename from assets/en_api_mp_math_segment.md.DqDvJpQR.js rename to assets/en_api_mp_math_segment.md.CxreVgqR.js index eb3dad5..f462604 100644 --- a/assets/en_api_mp_math_segment.md.DqDvJpQR.js +++ b/assets/en_api_mp_math_segment.md.CxreVgqR.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

Description: 三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -11,4 +11,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o
     '长度'
     self.length = self.direction.length
     '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; + self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_segment.md.DqDvJpQR.lean.js b/assets/en_api_mp_math_segment.md.CxreVgqR.lean.js similarity index 85% rename from assets/en_api_mp_math_segment.md.DqDvJpQR.lean.js rename to assets/en_api_mp_math_segment.md.CxreVgqR.lean.js index 10ebc2f..31daebf 100644 --- a/assets/en_api_mp_math_segment.md.DqDvJpQR.lean.js +++ b/assets/en_api_mp_math_segment.md.CxreVgqR.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.B0nejTCy.js b/assets/en_api_mp_math_utils.md.B7bkEcyv.js similarity index 76% rename from assets/en_api_mp_math_utils.md.B0nejTCy.js rename to assets/en_api_mp_math_utils.md.B7bkEcyv.js index 641859c..5c84b87 100644 --- a/assets/en_api_mp_math_utils.md.B0nejTCy.js +++ b/assets/en_api_mp_math_utils.md.B7bkEcyv.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),l={name:"en/api/mp_math/utils.md"},t=n(`

func clamp() -> float

区间限定函数

Arguments:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

Return:

  • 限制后的值
Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),t={name:"en/api/mp_math/utils.md"},l=n(`

func clamp() -> float

Description: 区间限定函数

Return: 限制后的值

Arguments:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,7 +9,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Arguments:

  • x: 数1

  • y: 数2

  • epsilon: 误差

Return:

  • 是否近似相等
Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

Description: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Return: 是否近似相等

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差
Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -19,7 +19,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

Arguments:

  • x: 数

  • only_neg: 是否只返回负数的符号

Return:

  • 符号 + - ""
Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

Description: 获取数的符号。

Return: 符号 + - ""

Arguments:

  • x: 数
  • only_neg: 是否只返回负数的符号
Source code
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -32,7 +32,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Arguments:

  • x: 数

  • only_neg: 是否只返回负数的符号

Return:

  • 符号 + - ""
Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

Description: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Return: 符号 + - ""

Arguments:

  • x: 数
  • only_neg: 是否只返回负数的符号
Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -48,8 +48,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

Source code
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

Source code
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -59,6 +59,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

Source code
python
def __ne__(self, other):
-    return not self.__eq__(other)
`,37),h=[t];function p(e,k,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + self.raise_type_error(other)

method raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

Source code
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,33),h=[l];function p(e,k,r,d,o,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.B0nejTCy.lean.js b/assets/en_api_mp_math_utils.md.B7bkEcyv.lean.js similarity index 57% rename from assets/en_api_mp_math_utils.md.B0nejTCy.lean.js rename to assets/en_api_mp_math_utils.md.B7bkEcyv.lean.js index f3abe36..f7f1f3a 100644 --- a/assets/en_api_mp_math_utils.md.B0nejTCy.lean.js +++ b/assets/en_api_mp_math_utils.md.B7bkEcyv.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),l={name:"en/api/mp_math/utils.md"},t=n("",37),h=[t];function p(e,k,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"en/api/mp_math/utils.md","filePath":"en/api/mp_math/utils.md"}'),t={name:"en/api/mp_math/utils.md"},l=n("",33),h=[l];function p(e,k,r,d,o,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/en_api_mp_math_vector.md.BpRKRIGw.js b/assets/en_api_mp_math_vector.md.BLUu1BnW.js similarity index 81% rename from assets/en_api_mp_math_vector.md.BpRKRIGw.js rename to assets/en_api_mp_math_vector.md.BLUu1BnW.js index a1687d7..383381b 100644 --- a/assets/en_api_mp_math_vector.md.BpRKRIGw.js +++ b/assets/en_api_mp_math_vector.md.BLUu1BnW.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),n={name:"en/api/mp_math/vector.md"},h=t(`

class Vector3

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

3维向量

Arguments:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

Source code
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),n={name:"en/api/mp_math/vector.md"},h=t(`

class Vector3

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

Description: 3维向量

Arguments:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
Source code
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

Arguments:

  • other:

  • epsilon:

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

Description: 判断两个向量是否近似相等。

Return: 是否近似相等

Arguments:

  • other:
  • epsilon:
Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -18,7 +18,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

Arguments:

  • other: 另一个向量

Return:

  • 夹角
Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

Description: 计算两个向量之间的夹角。

Return: 夹角

Arguments:

  • other: 另一个向量
Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -26,7 +26,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Arguments:

  • other:

Return:

  • 行列式的结果
Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

Description: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Return: 行列式的结果

Arguments:

  • other:
Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -46,7 +46,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

Arguments:

  • other: 另一个向量

  • epsilon: 允许的误差

Return:

  • 是否近似平行
Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

Description: 判断两个向量是否近似平行。

Return: 是否近似平行

Arguments:

  • other: 另一个向量
  • epsilon: 允许的误差
Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -55,7 +55,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

Arguments:

  • other: 另一个向量

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

Description: 判断两个向量是否平行。

Return: 是否平行

Arguments:

  • other: 另一个向量
Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

Description: 将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
     """
         将向量归一化。
 
@@ -72,32 +72,32 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

Source code
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

Source code
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

Return:

Source code
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

Description: 向量的模。

Return: 模

Source code
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

Return:

  • 单位向量
Source code
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

Description: 获取该向量的单位向量。

Return: 单位向量

Source code
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

Source code
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

Source code
python
@overload
+    return self / self.length

method __abs__(self)

Source code
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

Source code
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

method self + other

Description: V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -112,7 +112,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

Arguments:

  • other:

Return:

  • 是否相等
Source code
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

Description: 判断两个向量是否相等。

Return: 是否相等

Arguments:

  • other:
Source code
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -120,7 +120,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

Description: P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -128,11 +128,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

Source code
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

Source code
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

Source code
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
+    ...

method self - other

Description: V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

Arguments:

  • other:
Source code
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

Description: P - V -> P

Arguments:

  • other:
Source code
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -157,11 +157,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

Source code
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

Source code
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

Source code
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

Source code
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

Description: 数组运算 非点乘。点乘使用@,叉乘使用cross。

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -174,14 +174,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

Arguments:

  • other:
Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

Description: 点乘。

Arguments:

  • other:
Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

Source code
python
def __neg__(self):
-    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • Type: Vector3

  • Description: 零向量

var x_axis = Vector3(1, 0, 0)

  • Type: Vector3

  • Description: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • Type: Vector3

  • Description: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • Type: Vector3

  • Description: z轴单位向量

`,133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

Source code
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • Type: Vector3

  • Description: 零向量

var x_axis = Vector3(1, 0, 0)

  • Type: Vector3

  • Description: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • Type: Vector3

  • Description: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • Type: Vector3

  • Description: z轴单位向量

`,125),e=[h];function l(p,k,r,o,d,E){return a(),i("div",null,e)}const F=s(n,[["render",l]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_mp_math_vector.md.BpRKRIGw.lean.js b/assets/en_api_mp_math_vector.md.BLUu1BnW.lean.js similarity index 71% rename from assets/en_api_mp_math_vector.md.BpRKRIGw.lean.js rename to assets/en_api_mp_math_vector.md.BLUu1BnW.lean.js index d177c3f..0c06b93 100644 --- a/assets/en_api_mp_math_vector.md.BpRKRIGw.lean.js +++ b/assets/en_api_mp_math_vector.md.BLUu1BnW.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),n={name:"en/api/mp_math/vector.md"},h=t("",133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),n={name:"en/api/mp_math/vector.md"},h=t("",125),e=[h];function l(p,k,r,o,d,E){return a(),i("div",null,e)}const F=s(n,[["render",l]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_presets_model_index.md.j5zmPSwU.js b/assets/en_api_presets_model_index.md.Bd091b7b.js similarity index 90% rename from assets/en_api_presets_model_index.md.j5zmPSwU.js rename to assets/en_api_presets_model_index.md.Bd091b7b.js index 205228e..0cc6b7a 100644 --- a/assets/en_api_presets_model_index.md.j5zmPSwU.js +++ b/assets/en_api_presets_model_index.md.Bd091b7b.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),t={name:"en/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

Arguments:

  • radius:

  • density:

Return:

  • List[Point3]: 球体上的点集。
Source code
python
@staticmethod
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),t={name:"en/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

Description: 生成球体上的点集。

Return: List[Point3]: 球体上的点集。

Arguments:

  • radius:
  • density:
Source code
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -15,4 +15,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o
     x_array = radius * np.sin(phi_list) * np.cos(theta_list)
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/en_api_presets_model_index.md.j5zmPSwU.lean.js b/assets/en_api_presets_model_index.md.Bd091b7b.lean.js similarity index 72% rename from assets/en_api_presets_model_index.md.j5zmPSwU.lean.js rename to assets/en_api_presets_model_index.md.Bd091b7b.lean.js index 69c8af9..28f9d3a 100644 --- a/assets/en_api_presets_model_index.md.j5zmPSwU.lean.js +++ b/assets/en_api_presets_model_index.md.Bd091b7b.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),t={name:"en/api/presets/model/index.md"},h=n("",9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"en/api/presets/model/index.md","filePath":"en/api/presets/model/index.md"}'),t={name:"en/api/presets/model/index.md"},h=n("",8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_angle.md.D2dStPZh.js b/assets/ja_api_mp_math_angle.md.DxBe_g0o.js similarity index 82% rename from assets/ja_api_mp_math_angle.md.D2dStPZh.js rename to assets/ja_api_mp_math_angle.md.DxBe_g0o.js index 01d7a73..cb5c395 100644 --- a/assets/ja_api_mp_math_angle.md.D2dStPZh.js +++ b/assets/ja_api_mp_math_angle.md.DxBe_g0o.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),t={name:"ja/api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

引数:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),t={name:"ja/api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

説明: 任意角度。

引数:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -8,92 +8,92 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

戻り値:

  • 余角
ソースコード
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

説明: 余角:两角的和为90°。

戻り値: 余角

ソースコード
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

戻り値:

  • 补角
ソースコード
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

説明: 补角:两角的和为180°。

戻り値: 补角

ソースコード
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

戻り値:

  • 弧度
ソースコード
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

説明: 角度。

戻り値: 弧度

ソースコード
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

戻り値:

  • 最小正角度
ソースコード
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

説明: 最小正角。

戻り値: 最小正角度

ソースコード
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

戻り値:

  • 最大负角度
ソースコード
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

説明: 最大负角。

戻り値: 最大负角度

ソースコード
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

戻り値:

  • 正弦值
ソースコード
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

説明: 正弦值。

戻り値: 正弦值

ソースコード
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

戻り値:

  • 余弦值
ソースコード
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

説明: 余弦值。

戻り値: 余弦值

ソースコード
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

戻り値:

  • 正切值
ソースコード
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

説明: 正切值。

戻り値: 正切值

ソースコード
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

戻り値:

  • 余切值
ソースコード
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

説明: 余切值。

戻り値: 余切值

ソースコード
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

戻り値:

  • 正割值
ソースコード
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

説明: 正割值。

戻り値: 正割值

ソースコード
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

戻り値:

  • 余割值
ソースコード
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

説明: 余割值。

戻り値: 余割值

ソースコード
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

ソースコード
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

ソースコード
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

ソースコード
python
def __truediv__(self, other):
+    ...

method self / other

ソースコード
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; + return AnyAngle(self.radian / other, is_radian=True)
`,78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/ja_api_mp_math_angle.md.D2dStPZh.lean.js b/assets/ja_api_mp_math_angle.md.DxBe_g0o.lean.js similarity index 71% rename from assets/ja_api_mp_math_angle.md.D2dStPZh.lean.js rename to assets/ja_api_mp_math_angle.md.DxBe_g0o.lean.js index 48dff8f..0985b57 100644 --- a/assets/ja_api_mp_math_angle.md.D2dStPZh.lean.js +++ b/assets/ja_api_mp_math_angle.md.DxBe_g0o.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),t={name:"ja/api/mp_math/angle.md"},e=n("",89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"ja/api/mp_math/angle.md","filePath":"ja/api/mp_math/angle.md"}'),t={name:"ja/api/mp_math/angle.md"},e=n("",78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/ja_api_mp_math_equation.md.Cj8tgo_3.js b/assets/ja_api_mp_math_equation.md.CCgJ-L2G.js similarity index 83% rename from assets/ja_api_mp_math_equation.md.Cj8tgo_3.js rename to assets/ja_api_mp_math_equation.md.CCgJ-L2G.js index dc6213e..028c7f0 100644 --- a/assets/ja_api_mp_math_equation.md.Cj8tgo_3.js +++ b/assets/ja_api_mp_math_equation.md.CCgJ-L2G.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

引数:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

戻り値:

  • 偏导函数

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

説明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

戻り値: 偏导函数

引数:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -28,16 +28,16 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

引数:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

説明: 曲线方程。

引数:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -47,7 +47,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

引数:

  • *t:

  • 参数:

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:
ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -59,4 +59,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     if len(t) == 1:
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
-        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; + return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/ja_api_mp_math_equation.md.Cj8tgo_3.lean.js b/assets/ja_api_mp_math_equation.md.CCgJ-L2G.lean.js similarity index 86% rename from assets/ja_api_mp_math_equation.md.Cj8tgo_3.lean.js rename to assets/ja_api_mp_math_equation.md.CCgJ-L2G.lean.js index e34836e..83b725c 100644 --- a/assets/ja_api_mp_math_equation.md.Cj8tgo_3.lean.js +++ b/assets/ja_api_mp_math_equation.md.CCgJ-L2G.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n("",24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"ja/api/mp_math/equation.md","filePath":"ja/api/mp_math/equation.md"}'),l={name:"ja/api/mp_math/equation.md"},t=n("",23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/ja_api_mp_math_line.md.Dg8duKLw.js b/assets/ja_api_mp_math_line.md.CxvAbM2L.js similarity index 73% rename from assets/ja_api_mp_math_line.md.Dg8duKLw.js rename to assets/ja_api_mp_math_line.md.CxvAbM2L.js index 2b18144..90c6f83 100644 --- a/assets/ja_api_mp_math_line.md.Dg8duKLw.js +++ b/assets/ja_api_mp_math_line.md.CxvAbM2L.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

引数:

  • point: 直线上的一点

  • direction: 直线的方向向量

ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

説明: 三维空间中的直线。由一个点和一个方向向量确定。

引数:

  • point: 直线上的一点
  • direction: 直线的方向向量
ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -6,7 +6,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

引数:

  • other: 另一条直线

  • epsilon: 误差

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

説明: 判断两条直线是否近似相等。

戻り値: 是否近似相等

引数:

  • other: 另一条直线
  • epsilon: 误差
ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -15,7 +15,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

引数:

  • other: 另一条直线

戻り値:

  • 夹角弧度

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

説明: 计算直线和直线之间的夹角。

戻り値: 夹角弧度

引数:

  • other: 另一条直线

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -25,7 +25,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

引数:

  • other: 平行直线或点

戻り値:

  • 距离

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

説明: 计算直线和直线或点之间的距离。

戻り値: 距离

引数:

  • other: 平行直线或点

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -48,7 +48,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

引数:

  • other: 另一条直线

戻り値:

  • 交点

例外:

  • ValueError 直线平行

  • ValueError 直线不共面

ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

説明: 计算两条直线的交点。

戻り値: 交点

引数:

  • other: 另一条直线

例外:

  • ValueError 直线平行
  • ValueError 直线不共面
ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

引数:

  • point: 指定点

戻り値:

  • 垂线
ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

説明: 计算直线经过指定点p的垂线。

戻り値: 垂线

引数:

  • point: 指定点
ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -71,7 +71,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

引数:

  • t: 参数t

戻り値:

ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

説明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

戻り値: 点

引数:

  • t: 参数t
ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -79,13 +79,13 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

戻り値:

  • x(t), y(t), z(t)
ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

説明: 获取直线的参数方程。

戻り値: x(t), y(t), z(t)

ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

引数:

  • other: 另一条直线

  • epsilon: 误差

戻り値:

  • 是否近似平行
ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

説明: 判断两条直线是否近似平行。

戻り値: 是否近似平行

引数:

  • other: 另一条直线
  • epsilon: 误差
ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -94,7 +94,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

引数:

  • other: 另一条直线

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

説明: 判断两条直线是否平行。

戻り値: 是否平行

引数:

  • other: 另一条直线
ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -102,7 +102,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

引数:

  • other: 另一条直线

戻り値:

  • 是否共线
ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

説明: 判断两条直线是否共线。

戻り値: 是否共线

引数:

  • other: 另一条直线
ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -110,7 +110,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

引数:

  • point: 点

戻り値:

  • 是否在直线上
ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

説明: 判断点是否在直线上。

戻り値: 是否在直线上

引数:

  • point: 点
ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -118,7 +118,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

引数:

  • other: 另一条直线

戻り値:

  • 是否共面
ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

説明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

戻り値: 是否共面

引数:

  • other: 另一条直线
ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -127,7 +127,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

説明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -140,7 +140,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

引数:

  • p1: 点1

  • p2: 点2

戻り値:

  • 直线
ソースコード
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

説明: 工厂函数 由两点构造直线。

戻り値: 直线

引数:

  • p1: 点1
  • p2: 点2
ソースコード
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -151,7 +151,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

引数:

  • other: 另一条直线

戻り値:

  • 交点
ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

説明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

戻り値: 交点

引数:

  • other: 另一条直线
ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -164,7 +164,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

  • other:
ソースコード
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

説明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

  • other:
ソースコード
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -175,4 +175,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_line.md.Dg8duKLw.lean.js b/assets/ja_api_mp_math_line.md.CxvAbM2L.lean.js similarity index 85% rename from assets/ja_api_mp_math_line.md.Dg8duKLw.lean.js rename to assets/ja_api_mp_math_line.md.CxvAbM2L.lean.js index d3a0964..8842389 100644 --- a/assets/ja_api_mp_math_line.md.Dg8duKLw.lean.js +++ b/assets/ja_api_mp_math_line.md.CxvAbM2L.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},t=n("",119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),l={name:"ja/api/mp_math/line.md"},t=n("",105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_plane.md.CTOkqSft.js b/assets/ja_api_mp_math_plane.md.DGnOnQrW.js similarity index 82% rename from assets/ja_api_mp_math_plane.md.CTOkqSft.js rename to assets/ja_api_mp_math_plane.md.DGnOnQrW.js index 75198d9..a9c992c 100644 --- a/assets/ja_api_mp_math_plane.md.CTOkqSft.js +++ b/assets/ja_api_mp_math_plane.md.DGnOnQrW.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

引数:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

説明: 平面方程:ax + by + cz + d = 0

引数:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -10,7 +10,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

引数:

  • other: 另一个平面

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

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

戻り値: 是否近似相等

引数:

  • other: 另一个平面
ソースコード
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -28,7 +28,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

引数:

  • other: 另一个平面

戻り値:

  • 夹角弧度

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

説明: 计算平面与平面之间的夹角。

戻り値: 夹角弧度

引数:

  • other: 另一个平面

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -43,7 +43,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

引数:

  • other: 另一个平面或点

戻り値:

  • 距离

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

説明: 计算平面与平面或点之间的距离。

戻り値: 距离

引数:

  • other: 另一个平面或点

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -58,7 +58,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

引数:

  • other: 另一个平面

戻り値:

  • 两平面的交线
ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

説明: 计算两平面的交线。

戻り値: 两平面的交线

引数:

  • other: 另一个平面
ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -83,7 +83,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

引数:

  • other: 不与平面平行或在平面上的直线

戻り値:

  • 交点

例外:

  • ValueError 平面与直线平行或重合
ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

説明: 计算平面与直线的交点。

戻り値: 交点

引数:

  • other: 不与平面平行或在平面上的直线

例外:

  • ValueError 平面与直线平行或重合
ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -97,7 +97,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

引数:

  • point: 指定点

戻り値:

  • 所求平面
ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

説明: 计算平行于该平面且过指定点的平面。

戻り値: 所求平面

引数:

  • point: 指定点
ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -105,7 +105,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

引数:

  • other: 另一个平面

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

説明: 判断两个平面是否平行。

戻り値: 是否平行

引数:

  • other: 另一个平面
ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -113,14 +113,14 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

戻り値:

  • 法向量
ソースコード
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

説明: 平面的法向量。

戻り値: 法向量

ソースコード
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

引数:

  • point: 平面上的一点

  • normal: 法向量

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

説明: 工厂函数 由点和法向量构造平面(点法式构造)。

戻り値: 平面

引数:

  • point: 平面上的一点
  • normal: 法向量
ソースコード
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -132,7 +132,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

引数:

  • p1: 点1

  • p2: 点2

  • p3: 点3

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

説明: 工厂函数 由三点构造平面。

戻り値: 平面

引数:

  • p1: 点1
  • p2: 点2
  • p3: 点3
ソースコード
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

引数:

  • l1: 直线1

  • l2: 直线2

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

説明: 工厂函数 由两直线构造平面。

戻り値: 平面

引数:

  • l1: 直线1
  • l2: 直线2
ソースコード
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -160,7 +160,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

引数:

  • point: 面上一点

  • line: 面上直线,不包含点

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

説明: 工厂函数 由点和直线构造平面。

戻り値: 平面

引数:

  • point: 面上一点
  • line: 面上直线,不包含点
ソースコード
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -170,11 +170,11 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

ソースコード
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

ソースコード
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

ソースコード
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

ソースコード
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

引数:

  • other:

戻り値:

  • 不平行平面的交线,平面平行返回None
ソースコード
python
def __and__(self, other):
+    ...

method __and__(self, other)

説明: 取两平面的交集(人话:交线)

戻り値: 不平行平面的交线,平面平行返回None

引数:

  • other:
ソースコード
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -191,6 +191,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

ソースコード
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
-    return self.cal_intersection_point3(other)
`,116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; + raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

ソースコード
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_plane.md.CTOkqSft.lean.js b/assets/ja_api_mp_math_plane.md.DGnOnQrW.lean.js similarity index 85% rename from assets/ja_api_mp_math_plane.md.CTOkqSft.lean.js rename to assets/ja_api_mp_math_plane.md.DGnOnQrW.lean.js index f7f0be9..f33e85f 100644 --- a/assets/ja_api_mp_math_plane.md.CTOkqSft.lean.js +++ b/assets/ja_api_mp_math_plane.md.DGnOnQrW.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n("",116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"ja/api/mp_math/plane.md","filePath":"ja/api/mp_math/plane.md"}'),l={name:"ja/api/mp_math/plane.md"},h=n("",103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_point.md.ZsmRVuaC.js b/assets/ja_api_mp_math_point.md.0J5Y2wYa.js similarity index 74% rename from assets/ja_api_mp_math_point.md.ZsmRVuaC.js rename to assets/ja_api_mp_math_point.md.0J5Y2wYa.js index f953953..892ca50 100644 --- a/assets/ja_api_mp_math_point.md.ZsmRVuaC.js +++ b/assets/ja_api_mp_math_point.md.0J5Y2wYa.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),n={name:"ja/api/mp_math/point.md"},h=t(`

class Point3

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

笛卡尔坐标系中的点。

引数:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),n={name:"ja/api/mp_math/point.md"},l=t(`

class Point3

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

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

引数:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
ソースコード
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

引数:

  • other:

  • epsilon:

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

戻り値: 是否近似相等

引数:

  • other:
  • epsilon:
ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -18,11 +18,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

ソースコード
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

引数:

  • other:
ソースコード
python
def __add__(self, other):
+    ...

method self + other

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

引数:

  • other:
ソースコード
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -30,14 +30,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

引数:

  • other:
ソースコード
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

引数:

  • other:
ソースコード
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

引数:

  • other:
ソースコード
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

説明: P - P -> V

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

引数:

  • other:
ソースコード
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -48,4 +48,4 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_point.md.ZsmRVuaC.lean.js b/assets/ja_api_mp_math_point.md.0J5Y2wYa.lean.js similarity index 71% rename from assets/ja_api_mp_math_point.md.ZsmRVuaC.lean.js rename to assets/ja_api_mp_math_point.md.0J5Y2wYa.lean.js index 3466d9a..735a512 100644 --- a/assets/ja_api_mp_math_point.md.ZsmRVuaC.lean.js +++ b/assets/ja_api_mp_math_point.md.0J5Y2wYa.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),n={name:"ja/api/mp_math/point.md"},h=t("",35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"ja/api/mp_math/point.md","filePath":"ja/api/mp_math/point.md"}'),n={name:"ja/api/mp_math/point.md"},l=t("",34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_segment.md.D5ZKDDr_.js b/assets/ja_api_mp_math_segment.md.D0U5bMSu.js similarity index 82% rename from assets/ja_api_mp_math_segment.md.D5ZKDDr_.js rename to assets/ja_api_mp_math_segment.md.D0U5bMSu.js index afc42da..522a58c 100644 --- a/assets/ja_api_mp_math_segment.md.D5ZKDDr_.js +++ b/assets/ja_api_mp_math_segment.md.D0U5bMSu.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

説明: 三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -11,4 +11,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     '长度'
     self.length = self.direction.length
     '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; + self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_segment.md.D5ZKDDr_.lean.js b/assets/ja_api_mp_math_segment.md.D0U5bMSu.lean.js similarity index 57% rename from assets/ja_api_mp_math_segment.md.D5ZKDDr_.lean.js rename to assets/ja_api_mp_math_segment.md.D0U5bMSu.lean.js index 91c8dde..72f6bf5 100644 --- a/assets/ja_api_mp_math_segment.md.D5ZKDDr_.lean.js +++ b/assets/ja_api_mp_math_segment.md.D0U5bMSu.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_utils.md.jeRmCp2Q.js b/assets/ja_api_mp_math_utils.md.zOjWX1mJ.js similarity index 77% rename from assets/ja_api_mp_math_utils.md.jeRmCp2Q.js rename to assets/ja_api_mp_math_utils.md.zOjWX1mJ.js index 0c0c990..4a0fc8f 100644 --- a/assets/ja_api_mp_math_utils.md.jeRmCp2Q.js +++ b/assets/ja_api_mp_math_utils.md.zOjWX1mJ.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},t=n(`

func clamp() -> float

区间限定函数

引数:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

戻り値:

  • 限制后的值
ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},t=n(`

func clamp() -> float

説明: 区间限定函数

戻り値: 限制后的值

引数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,7 +9,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

引数:

  • x: 数1

  • y: 数2

  • epsilon: 误差

戻り値:

  • 是否近似相等
ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

説明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

戻り値: 是否近似相等

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差
ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -19,7 +19,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

引数:

  • x: 数

  • only_neg: 是否只返回负数的符号

戻り値:

  • 符号 + - ""
ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

説明: 获取数的符号。

戻り値: 符号 + - ""

引数:

  • x: 数
  • only_neg: 是否只返回负数的符号
ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -32,7 +32,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

引数:

  • x: 数

  • only_neg: 是否只返回负数的符号

戻り値:

  • 符号 + - ""
ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

説明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

戻り値: 符号 + - ""

引数:

  • x: 数
  • only_neg: 是否只返回负数的符号
ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -48,8 +48,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -59,6 +59,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

ソースコード
python
def __ne__(self, other):
-    return not self.__eq__(other)
`,37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + self.raise_type_error(other)

method raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

ソースコード
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_utils.md.jeRmCp2Q.lean.js b/assets/ja_api_mp_math_utils.md.zOjWX1mJ.lean.js similarity index 85% rename from assets/ja_api_mp_math_utils.md.jeRmCp2Q.lean.js rename to assets/ja_api_mp_math_utils.md.zOjWX1mJ.lean.js index 627f47a..33263b4 100644 --- a/assets/ja_api_mp_math_utils.md.jeRmCp2Q.lean.js +++ b/assets/ja_api_mp_math_utils.md.zOjWX1mJ.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},t=n("",37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"ja/api/mp_math/utils.md","filePath":"ja/api/mp_math/utils.md"}'),l={name:"ja/api/mp_math/utils.md"},t=n("",33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_vector.md.DAXdHSjp.js b/assets/ja_api_mp_math_vector.md.DiKIzhuY.js similarity index 81% rename from assets/ja_api_mp_math_vector.md.DAXdHSjp.js rename to assets/ja_api_mp_math_vector.md.DiKIzhuY.js index 71d30c1..5f7c6dd 100644 --- a/assets/ja_api_mp_math_vector.md.DAXdHSjp.js +++ b/assets/ja_api_mp_math_vector.md.DiKIzhuY.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),n={name:"ja/api/mp_math/vector.md"},h=t(`

class Vector3

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

3维向量

引数:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),n={name:"ja/api/mp_math/vector.md"},h=t(`

class Vector3

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

説明: 3维向量

引数:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
ソースコード
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

引数:

  • other:

  • epsilon:

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

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

戻り値: 是否近似相等

引数:

  • other:
  • epsilon:
ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -18,7 +18,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

引数:

  • other: 另一个向量

戻り値:

  • 夹角
ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

説明: 计算两个向量之间的夹角。

戻り値: 夹角

引数:

  • other: 另一个向量
ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -26,7 +26,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

引数:

  • other:

戻り値:

  • 行列式的结果
ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

説明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

戻り値: 行列式的结果

引数:

  • other:
ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -46,7 +46,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

引数:

  • other: 另一个向量

  • epsilon: 允许的误差

戻り値:

  • 是否近似平行
ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

説明: 判断两个向量是否近似平行。

戻り値: 是否近似平行

引数:

  • other: 另一个向量
  • epsilon: 允许的误差
ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -55,7 +55,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

引数:

  • other: 另一个向量

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

説明: 判断两个向量是否平行。

戻り値: 是否平行

引数:

  • other: 另一个向量
ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

説明: 将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
     """
         将向量归一化。
 
@@ -72,32 +72,32 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

ソースコード
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

ソースコード
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

戻り値:

ソースコード
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

説明: 向量的模。

戻り値: 模

ソースコード
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

戻り値:

  • 单位向量
ソースコード
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

説明: 获取该向量的单位向量。

戻り値: 单位向量

ソースコード
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

ソースコード
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

ソースコード
python
@overload
+    return self / self.length

method __abs__(self)

ソースコード
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

引数:

  • other:
ソースコード
python
def __add__(self, other):
+    ...

method self + other

説明: V + P -> P

V + V -> V

引数:

  • other:
ソースコード
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -112,7 +112,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

引数:

  • other:

戻り値:

  • 是否相等
ソースコード
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

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

戻り値: 是否相等

引数:

  • other:
ソースコード
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -120,7 +120,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

説明: P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -128,11 +128,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

ソースコード
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

ソースコード
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

引数:

  • other:
ソースコード
python
def __sub__(self, other):
+    ...

method self - other

説明: V - P -> P

V - V -> V

引数:

  • other:
ソースコード
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

引数:

  • other:
ソースコード
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

説明: P - V -> P

引数:

  • other:
ソースコード
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -157,11 +157,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

ソースコード
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

ソースコード
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

  • other:
ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

説明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

  • other:
ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -174,14 +174,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

引数:

  • other:
ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

説明: 点乘。

引数:

  • other:
ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

ソースコード
python
def __neg__(self):
-    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • タイプ: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • タイプ: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • タイプ: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • タイプ: Vector3

  • 説明: z轴单位向量

`,133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

ソースコード
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • タイプ: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • タイプ: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • タイプ: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • タイプ: Vector3

  • 説明: z轴单位向量

`,125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_vector.md.DAXdHSjp.lean.js b/assets/ja_api_mp_math_vector.md.DiKIzhuY.lean.js similarity index 85% rename from assets/ja_api_mp_math_vector.md.DAXdHSjp.lean.js rename to assets/ja_api_mp_math_vector.md.DiKIzhuY.lean.js index f6ef7be..a9174df 100644 --- a/assets/ja_api_mp_math_vector.md.DAXdHSjp.lean.js +++ b/assets/ja_api_mp_math_vector.md.DiKIzhuY.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),n={name:"ja/api/mp_math/vector.md"},h=t("",133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),n={name:"ja/api/mp_math/vector.md"},h=t("",125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_presets_model_index.md.CleEI4sj.js b/assets/ja_api_presets_model_index.md.Be7yN1vu.js similarity index 90% rename from assets/ja_api_presets_model_index.md.CleEI4sj.js rename to assets/ja_api_presets_model_index.md.Be7yN1vu.js index 699e103..21cecbb 100644 --- a/assets/ja_api_presets_model_index.md.CleEI4sj.js +++ b/assets/ja_api_presets_model_index.md.Be7yN1vu.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),t={name:"ja/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

引数:

  • radius:

  • density:

戻り値:

  • List[Point3]: 球体上的点集。
ソースコード
python
@staticmethod
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),t={name:"ja/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

説明: 生成球体上的点集。

戻り値: List[Point3]: 球体上的点集。

引数:

  • radius:
  • density:
ソースコード
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -15,4 +15,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o
     x_array = radius * np.sin(phi_list) * np.cos(theta_list)
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_presets_model_index.md.CleEI4sj.lean.js b/assets/ja_api_presets_model_index.md.Be7yN1vu.lean.js similarity index 72% rename from assets/ja_api_presets_model_index.md.CleEI4sj.lean.js rename to assets/ja_api_presets_model_index.md.Be7yN1vu.lean.js index 9f1e55f..8f9992c 100644 --- a/assets/ja_api_presets_model_index.md.CleEI4sj.lean.js +++ b/assets/ja_api_presets_model_index.md.Be7yN1vu.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),t={name:"ja/api/presets/model/index.md"},h=n("",9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"ja/api/presets/model/index.md","filePath":"ja/api/presets/model/index.md"}'),t={name:"ja/api/presets/model/index.md"},h=n("",8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_angle.md.CMQhsVJf.js b/assets/zht_api_mp_math_angle.md._4N19GGe.js similarity index 82% rename from assets/zht_api_mp_math_angle.md.CMQhsVJf.js rename to assets/zht_api_mp_math_angle.md._4N19GGe.js index b29a4c0..7c2b91f 100644 --- a/assets/zht_api_mp_math_angle.md.CMQhsVJf.js +++ b/assets/zht_api_mp_math_angle.md._4N19GGe.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"zht/api/mp_math/angle.md","filePath":"zht/api/mp_math/angle.md"}'),t={name:"zht/api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

變數説明:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

源碼
python
def __init__(self, value: float, is_radian: bool=False):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"zht/api/mp_math/angle.md","filePath":"zht/api/mp_math/angle.md"}'),t={name:"zht/api/mp_math/angle.md"},e=n(`

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

説明: 任意角度。

變數説明:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
源碼
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -8,92 +8,92 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

返回:

  • 余角
源碼
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

説明: 余角:两角的和为90°。

返回: 余角

源碼
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

返回:

  • 补角
源碼
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

説明: 补角:两角的和为180°。

返回: 补角

源碼
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

返回:

  • 弧度
源碼
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

説明: 角度。

返回: 弧度

源碼
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

返回:

  • 最小正角度
源碼
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

説明: 最小正角。

返回: 最小正角度

源碼
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

返回:

  • 最大负角度
源碼
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

説明: 最大负角。

返回: 最大负角度

源碼
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

返回:

  • 正弦值
源碼
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

説明: 正弦值。

返回: 正弦值

源碼
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

返回:

  • 余弦值
源碼
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

説明: 余弦值。

返回: 余弦值

源碼
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

返回:

  • 正切值
源碼
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

説明: 正切值。

返回: 正切值

源碼
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

返回:

  • 余切值
源碼
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

説明: 余切值。

返回: 余切值

源碼
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

返回:

  • 正割值
源碼
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

説明: 正割值。

返回: 正割值

源碼
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

返回:

  • 余割值
源碼
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

説明: 余割值。

返回: 余割值

源碼
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源碼
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源碼
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源碼
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源碼
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源碼
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源碼
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源碼
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源碼
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源碼
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源碼
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源碼
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

源碼
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

源碼
python
def __truediv__(self, other):
+    ...

method self / other

源碼
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; + return AnyAngle(self.radian / other, is_radian=True)
`,78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/zht_api_mp_math_angle.md.CMQhsVJf.lean.js b/assets/zht_api_mp_math_angle.md._4N19GGe.lean.js similarity index 71% rename from assets/zht_api_mp_math_angle.md.CMQhsVJf.lean.js rename to assets/zht_api_mp_math_angle.md._4N19GGe.lean.js index 32e4911..d02fff3 100644 --- a/assets/zht_api_mp_math_angle.md.CMQhsVJf.lean.js +++ b/assets/zht_api_mp_math_angle.md._4N19GGe.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"zht/api/mp_math/angle.md","filePath":"zht/api/mp_math/angle.md"}'),t={name:"zht/api/mp_math/angle.md"},e=n("",89),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{F as __pageData,E as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"zht/api/mp_math/angle.md","filePath":"zht/api/mp_math/angle.md"}'),t={name:"zht/api/mp_math/angle.md"},e=n("",78),l=[e];function h(p,k,r,d,o,g){return a(),i("div",null,l)}const c=s(t,[["render",h]]);export{F as __pageData,c as default}; diff --git a/assets/zht_api_mp_math_equation.md.BwlIZxDL.js b/assets/zht_api_mp_math_equation.md.C9cWPaC8.js similarity index 83% rename from assets/zht_api_mp_math_equation.md.BwlIZxDL.js rename to assets/zht_api_mp_math_equation.md.C9cWPaC8.js index 0a0da10..72f0338 100644 --- a/assets/zht_api_mp_math_equation.md.BwlIZxDL.js +++ b/assets/zht_api_mp_math_equation.md.C9cWPaC8.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),l={name:"zht/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

變數説明:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

返回:

  • 偏导函数

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),l={name:"zht/api/mp_math/equation.md"},t=n(`

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

説明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

返回: 偏导函数

變數説明:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -28,16 +28,16 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源碼
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源碼
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源碼
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源碼
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

變數説明:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

源碼
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

説明: 曲线方程。

變數説明:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
源碼
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -47,7 +47,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

變數説明:

  • *t:

  • 参数:

源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:
源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -59,4 +59,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     if len(t) == 1:
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
-        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; + return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
`,23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/zht_api_mp_math_equation.md.BwlIZxDL.lean.js b/assets/zht_api_mp_math_equation.md.C9cWPaC8.lean.js similarity index 86% rename from assets/zht_api_mp_math_equation.md.BwlIZxDL.lean.js rename to assets/zht_api_mp_math_equation.md.C9cWPaC8.lean.js index e2e34f2..7a9c189 100644 --- a/assets/zht_api_mp_math_equation.md.BwlIZxDL.lean.js +++ b/assets/zht_api_mp_math_equation.md.C9cWPaC8.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),l={name:"zht/api/mp_math/equation.md"},t=n("",24),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation"},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),l={name:"zht/api/mp_math/equation.md"},t=n("",23),h=[t];function p(k,e,r,E,d,g){return a(),i("div",null,h)}const u=s(l,[["render",p]]);export{y as __pageData,u as default}; diff --git a/assets/zht_api_mp_math_line.md.Czel-DYb.js b/assets/zht_api_mp_math_line.md.CG1Yioz9.js similarity index 72% rename from assets/zht_api_mp_math_line.md.Czel-DYb.js rename to assets/zht_api_mp_math_line.md.CG1Yioz9.js index db37b00..32405ce 100644 --- a/assets/zht_api_mp_math_line.md.Czel-DYb.js +++ b/assets/zht_api_mp_math_line.md.CG1Yioz9.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),l={name:"zht/api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

變數説明:

  • point: 直线上的一点

  • direction: 直线的方向向量

源碼
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),l={name:"zht/api/mp_math/line.md"},t=n(`

class Line3

method __init__(self, point: Point3, direction: Vector3)

説明: 三维空间中的直线。由一个点和一个方向向量确定。

變數説明:

  • point: 直线上的一点
  • direction: 直线的方向向量
源碼
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -6,7 +6,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

變數説明:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

説明: 判断两条直线是否近似相等。

返回: 是否近似相等

變數説明:

  • other: 另一条直线
  • epsilon: 误差
源碼
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -15,7 +15,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

變數説明:

  • other: 另一条直线

返回:

  • 夹角弧度

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

説明: 计算直线和直线之间的夹角。

返回: 夹角弧度

變數説明:

  • other: 另一条直线

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -25,7 +25,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

變數説明:

  • other: 平行直线或点

返回:

  • 距离

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

説明: 计算直线和直线或点之间的距离。

返回: 距离

變數説明:

  • other: 平行直线或点

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -48,7 +48,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

變數説明:

  • other: 另一条直线

返回:

  • 交点

抛出:

  • ValueError 直线平行

  • ValueError 直线不共面

源碼
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

説明: 计算两条直线的交点。

返回: 交点

變數説明:

  • other: 另一条直线

抛出:

  • ValueError 直线平行
  • ValueError 直线不共面
源碼
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

變數説明:

  • point: 指定点

返回:

  • 垂线
源碼
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

説明: 计算直线经过指定点p的垂线。

返回: 垂线

變數説明:

  • point: 指定点
源碼
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -71,7 +71,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

變數説明:

  • t: 参数t

返回:

源碼
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

説明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

返回: 点

變數説明:

  • t: 参数t
源碼
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -79,13 +79,13 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

返回:

  • x(t), y(t), z(t)
源碼
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

説明: 获取直线的参数方程。

返回: x(t), y(t), z(t)

源碼
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

變數説明:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似平行
源碼
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

説明: 判断两条直线是否近似平行。

返回: 是否近似平行

變數説明:

  • other: 另一条直线
  • epsilon: 误差
源碼
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -94,7 +94,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

變數説明:

  • other: 另一条直线

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

説明: 判断两条直线是否平行。

返回: 是否平行

變數説明:

  • other: 另一条直线
源碼
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -102,7 +102,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

變數説明:

  • other: 另一条直线

返回:

  • 是否共线
源碼
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

説明: 判断两条直线是否共线。

返回: 是否共线

變數説明:

  • other: 另一条直线
源碼
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -110,7 +110,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

變數説明:

  • point: 点

返回:

  • 是否在直线上
源碼
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

説明: 判断点是否在直线上。

返回: 是否在直线上

變數説明:

  • point: 点
源碼
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -118,7 +118,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

變數説明:

  • other: 另一条直线

返回:

  • 是否共面
源碼
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

説明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

返回: 是否共面

變數説明:

  • other: 另一条直线
源碼
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -127,7 +127,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源碼
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

説明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源碼
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -140,7 +140,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

變數説明:

  • p1: 点1

  • p2: 点2

返回:

  • 直线
源碼
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

説明: 工厂函数 由两点构造直线。

返回: 直线

變數説明:

  • p1: 点1
  • p2: 点2
源碼
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -151,7 +151,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

變數説明:

  • other: 另一条直线

返回:

  • 交点
源碼
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

説明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

返回: 交点

變數説明:

  • other: 另一条直线
源碼
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -164,7 +164,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

變數説明:

  • other:
源碼
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

説明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

變數説明:

  • other:
源碼
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -175,4 +175,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_line.md.Czel-DYb.lean.js b/assets/zht_api_mp_math_line.md.CG1Yioz9.lean.js similarity index 85% rename from assets/zht_api_mp_math_line.md.Czel-DYb.lean.js rename to assets/zht_api_mp_math_line.md.CG1Yioz9.lean.js index 1502b9d..8d2d9e6 100644 --- a/assets/zht_api_mp_math_line.md.Czel-DYb.lean.js +++ b/assets/zht_api_mp_math_line.md.CG1Yioz9.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),l={name:"zht/api/mp_math/line.md"},t=n("",119),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line"},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),l={name:"zht/api/mp_math/line.md"},t=n("",105),h=[t];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_plane.md.CxUaQCvU.js b/assets/zht_api_mp_math_plane.md.jJjMMFlO.js similarity index 83% rename from assets/zht_api_mp_math_plane.md.CxUaQCvU.js rename to assets/zht_api_mp_math_plane.md.jJjMMFlO.js index f626c3f..4e555ae 100644 --- a/assets/zht_api_mp_math_plane.md.CxUaQCvU.js +++ b/assets/zht_api_mp_math_plane.md.jJjMMFlO.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"zht/api/mp_math/plane.md","filePath":"zht/api/mp_math/plane.md"}'),l={name:"zht/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

變數説明:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

源碼
python
def __init__(self, a: float, b: float, c: float, d: float):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"zht/api/mp_math/plane.md","filePath":"zht/api/mp_math/plane.md"}'),l={name:"zht/api/mp_math/plane.md"},h=n(`

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

説明: 平面方程:ax + by + cz + d = 0

變數説明:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
源碼
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -10,7 +10,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

變數説明:

  • other: 另一个平面

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

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

返回: 是否近似相等

變數説明:

  • other: 另一个平面
源碼
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -28,7 +28,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

變數説明:

  • other: 另一个平面

返回:

  • 夹角弧度

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

説明: 计算平面与平面之间的夹角。

返回: 夹角弧度

變數説明:

  • other: 另一个平面

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -43,7 +43,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

變數説明:

  • other: 另一个平面或点

返回:

  • 距离

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

説明: 计算平面与平面或点之间的距离。

返回: 距离

變數説明:

  • other: 另一个平面或点

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -58,7 +58,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

變數説明:

  • other: 另一个平面

返回:

  • 两平面的交线
源碼
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

説明: 计算两平面的交线。

返回: 两平面的交线

變數説明:

  • other: 另一个平面
源碼
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -83,7 +83,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

變數説明:

  • other: 不与平面平行或在平面上的直线

返回:

  • 交点

抛出:

  • ValueError 平面与直线平行或重合
源碼
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

説明: 计算平面与直线的交点。

返回: 交点

變數説明:

  • other: 不与平面平行或在平面上的直线

抛出:

  • ValueError 平面与直线平行或重合
源碼
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -97,7 +97,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

變數説明:

  • point: 指定点

返回:

  • 所求平面
源碼
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

説明: 计算平行于该平面且过指定点的平面。

返回: 所求平面

變數説明:

  • point: 指定点
源碼
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -105,7 +105,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

變數説明:

  • other: 另一个平面

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

説明: 判断两个平面是否平行。

返回: 是否平行

變數説明:

  • other: 另一个平面
源碼
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -113,14 +113,14 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

返回:

  • 法向量
源碼
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

説明: 平面的法向量。

返回: 法向量

源碼
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

變數説明:

  • point: 平面上的一点

  • normal: 法向量

返回:

  • 平面
源碼
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

説明: 工厂函数 由点和法向量构造平面(点法式构造)。

返回: 平面

變數説明:

  • point: 平面上的一点
  • normal: 法向量
源碼
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -132,7 +132,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

變數説明:

  • p1: 点1

  • p2: 点2

  • p3: 点3

返回:

  • 平面
源碼
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

説明: 工厂函数 由三点构造平面。

返回: 平面

變數説明:

  • p1: 点1
  • p2: 点2
  • p3: 点3
源碼
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

變數説明:

  • l1: 直线1

  • l2: 直线2

返回:

  • 平面
源碼
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

説明: 工厂函数 由两直线构造平面。

返回: 平面

變數説明:

  • l1: 直线1
  • l2: 直线2
源碼
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -160,7 +160,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

變數説明:

  • point: 面上一点

  • line: 面上直线,不包含点

返回:

  • 平面
源碼
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

説明: 工厂函数 由点和直线构造平面。

返回: 平面

變數説明:

  • point: 面上一点
  • line: 面上直线,不包含点
源碼
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -170,11 +170,11 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源碼
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源碼
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源碼
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源碼
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

變數説明:

  • other:

返回:

  • 不平行平面的交线,平面平行返回None
源碼
python
def __and__(self, other):
+    ...

method __and__(self, other)

説明: 取两平面的交集(人话:交线)

返回: 不平行平面的交线,平面平行返回None

變數説明:

  • other:
源碼
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -191,6 +191,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源碼
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源碼
python
def __rand__(self, other: 'Line3') -> 'Point3':
-    return self.cal_intersection_point3(other)
`,116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; + raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源碼
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源碼
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_plane.md.CxUaQCvU.lean.js b/assets/zht_api_mp_math_plane.md.jJjMMFlO.lean.js similarity index 85% rename from assets/zht_api_mp_math_plane.md.CxUaQCvU.lean.js rename to assets/zht_api_mp_math_plane.md.jJjMMFlO.lean.js index 8482a1d..9765112 100644 --- a/assets/zht_api_mp_math_plane.md.CxUaQCvU.lean.js +++ b/assets/zht_api_mp_math_plane.md.jJjMMFlO.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"zht/api/mp_math/plane.md","filePath":"zht/api/mp_math/plane.md"}'),l={name:"zht/api/mp_math/plane.md"},h=n("",116),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane"},"headers":[],"relativePath":"zht/api/mp_math/plane.md","filePath":"zht/api/mp_math/plane.md"}'),l={name:"zht/api/mp_math/plane.md"},h=n("",103),t=[h];function p(k,e,r,d,E,o){return a(),i("div",null,t)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_point.md.BmRy6Xj6.js b/assets/zht_api_mp_math_point.md.CRxiJq-m.js similarity index 74% rename from assets/zht_api_mp_math_point.md.BmRy6Xj6.js rename to assets/zht_api_mp_math_point.md.CRxiJq-m.js index 09fd819..a5044ce 100644 --- a/assets/zht_api_mp_math_point.md.BmRy6Xj6.js +++ b/assets/zht_api_mp_math_point.md.CRxiJq-m.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"zht/api/mp_math/point.md","filePath":"zht/api/mp_math/point.md"}'),n={name:"zht/api/mp_math/point.md"},h=t(`

class Point3

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

笛卡尔坐标系中的点。

變數説明:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

源碼
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"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(`

class Point3

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

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

變數説明:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
源碼
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

變數説明:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

返回: 是否近似相等

變數説明:

  • other:
  • epsilon:
源碼
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -18,11 +18,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源碼
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

變數説明:

  • other:
源碼
python
def __add__(self, other):
+    ...

method self + other

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

變數説明:

  • other:
源碼
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -30,14 +30,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

變數説明:

  • other:
源碼
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

變數説明:

  • other:
源碼
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

變數説明:

  • other:
源碼
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

説明: P - P -> V

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

變數説明:

  • other:
源碼
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -48,4 +48,4 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_point.md.BmRy6Xj6.lean.js b/assets/zht_api_mp_math_point.md.CRxiJq-m.lean.js similarity index 71% rename from assets/zht_api_mp_math_point.md.BmRy6Xj6.lean.js rename to assets/zht_api_mp_math_point.md.CRxiJq-m.lean.js index 71132cb..606cff7 100644 --- a/assets/zht_api_mp_math_point.md.BmRy6Xj6.lean.js +++ b/assets/zht_api_mp_math_point.md.CRxiJq-m.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"headers":[],"relativePath":"zht/api/mp_math/point.md","filePath":"zht/api/mp_math/point.md"}'),n={name:"zht/api/mp_math/point.md"},h=t("",35),l=[h];function e(p,k,o,r,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point"},"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("",34),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_segment.md.Bn34DhAl.js b/assets/zht_api_mp_math_segment.md.U_lS4vUA.js similarity index 83% rename from assets/zht_api_mp_math_segment.md.Bn34DhAl.js rename to assets/zht_api_mp_math_segment.md.U_lS4vUA.js index d30797a..4e078d7 100644 --- a/assets/zht_api_mp_math_segment.md.Bn34DhAl.js +++ b/assets/zht_api_mp_math_segment.md.U_lS4vUA.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"zht/api/mp_math/segment.md","filePath":"zht/api/mp_math/segment.md"}'),t={name:"zht/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

源碼
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"zht/api/mp_math/segment.md","filePath":"zht/api/mp_math/segment.md"}'),t={name:"zht/api/mp_math/segment.md"},h=n(`

class Segment3

method __init__(self, p1: Point3, p2: Point3)

説明: 三维空间中的线段。 :param p1: :param p2:

源碼
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -11,4 +11,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y
     '长度'
     self.length = self.direction.length
     '中心点'
-    self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; + self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
`,4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_segment.md.Bn34DhAl.lean.js b/assets/zht_api_mp_math_segment.md.U_lS4vUA.lean.js similarity index 58% rename from assets/zht_api_mp_math_segment.md.Bn34DhAl.lean.js rename to assets/zht_api_mp_math_segment.md.U_lS4vUA.lean.js index 7b7a204..8f983aa 100644 --- a/assets/zht_api_mp_math_segment.md.Bn34DhAl.lean.js +++ b/assets/zht_api_mp_math_segment.md.U_lS4vUA.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"zht/api/mp_math/segment.md","filePath":"zht/api/mp_math/segment.md"}'),t={name:"zht/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,d,r,E,g){return a(),i("div",null,p)}const o=s(t,[["render",l]]);export{y as __pageData,o as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment"},"headers":[],"relativePath":"zht/api/mp_math/segment.md","filePath":"zht/api/mp_math/segment.md"}'),t={name:"zht/api/mp_math/segment.md"},h=n("",4),p=[h];function l(k,e,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_utils.md.BtiDgiKf.js b/assets/zht_api_mp_math_utils.md.wrAVKQq5.js similarity index 77% rename from assets/zht_api_mp_math_utils.md.BtiDgiKf.js rename to assets/zht_api_mp_math_utils.md.wrAVKQq5.js index 6ee4438..1cd5d1b 100644 --- a/assets/zht_api_mp_math_utils.md.BtiDgiKf.js +++ b/assets/zht_api_mp_math_utils.md.wrAVKQq5.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),l={name:"zht/api/mp_math/utils.md"},t=n(`

func clamp() -> float

区间限定函数

變數説明:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

返回:

  • 限制后的值
源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),l={name:"zht/api/mp_math/utils.md"},t=n(`

func clamp() -> float

説明: 区间限定函数

返回: 限制后的值

變數説明:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,7 +9,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

變數説明:

  • x: 数1

  • y: 数2

  • epsilon: 误差

返回:

  • 是否近似相等
源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

説明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

返回: 是否近似相等

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差
源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -19,7 +19,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

變數説明:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源碼
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

説明: 获取数的符号。

返回: 符号 + - ""

變數説明:

  • x: 数
  • only_neg: 是否只返回负数的符号
源碼
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -32,7 +32,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

變數説明:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

説明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

返回: 符号 + - ""

變數説明:

  • x: 数
  • only_neg: 是否只返回负数的符号
源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -48,8 +48,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

源碼
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

源碼
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

源碼
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

源碼
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -59,6 +59,6 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

源碼
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源碼
python
def __ne__(self, other):
-    return not self.__eq__(other)
`,37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; + self.raise_type_error(other)

method raise_type_error(self, other)

源碼
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源碼
python
def __ne__(self, other):
+    return not self.__eq__(other)
`,33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_utils.md.BtiDgiKf.lean.js b/assets/zht_api_mp_math_utils.md.wrAVKQq5.lean.js similarity index 85% rename from assets/zht_api_mp_math_utils.md.BtiDgiKf.lean.js rename to assets/zht_api_mp_math_utils.md.wrAVKQq5.lean.js index c055d01..32646d9 100644 --- a/assets/zht_api_mp_math_utils.md.BtiDgiKf.lean.js +++ b/assets/zht_api_mp_math_utils.md.wrAVKQq5.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),l={name:"zht/api/mp_math/utils.md"},t=n("",37),h=[t];function p(k,e,r,d,g,F){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils"},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),l={name:"zht/api/mp_math/utils.md"},t=n("",33),h=[t];function p(k,e,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_vector.md.DmxfMXiN.js b/assets/zht_api_mp_math_vector.md.B2jIk2y0.js similarity index 81% rename from assets/zht_api_mp_math_vector.md.DmxfMXiN.js rename to assets/zht_api_mp_math_vector.md.B2jIk2y0.js index f0bba58..db64f2e 100644 --- a/assets/zht_api_mp_math_vector.md.DmxfMXiN.js +++ b/assets/zht_api_mp_math_vector.md.B2jIk2y0.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),n={name:"zht/api/mp_math/vector.md"},h=t(`

class Vector3

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

3维向量

變數説明:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

源碼
python
def __init__(self, x: float, y: float, z: float):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),n={name:"zht/api/mp_math/vector.md"},h=t(`

class Vector3

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

説明: 3维向量

變數説明:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
源碼
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

變數説明:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

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

返回: 是否近似相等

變數説明:

  • other:
  • epsilon:
源碼
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -18,7 +18,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

變數説明:

  • other: 另一个向量

返回:

  • 夹角
源碼
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

説明: 计算两个向量之间的夹角。

返回: 夹角

變數説明:

  • other: 另一个向量
源碼
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -26,7 +26,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

變數説明:

  • other:

返回:

  • 行列式的结果
源碼
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

説明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

返回: 行列式的结果

變數説明:

  • other:
源碼
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -46,7 +46,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

變數説明:

  • other: 另一个向量

  • epsilon: 允许的误差

返回:

  • 是否近似平行
源碼
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

説明: 判断两个向量是否近似平行。

返回: 是否近似平行

變數説明:

  • other: 另一个向量
  • epsilon: 允许的误差
源碼
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -55,7 +55,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

變數説明:

  • other: 另一个向量

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

説明: 判断两个向量是否平行。

返回: 是否平行

變數説明:

  • other: 另一个向量
源碼
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -63,7 +63,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

源碼
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

説明: 将向量归一化。

自体归一化,不返回值。

源碼
python
def normalize(self):
     """
         将向量归一化。
 
@@ -72,32 +72,32 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

源碼
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

源碼
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

返回:

源碼
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

説明: 向量的模。

返回: 模

源碼
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

返回:

  • 单位向量
源碼
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

説明: 获取该向量的单位向量。

返回: 单位向量

源碼
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

源碼
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

源碼
python
@overload
+    return self / self.length

method __abs__(self)

源碼
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

源碼
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

變數説明:

  • other:
源碼
python
def __add__(self, other):
+    ...

method self + other

説明: V + P -> P

V + V -> V

變數説明:

  • other:
源碼
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -112,7 +112,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

變數説明:

  • other:

返回:

  • 是否相等
源碼
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

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

返回: 是否相等

變數説明:

  • other:
源碼
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -120,7 +120,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

源碼
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

説明: P + V -> P

别去点那边实现了。 :param other: :return:

源碼
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -128,11 +128,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源碼
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源碼
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

源碼
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

變數説明:

  • other:
源碼
python
def __sub__(self, other):
+    ...

method self - other

説明: V - P -> P

V - V -> V

變數説明:

  • other:
源碼
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -146,7 +146,7 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

變數説明:

  • other:
源碼
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

説明: P - V -> P

變數説明:

  • other:
源碼
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -157,11 +157,11 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源碼
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源碼
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

變數説明:

  • other:
源碼
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

説明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

變數説明:

  • other:
源碼
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -174,14 +174,14 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源碼
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

變數説明:

  • other:
源碼
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源碼
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

説明: 点乘。

變數説明:

  • other:
源碼
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源碼
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源碼
python
def __neg__(self):
-    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 類型: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 類型: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 類型: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 類型: Vector3

  • 説明: z轴单位向量

`,133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; + return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源碼
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源碼
python
def __neg__(self):
+    return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 類型: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 類型: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 類型: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 類型: Vector3

  • 説明: z轴单位向量

`,125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_vector.md.DmxfMXiN.lean.js b/assets/zht_api_mp_math_vector.md.B2jIk2y0.lean.js similarity index 85% rename from assets/zht_api_mp_math_vector.md.DmxfMXiN.lean.js rename to assets/zht_api_mp_math_vector.md.B2jIk2y0.lean.js index 5bbc640..38a3194 100644 --- a/assets/zht_api_mp_math_vector.md.DmxfMXiN.lean.js +++ b/assets/zht_api_mp_math_vector.md.B2jIk2y0.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),n={name:"zht/api/mp_math/vector.md"},h=t("",133),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.BV61Qrc0.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector"},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),n={name:"zht/api/mp_math/vector.md"},h=t("",125),l=[h];function e(p,k,r,o,d,E){return a(),i("div",null,l)}const F=s(n,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_presets_model_index.md.DDom2SLG.js b/assets/zht_api_presets_model_index.md.CPzp1vmU.js similarity index 90% rename from assets/zht_api_presets_model_index.md.DDom2SLG.js rename to assets/zht_api_presets_model_index.md.CPzp1vmU.js index b44f611..bbf87b3 100644 --- a/assets/zht_api_presets_model_index.md.DDom2SLG.js +++ b/assets/zht_api_presets_model_index.md.CPzp1vmU.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),t={name:"zht/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

變數説明:

  • radius:

  • density:

返回:

  • List[Point3]: 球体上的点集。
源碼
python
@staticmethod
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),t={name:"zht/api/presets/model/index.md"},h=n(`

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

説明: 生成球体上的点集。

返回: List[Point3]: 球体上的点集。

變數説明:

  • radius:
  • density:
源碼
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -15,4 +15,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o
     x_array = radius * np.sin(phi_list) * np.cos(theta_list)
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
-    return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/assets/zht_api_presets_model_index.md.DDom2SLG.lean.js b/assets/zht_api_presets_model_index.md.CPzp1vmU.lean.js similarity index 72% rename from assets/zht_api_presets_model_index.md.DDom2SLG.lean.js rename to assets/zht_api_presets_model_index.md.CPzp1vmU.lean.js index 2fc38dc..8e76554 100644 --- a/assets/zht_api_presets_model_index.md.DDom2SLG.lean.js +++ b/assets/zht_api_presets_model_index.md.CPzp1vmU.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),t={name:"zht/api/presets/model/index.md"},h=n("",9),l=[h];function p(k,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model"},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),t={name:"zht/api/presets/model/index.md"},h=n("",8),l=[h];function k(p,e,r,d,E,y){return a(),i("div",null,l)}const F=s(t,[["render",k]]);export{o as __pageData,F as default}; diff --git a/en/api/index.html b/en/api/index.html index d2c8ab1..b12632d 100644 --- a/en/api/index.html +++ b/en/api/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/en/api/mp_math/angle.html b/en/api/mp_math/angle.html index 5a259b8..821ef28 100644 --- a/en/api/mp_math/angle.html +++ b/en/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

Arguments:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

Source code
python
def __init__(self, value: float, is_radian: bool=False):
+    
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

Description: 任意角度。

Arguments:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
Source code
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -27,96 +27,96 @@
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

Return:

  • 余角
Source code
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

Description: 余角:两角的和为90°。

Return: 余角

Source code
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

Return:

  • 补角
Source code
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

Description: 补角:两角的和为180°。

Return: 补角

Source code
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

Return:

  • 弧度
Source code
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

Description: 角度。

Return: 弧度

Source code
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

Return:

  • 最小正角度
Source code
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

Description: 最小正角。

Return: 最小正角度

Source code
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

Return:

  • 最大负角度
Source code
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

Description: 最大负角。

Return: 最大负角度

Source code
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

Return:

  • 正弦值
Source code
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

Description: 正弦值。

Return: 正弦值

Source code
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

Return:

  • 余弦值
Source code
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

Return:

  • 正切值
Source code
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

Description: 正切值。

Return: 正切值

Source code
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

Return:

  • 余切值
Source code
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

Description: 余切值。

Return: 余切值

Source code
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

Return:

  • 正割值
Source code
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

Description: 正割值。

Return: 正割值

Source code
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

Return:

  • 余割值
Source code
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

Description: 余割值。

Return: 余割值

Source code
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

Source code
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

Source code
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

Source code
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

Source code
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

Source code
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

Source code
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

Source code
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

Source code
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

Source code
python
def __truediv__(self, other):
+    ...

method self / other

Source code
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)
- + \ No newline at end of file diff --git a/en/api/mp_math/const.html b/en/api/mp_math/const.html index 3bb0d7b..3f5fba2 100644 --- a/en/api/mp_math/const.html +++ b/en/api/mp_math/const.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/en/api/mp_math/equation.html b/en/api/mp_math/equation.html index 2b78516..51aa6bf 100644 --- a/en/api/mp_math/equation.html +++ b/en/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Arguments:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

Return:

  • 偏导函数

Raises:

  • ValueError 无效变量类型
Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

Description: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

Return: 偏导函数

Arguments:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

Raises:

  • ValueError 无效变量类型
Source code
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -47,16 +47,16 @@
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

Source code
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

Source code
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

Source code
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

Arguments:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

Description: 曲线方程。

Arguments:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
Source code
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -66,7 +66,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

Arguments:

  • *t:

  • 参数:

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:
Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -79,7 +79,7 @@
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
         return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
- + \ No newline at end of file diff --git a/en/api/mp_math/index.html b/en/api/mp_math/index.html index b544708..78ab216 100644 --- a/en/api/mp_math/index.html +++ b/en/api/mp_math/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/en/api/mp_math/line.html b/en/api/mp_math/line.html index 106c9ea..580c008 100644 --- a/en/api/mp_math/line.html +++ b/en/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

Arguments:

  • point: 直线上的一点

  • direction: 直线的方向向量

Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

Description: 三维空间中的直线。由一个点和一个方向向量确定。

Arguments:

  • point: 直线上的一点
  • direction: 直线的方向向量
Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -25,7 +25,7 @@
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

Arguments:

  • other: 另一条直线

  • epsilon: 误差

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

Description: 判断两条直线是否近似相等。

Return: 是否近似相等

Arguments:

  • other: 另一条直线
  • epsilon: 误差
Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -34,7 +34,7 @@
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

Arguments:

  • other: 另一条直线

Return:

  • 夹角弧度

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

Description: 计算直线和直线之间的夹角。

Return: 夹角弧度

Arguments:

  • other: 另一条直线

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -44,7 +44,7 @@
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

Arguments:

  • other: 平行直线或点

Return:

  • 距离

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

Description: 计算直线和直线或点之间的距离。

Return: 距离

Arguments:

  • other: 平行直线或点

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -67,7 +67,7 @@
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return:

  • 交点

Raises:

  • ValueError 直线平行

  • ValueError 直线不共面

Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

Description: 计算两条直线的交点。

Return: 交点

Arguments:

  • other: 另一条直线

Raises:

  • ValueError 直线平行
  • ValueError 直线不共面
Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -82,7 +82,7 @@
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

Arguments:

  • point: 指定点

Return:

  • 垂线
Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

Description: 计算直线经过指定点p的垂线。

Return: 垂线

Arguments:

  • point: 指定点
Source code
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -90,7 +90,7 @@
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Arguments:

  • t: 参数t

Return:

Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

Description: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

Return: 点

Arguments:

  • t: 参数t
Source code
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -98,13 +98,13 @@
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

Return:

  • x(t), y(t), z(t)
Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

Description: 获取直线的参数方程。

Return: x(t), y(t), z(t)

Source code
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

Arguments:

  • other: 另一条直线

  • epsilon: 误差

Return:

  • 是否近似平行
Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

Description: 判断两条直线是否近似平行。

Return: 是否近似平行

Arguments:

  • other: 另一条直线
  • epsilon: 误差
Source code
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -113,7 +113,7 @@
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

Arguments:

  • other: 另一条直线

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

Description: 判断两条直线是否平行。

Return: 是否平行

Arguments:

  • other: 另一条直线
Source code
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -121,7 +121,7 @@
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return:

  • 是否共线
Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

Description: 判断两条直线是否共线。

Return: 是否共线

Arguments:

  • other: 另一条直线
Source code
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -129,7 +129,7 @@
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

Arguments:

  • point: 点

Return:

  • 是否在直线上
Source code
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

Description: 判断点是否在直线上。

Return: 是否在直线上

Arguments:

  • point: 点
Source code
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -137,7 +137,7 @@
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Arguments:

  • other: 另一条直线

Return:

  • 是否共面
Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

Description: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

Return: 是否共面

Arguments:

  • other: 另一条直线
Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -146,7 +146,7 @@
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

Description: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

Source code
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -159,7 +159,7 @@
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

Arguments:

  • p1: 点1

  • p2: 点2

Return:

  • 直线
Source code
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

Description: 工厂函数 由两点构造直线。

Return: 直线

Arguments:

  • p1: 点1
  • p2: 点2
Source code
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -170,7 +170,7 @@
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Arguments:

  • other: 另一条直线

Return:

  • 交点
Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

Description: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

Return: 交点

Arguments:

  • other: 另一条直线
Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -183,7 +183,7 @@
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

Description: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -195,7 +195,7 @@
 
         """
     return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
- + \ No newline at end of file diff --git a/en/api/mp_math/mp_math_typing.html b/en/api/mp_math/mp_math_typing.html index 2cc94d0..0410dfd 100644 --- a/en/api/mp_math/mp_math_typing.html +++ b/en/api/mp_math/mp_math_typing.html @@ -18,7 +18,7 @@
Skip to content

var RealNumber = int | float

  • Type: TypeAlias

var Number = RealNumber | complex

  • Type: TypeAlias

var Var = SingleVar | ArrayVar

  • Type: TypeAlias

var OneSingleVarFunc = Callable[[SingleVar], SingleVar]

  • Type: TypeAlias

var OneArrayFunc = Callable[[ArrayVar], ArrayVar]

  • Type: TypeAlias

var OneVarFunc = OneSingleVarFunc | OneArrayFunc

  • Type: TypeAlias

var TwoSingleVarsFunc = Callable[[SingleVar, SingleVar], SingleVar]

  • Type: TypeAlias

var TwoArraysFunc = Callable[[ArrayVar, ArrayVar], ArrayVar]

  • Type: TypeAlias

var TwoVarsFunc = TwoSingleVarsFunc | TwoArraysFunc

  • Type: TypeAlias

var ThreeSingleVarsFunc = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

  • Type: TypeAlias

var ThreeArraysFunc = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

  • Type: TypeAlias

var ThreeVarsFunc = ThreeSingleVarsFunc | ThreeArraysFunc

  • Type: TypeAlias

var MultiSingleVarsFunc = Callable[..., SingleVar]

  • Type: TypeAlias

var MultiArraysFunc = Callable[..., ArrayVar]

  • Type: TypeAlias

var MultiVarsFunc = MultiSingleVarsFunc | MultiArraysFunc

  • Type: TypeAlias
- + \ No newline at end of file diff --git a/en/api/mp_math/plane.html b/en/api/mp_math/plane.html index 1f363da..0d23a51 100644 --- a/en/api/mp_math/plane.html +++ b/en/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

Arguments:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
+    
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

Description: 平面方程:ax + by + cz + d = 0

Arguments:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
Source code
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -29,7 +29,7 @@
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

Arguments:

  • other: 另一个平面

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

Description: 判断两个平面是否近似相等。

Return: 是否近似相等

Arguments:

  • other: 另一个平面
Source code
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -47,7 +47,7 @@
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

Arguments:

  • other: 另一个平面

Return:

  • 夹角弧度

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

Description: 计算平面与平面之间的夹角。

Return: 夹角弧度

Arguments:

  • other: 另一个平面

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -62,7 +62,7 @@
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

Arguments:

  • other: 另一个平面或点

Return:

  • 距离

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

Description: 计算平面与平面或点之间的距离。

Return: 距离

Arguments:

  • other: 另一个平面或点

Raises:

  • TypeError 不支持的类型
Source code
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -77,7 +77,7 @@
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

Arguments:

  • other: 另一个平面

Return:

  • 两平面的交线
Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

Description: 计算两平面的交线。

Return: 两平面的交线

Arguments:

  • other: 另一个平面
Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -102,7 +102,7 @@
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

Arguments:

  • other: 不与平面平行或在平面上的直线

Return:

  • 交点

Raises:

  • ValueError 平面与直线平行或重合
Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

Description: 计算平面与直线的交点。

Return: 交点

Arguments:

  • other: 不与平面平行或在平面上的直线

Raises:

  • ValueError 平面与直线平行或重合
Source code
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -116,7 +116,7 @@
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

Arguments:

  • point: 指定点

Return:

  • 所求平面
Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

Description: 计算平行于该平面且过指定点的平面。

Return: 所求平面

Arguments:

  • point: 指定点
Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -124,7 +124,7 @@
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

Description: 判断两个平面是否平行。

Return: 是否平行

Arguments:

  • other: 另一个平面
Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -132,14 +132,14 @@
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

Return:

  • 法向量
Source code
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

Description: 平面的法向量。

Return: 法向量

Source code
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

Arguments:

  • point: 平面上的一点

  • normal: 法向量

Return:

  • 平面
Source code
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

Description: 工厂函数 由点和法向量构造平面(点法式构造)。

Return: 平面

Arguments:

  • point: 平面上的一点
  • normal: 法向量
Source code
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -151,7 +151,7 @@
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

Arguments:

  • p1: 点1

  • p2: 点2

  • p3: 点3

Return:

  • 平面
Source code
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

Description: 工厂函数 由三点构造平面。

Return: 平面

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3
Source code
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -165,7 +165,7 @@
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

Arguments:

  • l1: 直线1

  • l2: 直线2

Return:

  • 平面
Source code
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

Description: 工厂函数 由两直线构造平面。

Return: 平面

Arguments:

  • l1: 直线1
  • l2: 直线2
Source code
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -179,7 +179,7 @@
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

Arguments:

  • point: 面上一点

  • line: 面上直线,不包含点

Return:

  • 平面
Source code
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

Description: 工厂函数 由点和直线构造平面。

Return: 平面

Arguments:

  • point: 面上一点
  • line: 面上直线,不包含点
Source code
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -189,11 +189,11 @@
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

Source code
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

Source code
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

Source code
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

Source code
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

Arguments:

  • other:

Return:

  • 不平行平面的交线,平面平行返回None
Source code
python
def __and__(self, other):
+    ...

method __and__(self, other)

Description: 取两平面的交集(人话:交线)

Return: 不平行平面的交线,平面平行返回None

Arguments:

  • other:
Source code
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -210,10 +210,10 @@
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)
- + \ No newline at end of file diff --git a/en/api/mp_math/point.html b/en/api/mp_math/point.html index 91314cb..d04df87 100644 --- a/en/api/mp_math/point.html +++ b/en/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Point3

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

笛卡尔坐标系中的点。

Arguments:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

Source code
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Point3

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

Description: 笛卡尔坐标系中的点。

Arguments:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
Source code
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

Arguments:

  • other:

  • epsilon:

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Return: 是否近似相等

Arguments:

  • other:
  • epsilon:
Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -37,11 +37,11 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

Source code
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

method self + other

Description: P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -49,14 +49,14 @@
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

Arguments:

  • other:
Source code
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

Description: 判断两个点是否相等。

Arguments:

  • other:
Source code
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

Arguments:

  • other:
Source code
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

Description: P - P -> V

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

Arguments:

  • other:
Source code
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -68,7 +68,7 @@
         """
     from .vector import Vector3
     return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
- + \ No newline at end of file diff --git a/en/api/mp_math/segment.html b/en/api/mp_math/segment.html index f46d684..e2290d2 100644 --- a/en/api/mp_math/segment.html +++ b/en/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

Description: 三维空间中的线段。 :param p1: :param p2:

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -31,7 +31,7 @@
     self.length = self.direction.length
     '中心点'
     self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
- + \ No newline at end of file diff --git a/en/api/mp_math/utils.html b/en/api/mp_math/utils.html index d206132..050a02a 100644 --- a/en/api/mp_math/utils.html +++ b/en/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

func clamp() -> float

区间限定函数

Arguments:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

Return:

  • 限制后的值
Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

func clamp() -> float

Description: 区间限定函数

Return: 限制后的值

Arguments:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,7 +28,7 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Arguments:

  • x: 数1

  • y: 数2

  • epsilon: 误差

Return:

  • 是否近似相等
Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

Description: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

Return: 是否近似相等

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差
Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -38,7 +38,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

Arguments:

  • x: 数

  • only_neg: 是否只返回负数的符号

Return:

  • 符号 + - ""
Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

Description: 获取数的符号。

Return: 符号 + - ""

Arguments:

  • x: 数
  • only_neg: 是否只返回负数的符号
Source code
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -51,7 +51,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Arguments:

  • x: 数

  • only_neg: 是否只返回负数的符号

Return:

  • 符号 + - ""
Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

Description: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

Return: 符号 + - ""

Arguments:

  • x: 数
  • only_neg: 是否只返回负数的符号
Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -67,8 +67,8 @@
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

Source code
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

Source code
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -78,10 +78,10 @@
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

Source code
python
def __ne__(self, other):
+            self.raise_type_error(other)

method raise_type_error(self, other)

Source code
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

Source code
python
def __ne__(self, other):
     return not self.__eq__(other)
- + \ No newline at end of file diff --git a/en/api/mp_math/vector.html b/en/api/mp_math/vector.html index 2bd78d6..d97d0bb 100644 --- a/en/api/mp_math/vector.html +++ b/en/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Vector3

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

3维向量

Arguments:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

Source code
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Vector3

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

Description: 3维向量

Arguments:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
Source code
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

Arguments:

  • other:

  • epsilon:

Return:

  • 是否近似相等
Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

Description: 判断两个向量是否近似相等。

Return: 是否近似相等

Arguments:

  • other:
  • epsilon:
Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -37,7 +37,7 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

Arguments:

  • other: 另一个向量

Return:

  • 夹角
Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

Description: 计算两个向量之间的夹角。

Return: 夹角

Arguments:

  • other: 另一个向量
Source code
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -45,7 +45,7 @@
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Arguments:

  • other:

Return:

  • 行列式的结果
Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

Description: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

Return: 行列式的结果

Arguments:

  • other:
Source code
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -65,7 +65,7 @@
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

Arguments:

  • other: 另一个向量

  • epsilon: 允许的误差

Return:

  • 是否近似平行
Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

Description: 判断两个向量是否近似平行。

Return: 是否近似平行

Arguments:

  • other: 另一个向量
  • epsilon: 允许的误差
Source code
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -74,7 +74,7 @@
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

Arguments:

  • other: 另一个向量

Return:

  • 是否平行
Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

Description: 判断两个向量是否平行。

Return: 是否平行

Arguments:

  • other: 另一个向量
Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -82,7 +82,7 @@
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

Description: 将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
     """
         将向量归一化。
 
@@ -91,32 +91,32 @@
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

Source code
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

Source code
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

Return:

Source code
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

Description: 向量的模。

Return: 模

Source code
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

Return:

  • 单位向量
Source code
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

Description: 获取该向量的单位向量。

Return: 单位向量

Source code
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

Source code
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

Source code
python
@overload
+    return self / self.length

method __abs__(self)

Source code
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

Source code
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

method self + other

Description: V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -131,7 +131,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

Arguments:

  • other:

Return:

  • 是否相等
Source code
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

Description: 判断两个向量是否相等。

Return: 是否相等

Arguments:

  • other:
Source code
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -139,7 +139,7 @@
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

Description: P + V -> P

别去点那边实现了。 :param other: :return:

Source code
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -147,11 +147,11 @@
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

Source code
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

Source code
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

Source code
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

Source code
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
+    ...

method self - other

Description: V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -165,7 +165,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

Arguments:

  • other:
Source code
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

Description: P - V -> P

Arguments:

  • other:
Source code
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -176,11 +176,11 @@
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

Source code
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

Source code
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

Source code
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

Source code
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

Description: 数组运算 非点乘。点乘使用@,叉乘使用cross。

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -193,18 +193,18 @@
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

Arguments:

  • other:
Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

Description: 点乘。

Arguments:

  • other:
Source code
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

Source code
python
def __neg__(self):
+    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

Source code
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

Source code
python
def __neg__(self):
     return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • Type: Vector3

  • Description: 零向量

var x_axis = Vector3(1, 0, 0)

  • Type: Vector3

  • Description: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • Type: Vector3

  • Description: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • Type: Vector3

  • Description: z轴单位向量

- + \ No newline at end of file diff --git a/en/api/particle/index.html b/en/api/particle/index.html index 26cf445..df4e322 100644 --- a/en/api/particle/index.html +++ b/en/api/particle/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/en/api/presets/index.html b/en/api/presets/index.html index 3d4f738..32da63f 100644 --- a/en/api/presets/index.html +++ b/en/api/presets/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/en/api/presets/model/index.html b/en/api/presets/model/index.html index 4057700..192420f 100644 --- a/en/api/presets/model/index.html +++ b/en/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

Arguments:

  • radius:

  • density:

Return:

  • List[Point3]: 球体上的点集。
Source code
python
@staticmethod
+    
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

Description: 生成球体上的点集。

Return: List[Point3]: 球体上的点集。

Arguments:

  • radius:
  • density:
Source code
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -35,7 +35,7 @@
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
     return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
- + \ No newline at end of file diff --git a/guide/index.html b/guide/index.html index 484e0c0..1a5b54e 100644 --- a/guide/index.html +++ b/guide/index.html @@ -18,7 +18,7 @@
Skip to content

开始不了一点

- + \ No newline at end of file diff --git a/hashmap.json b/hashmap.json index 004e0f2..47693e4 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"api-ex.md":"DOsKaL8H","api_index.md":"BvazTqTB","api_mp_math_angle.md":"HvtyV1VE","api_mp_math_const.md":"BzOZuyZq","api_mp_math_equation.md":"C2RSv9WY","api_mp_math_index.md":"4P0hk6gb","api_mp_math_line.md":"BPnyTp_q","api_mp_math_mp_math_typing.md":"B0OaWJmF","api_mp_math_plane.md":"DLhf2OdI","api_mp_math_point.md":"0dOKpGzi","api_mp_math_segment.md":"9QWXtPbn","api_mp_math_utils.md":"DdkUph5B","api_mp_math_vector.md":"Bodba8jG","api_particle_index.md":"BRCSxC3e","api_presets_index.md":"Dl6Ss91J","api_presets_model_index.md":"YrmtLmca","en_api_index.md":"Bgu-LD1B","en_api_mp_math_angle.md":"fmci6qlC","en_api_mp_math_const.md":"6yNmEodn","en_api_mp_math_equation.md":"BwRlBW4s","en_api_mp_math_index.md":"DrjDUYBY","en_api_mp_math_line.md":"B1oAhkHS","en_api_mp_math_mp_math_typing.md":"Ba9aYPR2","en_api_mp_math_plane.md":"D3xHJy8e","en_api_mp_math_point.md":"P1GRdc2H","en_api_mp_math_segment.md":"DqDvJpQR","en_api_mp_math_utils.md":"B0nejTCy","en_api_mp_math_vector.md":"BpRKRIGw","en_api_particle_index.md":"CmC1QX5o","en_api_presets_index.md":"CZ5hl_7D","en_api_presets_model_index.md":"j5zmPSwU","guide_index.md":"BE2yloik","index.md":"BE1qChTt","ja_api_index.md":"4BnflFIm","ja_api_mp_math_angle.md":"D2dStPZh","ja_api_mp_math_const.md":"CflutYeA","ja_api_mp_math_equation.md":"Cj8tgo_3","ja_api_mp_math_index.md":"CSAMHYsB","ja_api_mp_math_line.md":"Dg8duKLw","ja_api_mp_math_mp_math_typing.md":"Bhy6h0r0","ja_api_mp_math_plane.md":"CTOkqSft","ja_api_mp_math_point.md":"ZsmRVuaC","ja_api_mp_math_segment.md":"D5ZKDDr_","ja_api_mp_math_utils.md":"jeRmCp2Q","ja_api_mp_math_vector.md":"DAXdHSjp","ja_api_particle_index.md":"E2YnH7EN","ja_api_presets_index.md":"ATGcHt9d","ja_api_presets_model_index.md":"CleEI4sj","md-ex.md":"BX0WqOqv","zh-hant_api_index.md":"D-iBkJb-","zh-hant_api_mp_math_angle.md":"eKQSpiMX","zh-hant_api_mp_math_const.md":"B_tZ9wL7","zh-hant_api_mp_math_equation.md":"DPinrp8_","zh-hant_api_mp_math_index.md":"B8NLV8Cf","zh-hant_api_mp_math_line.md":"B-s8aLxY","zh-hant_api_mp_math_mp_math_typing.md":"DOwDUOu8","zh-hant_api_mp_math_plane.md":"B60Bzq3i","zh-hant_api_mp_math_point.md":"BEsHV_8G","zh-hant_api_mp_math_segment.md":"C-4eJk-Y","zh-hant_api_mp_math_utils.md":"z2lMMpnT","zh-hant_api_mp_math_vector.md":"n5Efae6D","zh-hant_api_particle_index.md":"BlduIPtw","zh-hant_api_presets_index.md":"CDyg87e9","zh-hant_api_presets_model_index.md":"DCHpjjZ_","zht_api_index.md":"Dq4XPUKZ","zht_api_mp_math_angle.md":"CMQhsVJf","zht_api_mp_math_const.md":"CIhADrI2","zht_api_mp_math_equation.md":"BwlIZxDL","zht_api_mp_math_index.md":"D09y2ubg","zht_api_mp_math_line.md":"Czel-DYb","zht_api_mp_math_mp_math_typing.md":"DlxSozR9","zht_api_mp_math_plane.md":"CxUaQCvU","zht_api_mp_math_point.md":"BmRy6Xj6","zht_api_mp_math_segment.md":"Bn34DhAl","zht_api_mp_math_utils.md":"BtiDgiKf","zht_api_mp_math_vector.md":"DmxfMXiN","zht_api_particle_index.md":"kAm9VAEw","zht_api_presets_index.md":"BmouaEaT","zht_api_presets_model_index.md":"DDom2SLG"} +{"api-ex.md":"DOsKaL8H","api_index.md":"BvazTqTB","api_mp_math_angle.md":"B8w0LP6o","api_mp_math_const.md":"BzOZuyZq","api_mp_math_equation.md":"Bx4yJe6o","api_mp_math_index.md":"4P0hk6gb","api_mp_math_line.md":"B1s7_FXM","api_mp_math_mp_math_typing.md":"B0OaWJmF","api_mp_math_plane.md":"BiW2-xb_","api_mp_math_point.md":"Cl5vX84g","api_mp_math_segment.md":"C6i78ST1","api_mp_math_utils.md":"B902hNw4","api_mp_math_vector.md":"CoooOTww","api_particle_index.md":"BRCSxC3e","api_presets_index.md":"Dl6Ss91J","api_presets_model_index.md":"kSDvd14X","en_api_index.md":"Bgu-LD1B","en_api_mp_math_angle.md":"DmK_A9xI","en_api_mp_math_const.md":"6yNmEodn","en_api_mp_math_equation.md":"BHF2EYD-","en_api_mp_math_index.md":"DrjDUYBY","en_api_mp_math_line.md":"B9L-UwK8","en_api_mp_math_mp_math_typing.md":"Ba9aYPR2","en_api_mp_math_plane.md":"BkRMq93h","en_api_mp_math_point.md":"S7QlcMfS","en_api_mp_math_segment.md":"CxreVgqR","en_api_mp_math_utils.md":"B7bkEcyv","en_api_mp_math_vector.md":"BLUu1BnW","en_api_particle_index.md":"CmC1QX5o","en_api_presets_index.md":"CZ5hl_7D","en_api_presets_model_index.md":"Bd091b7b","guide_index.md":"BE2yloik","index.md":"BE1qChTt","ja_api_index.md":"4BnflFIm","ja_api_mp_math_angle.md":"DxBe_g0o","ja_api_mp_math_const.md":"CflutYeA","ja_api_mp_math_equation.md":"CCgJ-L2G","ja_api_mp_math_index.md":"CSAMHYsB","ja_api_mp_math_line.md":"CxvAbM2L","ja_api_mp_math_mp_math_typing.md":"Bhy6h0r0","ja_api_mp_math_plane.md":"DGnOnQrW","ja_api_mp_math_point.md":"0J5Y2wYa","ja_api_mp_math_segment.md":"D0U5bMSu","ja_api_mp_math_utils.md":"zOjWX1mJ","ja_api_mp_math_vector.md":"DiKIzhuY","ja_api_particle_index.md":"E2YnH7EN","ja_api_presets_index.md":"ATGcHt9d","ja_api_presets_model_index.md":"Be7yN1vu","md-ex.md":"BX0WqOqv","zh-hant_api_index.md":"D-iBkJb-","zh-hant_api_mp_math_angle.md":"eKQSpiMX","zh-hant_api_mp_math_const.md":"B_tZ9wL7","zh-hant_api_mp_math_equation.md":"DPinrp8_","zh-hant_api_mp_math_index.md":"B8NLV8Cf","zh-hant_api_mp_math_line.md":"B-s8aLxY","zh-hant_api_mp_math_mp_math_typing.md":"DOwDUOu8","zh-hant_api_mp_math_plane.md":"B60Bzq3i","zh-hant_api_mp_math_point.md":"BEsHV_8G","zh-hant_api_mp_math_segment.md":"C-4eJk-Y","zh-hant_api_mp_math_utils.md":"z2lMMpnT","zh-hant_api_mp_math_vector.md":"n5Efae6D","zh-hant_api_particle_index.md":"BlduIPtw","zh-hant_api_presets_index.md":"CDyg87e9","zh-hant_api_presets_model_index.md":"DCHpjjZ_","zht_api_index.md":"Dq4XPUKZ","zht_api_mp_math_angle.md":"_4N19GGe","zht_api_mp_math_const.md":"CIhADrI2","zht_api_mp_math_equation.md":"C9cWPaC8","zht_api_mp_math_index.md":"D09y2ubg","zht_api_mp_math_line.md":"CG1Yioz9","zht_api_mp_math_mp_math_typing.md":"DlxSozR9","zht_api_mp_math_plane.md":"jJjMMFlO","zht_api_mp_math_point.md":"CRxiJq-m","zht_api_mp_math_segment.md":"U_lS4vUA","zht_api_mp_math_utils.md":"wrAVKQq5","zht_api_mp_math_vector.md":"B2jIk2y0","zht_api_particle_index.md":"kAm9VAEw","zht_api_presets_index.md":"BmouaEaT","zht_api_presets_model_index.md":"CPzp1vmU"} diff --git a/index.html b/index.html index 6e39a3c..f867032 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@
Skip to content

MBCP docs

More basic change particle

用于几何运算和粒子制作的库

- + \ No newline at end of file diff --git a/ja/api/index.html b/ja/api/index.html index e268c1e..0e08d28 100644 --- a/ja/api/index.html +++ b/ja/api/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/ja/api/mp_math/angle.html b/ja/api/mp_math/angle.html index 02aaee1..e8247da 100644 --- a/ja/api/mp_math/angle.html +++ b/ja/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

引数:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
+    
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

説明: 任意角度。

引数:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
ソースコード
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -27,96 +27,96 @@
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

戻り値:

  • 余角
ソースコード
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

説明: 余角:两角的和为90°。

戻り値: 余角

ソースコード
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

戻り値:

  • 补角
ソースコード
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

説明: 补角:两角的和为180°。

戻り値: 补角

ソースコード
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

戻り値:

  • 弧度
ソースコード
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

説明: 角度。

戻り値: 弧度

ソースコード
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

戻り値:

  • 最小正角度
ソースコード
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

説明: 最小正角。

戻り値: 最小正角度

ソースコード
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

戻り値:

  • 最大负角度
ソースコード
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

説明: 最大负角。

戻り値: 最大负角度

ソースコード
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

戻り値:

  • 正弦值
ソースコード
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

説明: 正弦值。

戻り値: 正弦值

ソースコード
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

戻り値:

  • 余弦值
ソースコード
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

説明: 余弦值。

戻り値: 余弦值

ソースコード
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

戻り値:

  • 正切值
ソースコード
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

説明: 正切值。

戻り値: 正切值

ソースコード
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

戻り値:

  • 余切值
ソースコード
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

説明: 余切值。

戻り値: 余切值

ソースコード
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

戻り値:

  • 正割值
ソースコード
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

説明: 正割值。

戻り値: 正割值

ソースコード
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

戻り値:

  • 余割值
ソースコード
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

説明: 余割值。

戻り値: 余割值

ソースコード
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

ソースコード
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

ソースコード
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

ソースコード
python
def __truediv__(self, other):
+    ...

method self / other

ソースコード
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)
- + \ No newline at end of file diff --git a/ja/api/mp_math/const.html b/ja/api/mp_math/const.html index c6f66df..2279d26 100644 --- a/ja/api/mp_math/const.html +++ b/ja/api/mp_math/const.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/ja/api/mp_math/equation.html b/ja/api/mp_math/equation.html index a376aa1..7735b3a 100644 --- a/ja/api/mp_math/equation.html +++ b/ja/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

引数:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

戻り値:

  • 偏导函数

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

説明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

戻り値: 偏导函数

引数:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -47,16 +47,16 @@
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

ソースコード
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

ソースコード
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

引数:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

説明: 曲线方程。

引数:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
ソースコード
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -66,7 +66,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

引数:

  • *t:

  • 参数:

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:
ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -79,7 +79,7 @@
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
         return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
- + \ No newline at end of file diff --git a/ja/api/mp_math/index.html b/ja/api/mp_math/index.html index 1e289d5..4fd1c33 100644 --- a/ja/api/mp_math/index.html +++ b/ja/api/mp_math/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/ja/api/mp_math/line.html b/ja/api/mp_math/line.html index 7aa3dcf..382d7d9 100644 --- a/ja/api/mp_math/line.html +++ b/ja/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

引数:

  • point: 直线上的一点

  • direction: 直线的方向向量

ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

説明: 三维空间中的直线。由一个点和一个方向向量确定。

引数:

  • point: 直线上的一点
  • direction: 直线的方向向量
ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -25,7 +25,7 @@
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

引数:

  • other: 另一条直线

  • epsilon: 误差

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

説明: 判断两条直线是否近似相等。

戻り値: 是否近似相等

引数:

  • other: 另一条直线
  • epsilon: 误差
ソースコード
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -34,7 +34,7 @@
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

引数:

  • other: 另一条直线

戻り値:

  • 夹角弧度

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

説明: 计算直线和直线之间的夹角。

戻り値: 夹角弧度

引数:

  • other: 另一条直线

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -44,7 +44,7 @@
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

引数:

  • other: 平行直线或点

戻り値:

  • 距离

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

説明: 计算直线和直线或点之间的距离。

戻り値: 距离

引数:

  • other: 平行直线或点

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -67,7 +67,7 @@
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

引数:

  • other: 另一条直线

戻り値:

  • 交点

例外:

  • ValueError 直线平行

  • ValueError 直线不共面

ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

説明: 计算两条直线的交点。

戻り値: 交点

引数:

  • other: 另一条直线

例外:

  • ValueError 直线平行
  • ValueError 直线不共面
ソースコード
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -82,7 +82,7 @@
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

引数:

  • point: 指定点

戻り値:

  • 垂线
ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

説明: 计算直线经过指定点p的垂线。

戻り値: 垂线

引数:

  • point: 指定点
ソースコード
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -90,7 +90,7 @@
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

引数:

  • t: 参数t

戻り値:

ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

説明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

戻り値: 点

引数:

  • t: 参数t
ソースコード
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -98,13 +98,13 @@
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

戻り値:

  • x(t), y(t), z(t)
ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

説明: 获取直线的参数方程。

戻り値: x(t), y(t), z(t)

ソースコード
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

引数:

  • other: 另一条直线

  • epsilon: 误差

戻り値:

  • 是否近似平行
ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

説明: 判断两条直线是否近似平行。

戻り値: 是否近似平行

引数:

  • other: 另一条直线
  • epsilon: 误差
ソースコード
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -113,7 +113,7 @@
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

引数:

  • other: 另一条直线

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

説明: 判断两条直线是否平行。

戻り値: 是否平行

引数:

  • other: 另一条直线
ソースコード
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -121,7 +121,7 @@
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

引数:

  • other: 另一条直线

戻り値:

  • 是否共线
ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

説明: 判断两条直线是否共线。

戻り値: 是否共线

引数:

  • other: 另一条直线
ソースコード
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -129,7 +129,7 @@
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

引数:

  • point: 点

戻り値:

  • 是否在直线上
ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

説明: 判断点是否在直线上。

戻り値: 是否在直线上

引数:

  • point: 点
ソースコード
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -137,7 +137,7 @@
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

引数:

  • other: 另一条直线

戻り値:

  • 是否共面
ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

説明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

戻り値: 是否共面

引数:

  • other: 另一条直线
ソースコード
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -146,7 +146,7 @@
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

説明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

ソースコード
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -159,7 +159,7 @@
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

引数:

  • p1: 点1

  • p2: 点2

戻り値:

  • 直线
ソースコード
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

説明: 工厂函数 由两点构造直线。

戻り値: 直线

引数:

  • p1: 点1
  • p2: 点2
ソースコード
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -170,7 +170,7 @@
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

引数:

  • other: 另一条直线

戻り値:

  • 交点
ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

説明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

戻り値: 交点

引数:

  • other: 另一条直线
ソースコード
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -183,7 +183,7 @@
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

  • other:
ソースコード
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

説明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

引数:

  • other:
ソースコード
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -195,7 +195,7 @@
 
         """
     return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
- + \ No newline at end of file diff --git a/ja/api/mp_math/mp_math_typing.html b/ja/api/mp_math/mp_math_typing.html index 6da90b3..a358872 100644 --- a/ja/api/mp_math/mp_math_typing.html +++ b/ja/api/mp_math/mp_math_typing.html @@ -18,7 +18,7 @@
Skip to content

var RealNumber = int | float

  • タイプ: TypeAlias

var Number = RealNumber | complex

  • タイプ: TypeAlias

var Var = SingleVar | ArrayVar

  • タイプ: TypeAlias

var OneSingleVarFunc = Callable[[SingleVar], SingleVar]

  • タイプ: TypeAlias

var OneArrayFunc = Callable[[ArrayVar], ArrayVar]

  • タイプ: TypeAlias

var OneVarFunc = OneSingleVarFunc | OneArrayFunc

  • タイプ: TypeAlias

var TwoSingleVarsFunc = Callable[[SingleVar, SingleVar], SingleVar]

  • タイプ: TypeAlias

var TwoArraysFunc = Callable[[ArrayVar, ArrayVar], ArrayVar]

  • タイプ: TypeAlias

var TwoVarsFunc = TwoSingleVarsFunc | TwoArraysFunc

  • タイプ: TypeAlias

var ThreeSingleVarsFunc = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

  • タイプ: TypeAlias

var ThreeArraysFunc = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

  • タイプ: TypeAlias

var ThreeVarsFunc = ThreeSingleVarsFunc | ThreeArraysFunc

  • タイプ: TypeAlias

var MultiSingleVarsFunc = Callable[..., SingleVar]

  • タイプ: TypeAlias

var MultiArraysFunc = Callable[..., ArrayVar]

  • タイプ: TypeAlias

var MultiVarsFunc = MultiSingleVarsFunc | MultiArraysFunc

  • タイプ: TypeAlias
- + \ No newline at end of file diff --git a/ja/api/mp_math/plane.html b/ja/api/mp_math/plane.html index c777024..02e3093 100644 --- a/ja/api/mp_math/plane.html +++ b/ja/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

引数:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
+    
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

説明: 平面方程:ax + by + cz + d = 0

引数:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
ソースコード
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -29,7 +29,7 @@
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

引数:

  • other: 另一个平面

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

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

戻り値: 是否近似相等

引数:

  • other: 另一个平面
ソースコード
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -47,7 +47,7 @@
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

引数:

  • other: 另一个平面

戻り値:

  • 夹角弧度

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

説明: 计算平面与平面之间的夹角。

戻り値: 夹角弧度

引数:

  • other: 另一个平面

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -62,7 +62,7 @@
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

引数:

  • other: 另一个平面或点

戻り値:

  • 距离

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

説明: 计算平面与平面或点之间的距离。

戻り値: 距离

引数:

  • other: 另一个平面或点

例外:

  • TypeError 不支持的类型
ソースコード
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -77,7 +77,7 @@
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

引数:

  • other: 另一个平面

戻り値:

  • 两平面的交线
ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

説明: 计算两平面的交线。

戻り値: 两平面的交线

引数:

  • other: 另一个平面
ソースコード
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -102,7 +102,7 @@
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

引数:

  • other: 不与平面平行或在平面上的直线

戻り値:

  • 交点

例外:

  • ValueError 平面与直线平行或重合
ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

説明: 计算平面与直线的交点。

戻り値: 交点

引数:

  • other: 不与平面平行或在平面上的直线

例外:

  • ValueError 平面与直线平行或重合
ソースコード
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -116,7 +116,7 @@
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

引数:

  • point: 指定点

戻り値:

  • 所求平面
ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

説明: 计算平行于该平面且过指定点的平面。

戻り値: 所求平面

引数:

  • point: 指定点
ソースコード
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -124,7 +124,7 @@
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

引数:

  • other: 另一个平面

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

説明: 判断两个平面是否平行。

戻り値: 是否平行

引数:

  • other: 另一个平面
ソースコード
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -132,14 +132,14 @@
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

戻り値:

  • 法向量
ソースコード
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

説明: 平面的法向量。

戻り値: 法向量

ソースコード
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

引数:

  • point: 平面上的一点

  • normal: 法向量

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

説明: 工厂函数 由点和法向量构造平面(点法式构造)。

戻り値: 平面

引数:

  • point: 平面上的一点
  • normal: 法向量
ソースコード
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -151,7 +151,7 @@
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

引数:

  • p1: 点1

  • p2: 点2

  • p3: 点3

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

説明: 工厂函数 由三点构造平面。

戻り値: 平面

引数:

  • p1: 点1
  • p2: 点2
  • p3: 点3
ソースコード
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -165,7 +165,7 @@
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

引数:

  • l1: 直线1

  • l2: 直线2

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

説明: 工厂函数 由两直线构造平面。

戻り値: 平面

引数:

  • l1: 直线1
  • l2: 直线2
ソースコード
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -179,7 +179,7 @@
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

引数:

  • point: 面上一点

  • line: 面上直线,不包含点

戻り値:

  • 平面
ソースコード
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

説明: 工厂函数 由点和直线构造平面。

戻り値: 平面

引数:

  • point: 面上一点
  • line: 面上直线,不包含点
ソースコード
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -189,11 +189,11 @@
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

ソースコード
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

ソースコード
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

ソースコード
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

ソースコード
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

引数:

  • other:

戻り値:

  • 不平行平面的交线,平面平行返回None
ソースコード
python
def __and__(self, other):
+    ...

method __and__(self, other)

説明: 取两平面的交集(人话:交线)

戻り値: 不平行平面的交线,平面平行返回None

引数:

  • other:
ソースコード
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -210,10 +210,10 @@
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

ソースコード
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

ソースコード
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

ソースコード
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)
- + \ No newline at end of file diff --git a/ja/api/mp_math/point.html b/ja/api/mp_math/point.html index 6623310..0c8834a 100644 --- a/ja/api/mp_math/point.html +++ b/ja/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Point3

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

笛卡尔坐标系中的点。

引数:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Point3

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

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

引数:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
ソースコード
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

引数:

  • other:

  • epsilon:

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

戻り値: 是否近似相等

引数:

  • other:
  • epsilon:
ソースコード
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -37,11 +37,11 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

ソースコード
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

引数:

  • other:
ソースコード
python
def __add__(self, other):
+    ...

method self + other

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

引数:

  • other:
ソースコード
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -49,14 +49,14 @@
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

引数:

  • other:
ソースコード
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

引数:

  • other:
ソースコード
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

引数:

  • other:
ソースコード
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

説明: P - P -> V

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

引数:

  • other:
ソースコード
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -68,7 +68,7 @@
         """
     from .vector import Vector3
     return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
- + \ No newline at end of file diff --git a/ja/api/mp_math/segment.html b/ja/api/mp_math/segment.html index bfecb8f..dbced17 100644 --- a/ja/api/mp_math/segment.html +++ b/ja/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

説明: 三维空间中的线段。 :param p1: :param p2:

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -31,7 +31,7 @@
     self.length = self.direction.length
     '中心点'
     self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
- + \ No newline at end of file diff --git a/ja/api/mp_math/utils.html b/ja/api/mp_math/utils.html index 212c332..b8761df 100644 --- a/ja/api/mp_math/utils.html +++ b/ja/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

func clamp() -> float

区间限定函数

引数:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

戻り値:

  • 限制后的值
ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

func clamp() -> float

説明: 区间限定函数

戻り値: 限制后的值

引数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,7 +28,7 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

引数:

  • x: 数1

  • y: 数2

  • epsilon: 误差

戻り値:

  • 是否近似相等
ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

説明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

戻り値: 是否近似相等

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差
ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -38,7 +38,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

引数:

  • x: 数

  • only_neg: 是否只返回负数的符号

戻り値:

  • 符号 + - ""
ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

説明: 获取数的符号。

戻り値: 符号 + - ""

引数:

  • x: 数
  • only_neg: 是否只返回负数的符号
ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -51,7 +51,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

引数:

  • x: 数

  • only_neg: 是否只返回负数的符号

戻り値:

  • 符号 + - ""
ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

説明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

戻り値: 符号 + - ""

引数:

  • x: 数
  • only_neg: 是否只返回负数的符号
ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -67,8 +67,8 @@
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

ソースコード
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -78,10 +78,10 @@
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

ソースコード
python
def __ne__(self, other):
+            self.raise_type_error(other)

method raise_type_error(self, other)

ソースコード
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

ソースコード
python
def __ne__(self, other):
     return not self.__eq__(other)
- + \ No newline at end of file diff --git a/ja/api/mp_math/vector.html b/ja/api/mp_math/vector.html index 024ea01..f171270 100644 --- a/ja/api/mp_math/vector.html +++ b/ja/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Vector3

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

3维向量

引数:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

ソースコード
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Vector3

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

説明: 3维向量

引数:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
ソースコード
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

引数:

  • other:

  • epsilon:

戻り値:

  • 是否近似相等
ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

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

戻り値: 是否近似相等

引数:

  • other:
  • epsilon:
ソースコード
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -37,7 +37,7 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

引数:

  • other: 另一个向量

戻り値:

  • 夹角
ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

説明: 计算两个向量之间的夹角。

戻り値: 夹角

引数:

  • other: 另一个向量
ソースコード
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -45,7 +45,7 @@
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

引数:

  • other:

戻り値:

  • 行列式的结果
ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

説明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

戻り値: 行列式的结果

引数:

  • other:
ソースコード
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -65,7 +65,7 @@
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

引数:

  • other: 另一个向量

  • epsilon: 允许的误差

戻り値:

  • 是否近似平行
ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

説明: 判断两个向量是否近似平行。

戻り値: 是否近似平行

引数:

  • other: 另一个向量
  • epsilon: 允许的误差
ソースコード
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -74,7 +74,7 @@
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

引数:

  • other: 另一个向量

戻り値:

  • 是否平行
ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

説明: 判断两个向量是否平行。

戻り値: 是否平行

引数:

  • other: 另一个向量
ソースコード
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -82,7 +82,7 @@
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

説明: 将向量归一化。

自体归一化,不返回值。

ソースコード
python
def normalize(self):
     """
         将向量归一化。
 
@@ -91,32 +91,32 @@
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

ソースコード
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

ソースコード
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

戻り値:

ソースコード
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

説明: 向量的模。

戻り値: 模

ソースコード
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

戻り値:

  • 单位向量
ソースコード
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

説明: 获取该向量的单位向量。

戻り値: 单位向量

ソースコード
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

ソースコード
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

ソースコード
python
@overload
+    return self / self.length

method __abs__(self)

ソースコード
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

引数:

  • other:
ソースコード
python
def __add__(self, other):
+    ...

method self + other

説明: V + P -> P

V + V -> V

引数:

  • other:
ソースコード
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -131,7 +131,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

引数:

  • other:

戻り値:

  • 是否相等
ソースコード
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

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

戻り値: 是否相等

引数:

  • other:
ソースコード
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -139,7 +139,7 @@
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

説明: P + V -> P

别去点那边实现了。 :param other: :return:

ソースコード
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -147,11 +147,11 @@
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

ソースコード
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

ソースコード
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

引数:

  • other:
ソースコード
python
def __sub__(self, other):
+    ...

method self - other

説明: V - P -> P

V - V -> V

引数:

  • other:
ソースコード
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -165,7 +165,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

引数:

  • other:
ソースコード
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

説明: P - V -> P

引数:

  • other:
ソースコード
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -176,11 +176,11 @@
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

ソースコード
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

ソースコード
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

  • other:
ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

説明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

引数:

  • other:
ソースコード
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -193,18 +193,18 @@
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

引数:

  • other:
ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

説明: 点乘。

引数:

  • other:
ソースコード
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

ソースコード
python
def __neg__(self):
+    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

ソースコード
python
def __neg__(self):
     return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • タイプ: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • タイプ: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • タイプ: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • タイプ: Vector3

  • 説明: z轴单位向量

- + \ No newline at end of file diff --git a/ja/api/particle/index.html b/ja/api/particle/index.html index 1ccc710..bfe8294 100644 --- a/ja/api/particle/index.html +++ b/ja/api/particle/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/ja/api/presets/index.html b/ja/api/presets/index.html index 39d763d..7ddb3b8 100644 --- a/ja/api/presets/index.html +++ b/ja/api/presets/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/ja/api/presets/model/index.html b/ja/api/presets/model/index.html index 9a97d0a..d75e608 100644 --- a/ja/api/presets/model/index.html +++ b/ja/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

引数:

  • radius:

  • density:

戻り値:

  • List[Point3]: 球体上的点集。
ソースコード
python
@staticmethod
+    
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

説明: 生成球体上的点集。

戻り値: List[Point3]: 球体上的点集。

引数:

  • radius:
  • density:
ソースコード
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -35,7 +35,7 @@
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
     return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
- + \ No newline at end of file diff --git a/md-ex.html b/md-ex.html index 65e8351..8be09d2 100644 --- a/md-ex.html +++ b/md-ex.html @@ -50,7 +50,7 @@ ::: details This is a details block. :::

Output

INFO

This is an info box.

TIP

This is a tip.

WARNING

This is a warning.

DANGER

This is a dangerous warning.

Details

This is a details block.

More

Check out the documentation for the full list of markdown extensions.

- + \ No newline at end of file diff --git a/zh-Hant/api/index.html b/zh-Hant/api/index.html index 2709bfa..23ffea6 100644 --- a/zh-Hant/api/index.html +++ b/zh-Hant/api/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/angle.html b/zh-Hant/api/mp_math/angle.html index 4397cd0..e1bc606 100644 --- a/zh-Hant/api/mp_math/angle.html +++ b/zh-Hant/api/mp_math/angle.html @@ -118,7 +118,7 @@ if isinstance(other, AnyAngle): return self.radian / other.radian return AnyAngle(self.radian / other, is_radian=True)
- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/const.html b/zh-Hant/api/mp_math/const.html index a72bbdc..bf33071 100644 --- a/zh-Hant/api/mp_math/const.html +++ b/zh-Hant/api/mp_math/const.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/equation.html b/zh-Hant/api/mp_math/equation.html index 3f83ff5..f1a547d 100644 --- a/zh-Hant/api/mp_math/equation.html +++ b/zh-Hant/api/mp_math/equation.html @@ -80,7 +80,7 @@ else: return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])

def __str__(self)

源碼
python
def __str__(self):
     return 'CurveEquation()'

var result_func = get_partial_derivative_func(result_func, v, epsilon)

- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/index.html b/zh-Hant/api/mp_math/index.html index dc83dd5..2521ef7 100644 --- a/zh-Hant/api/mp_math/index.html +++ b/zh-Hant/api/mp_math/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/line.html b/zh-Hant/api/mp_math/line.html index fa12d69..57951d0 100644 --- a/zh-Hant/api/mp_math/line.html +++ b/zh-Hant/api/mp_math/line.html @@ -209,7 +209,7 @@ s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}' return s

def __repr__(self)

源碼
python
def __repr__(self):
     return f'Line3({self.point}, {self.direction})'
- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/mp_math_typing.html b/zh-Hant/api/mp_math/mp_math_typing.html index 8074cf5..3d482c4 100644 --- a/zh-Hant/api/mp_math/mp_math_typing.html +++ b/zh-Hant/api/mp_math/mp_math_typing.html @@ -18,7 +18,7 @@
Skip to content

var RealNumber: TypeAlias = int | float

var Number: TypeAlias = RealNumber | complex

var SingleVar = TypeVar('SingleVar', bound=Number)

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

var Var: TypeAlias = SingleVar | ArrayVar

var OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]

var OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]

var OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc

var TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]

var TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]

var TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc

var ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

var ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

var ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc

var MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]

var MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]

var MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc

- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/plane.html b/zh-Hant/api/mp_math/plane.html index 3641700..8122e5a 100644 --- a/zh-Hant/api/mp_math/plane.html +++ b/zh-Hant/api/mp_math/plane.html @@ -226,7 +226,7 @@ raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

def __eq__(self, other) -> bool

源碼
python
def __eq__(self, other) -> bool:
     return self.approx(other)

def __rand__(self, other: 'Line3') -> 'Point3'

源碼
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)

var k = other.a / self.a

var A = np.array([[self.b, self.c], [other.b, other.c]])

var B = np.array([-self.d, -other.d])

var v2 = l2.get_point(1) - l1.point

var k = other.b / self.b

var A = np.array([[self.a, self.c], [other.a, other.c]])

var B = np.array([-self.d, -other.d])

var k = other.c / self.c

var A = np.array([[self.a, self.b], [other.a, other.b]])

var B = np.array([-self.d, -other.d])

- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/point.html b/zh-Hant/api/mp_math/point.html index c060a77..29ff08f 100644 --- a/zh-Hant/api/mp_math/point.html +++ b/zh-Hant/api/mp_math/point.html @@ -69,7 +69,7 @@ """ from .vector import Vector3 return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/segment.html b/zh-Hant/api/mp_math/segment.html index facfb00..4f27020 100644 --- a/zh-Hant/api/mp_math/segment.html +++ b/zh-Hant/api/mp_math/segment.html @@ -33,7 +33,7 @@ self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)

def __repr__(self)

源碼
python
def __repr__(self):
     return f'Segment3({self.p1}, {self.p2})'

def __str__(self)

源碼
python
def __str__(self):
     return f'Segment3({self.p1} -> {self.p2})'
- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/utils.html b/zh-Hant/api/mp_math/utils.html index 3310dd6..638f213 100644 --- a/zh-Hant/api/mp_math/utils.html +++ b/zh-Hant/api/mp_math/utils.html @@ -82,7 +82,7 @@ self.raise_type_error(other)

def raise_type_error(self, other)

源碼
python
def raise_type_error(self, other):
     raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

def __ne__(self, other)

源碼
python
def __ne__(self, other):
     return not self.__eq__(other)
- + \ No newline at end of file diff --git a/zh-Hant/api/mp_math/vector.html b/zh-Hant/api/mp_math/vector.html index 4a7cf71..6ca3cea 100644 --- a/zh-Hant/api/mp_math/vector.html +++ b/zh-Hant/api/mp_math/vector.html @@ -206,7 +206,7 @@ return Vector3(-self.x, -self.y, -self.z)

def __repr__(self)

源碼
python
def __repr__(self):
     return f'Vector3({self.x}, {self.y}, {self.z})'

def __str__(self)

源碼
python
def __str__(self):
     return f'Vector3({self.x}, {self.y}, {self.z})'

var zero_vector3 = Vector3(0, 0, 0)

var x_axis = Vector3(1, 0, 0)

var y_axis = Vector3(0, 1, 0)

var z_axis = Vector3(0, 0, 1)

- + \ No newline at end of file diff --git a/zh-Hant/api/particle/index.html b/zh-Hant/api/particle/index.html index 3f66c74..69e6206 100644 --- a/zh-Hant/api/particle/index.html +++ b/zh-Hant/api/particle/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zh-Hant/api/presets/index.html b/zh-Hant/api/presets/index.html index 79ab0a5..38dbcbc 100644 --- a/zh-Hant/api/presets/index.html +++ b/zh-Hant/api/presets/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zh-Hant/api/presets/model/index.html b/zh-Hant/api/presets/model/index.html index 7304f99..ba2a771 100644 --- a/zh-Hant/api/presets/model/index.html +++ b/zh-Hant/api/presets/model/index.html @@ -35,7 +35,7 @@ y_array = radius * np.sin(phi_list) * np.sin(theta_list) z_array = radius * np.cos(phi_list) return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
- + \ No newline at end of file diff --git a/zht/api/index.html b/zht/api/index.html index 1d23982..beb6d85 100644 --- a/zht/api/index.html +++ b/zht/api/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zht/api/mp_math/angle.html b/zht/api/mp_math/angle.html index 366a1d2..1c1fe14 100644 --- a/zht/api/mp_math/angle.html +++ b/zht/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

任意角度。

變數説明:

  • value: 角度或弧度值

  • is_radian: 是否为弧度,默认为否

源碼
python
def __init__(self, value: float, is_radian: bool=False):
+    
Skip to content

class Angle

class AnyAngle(Angle)

method __init__(self, value: float, is_radian: bool = False)

説明: 任意角度。

變數説明:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
源碼
python
def __init__(self, value: float, is_radian: bool=False):
     """
         任意角度。
         Args:
@@ -27,96 +27,96 @@
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

余角:两角的和为90°。

返回:

  • 余角
源碼
python
@property
+        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

説明: 余角:两角的和为90°。

返回: 余角

源碼
python
@property
 def complementary(self) -> 'AnyAngle':
     """
         余角:两角的和为90°。
         Returns:
             余角
         """
-    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

补角:两角的和为180°。

返回:

  • 补角
源碼
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

説明: 补角:两角的和为180°。

返回: 补角

源碼
python
@property
 def supplementary(self) -> 'AnyAngle':
     """
         补角:两角的和为180°。
         Returns:
             补角
         """
-    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

角度。

返回:

  • 弧度
源碼
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

説明: 角度。

返回: 弧度

源碼
python
@property
 def degree(self) -> float:
     """
         角度。
         Returns:
             弧度
         """
-    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

最小正角。

返回:

  • 最小正角度
源碼
python
@property
+    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

説明: 最小正角。

返回: 最小正角度

源碼
python
@property
 def minimum_positive(self) -> 'AnyAngle':
     """
         最小正角。
         Returns:
             最小正角度
         """
-    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

最大负角。

返回:

  • 最大负角度
源碼
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

説明: 最大负角。

返回: 最大负角度

源碼
python
@property
 def maximum_negative(self) -> 'AnyAngle':
     """
         最大负角。
         Returns:
             最大负角度
         """
-    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

正弦值。

返回:

  • 正弦值
源碼
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

説明: 正弦值。

返回: 正弦值

源碼
python
@property
 def sin(self) -> float:
     """
         正弦值。
         Returns:
             正弦值
         """
-    return math.sin(self.radian)

@property

method cos(self) -> float

余弦值。

返回:

  • 余弦值
源碼
python
@property
+    return math.sin(self.radian)

@property

method cos(self) -> float

説明: 余弦值。

返回: 余弦值

源碼
python
@property
 def cos(self) -> float:
     """
         余弦值。
         Returns:
             余弦值
         """
-    return math.cos(self.radian)

@property

method tan(self) -> float

正切值。

返回:

  • 正切值
源碼
python
@property
+    return math.cos(self.radian)

@property

method tan(self) -> float

説明: 正切值。

返回: 正切值

源碼
python
@property
 def tan(self) -> float:
     """
         正切值。
         Returns:
             正切值
         """
-    return math.tan(self.radian)

@property

method cot(self) -> float

余切值。

返回:

  • 余切值
源碼
python
@property
+    return math.tan(self.radian)

@property

method cot(self) -> float

説明: 余切值。

返回: 余切值

源碼
python
@property
 def cot(self) -> float:
     """
         余切值。
         Returns:
             余切值
         """
-    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

正割值。

返回:

  • 正割值
源碼
python
@property
+    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

説明: 正割值。

返回: 正割值

源碼
python
@property
 def sec(self) -> float:
     """
         正割值。
         Returns:
             正割值
         """
-    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

余割值。

返回:

  • 余割值
源碼
python
@property
+    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

説明: 余割值。

返回: 余割值

源碼
python
@property
 def csc(self) -> float:
     """
         余割值。
         Returns:
             余割值
         """
-    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源碼
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源碼
python
def __eq__(self, other):
-    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源碼
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
-    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源碼
python
def __mul__(self, other: float) -> 'AnyAngle':
-    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源碼
python
@overload
+    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

源碼
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

method __eq__(self, other)

源碼
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

源碼
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

method self * other: float => AnyAngle

源碼
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

method self / other: float => AnyAngle

源碼
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源碼
python
@overload
+    ...

@overload

method self / other: AnyAngle => float

源碼
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

源碼
python
def __truediv__(self, other):
+    ...

method self / other

源碼
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)
- + \ No newline at end of file diff --git a/zht/api/mp_math/const.html b/zht/api/mp_math/const.html index cbf5c8b..d752149 100644 --- a/zht/api/mp_math/const.html +++ b/zht/api/mp_math/const.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zht/api/mp_math/equation.html b/zht/api/mp_math/equation.html index f0f83d4..e7f06ad 100644 --- a/zht/api/mp_math/equation.html +++ b/zht/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

求N元函数一阶偏导函数。这玩意不太稳定,慎用。

變數説明:

  • func: 函数

  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)

  • epsilon: 偏移量

返回:

  • 偏导函数

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+    
Skip to content

func get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc

説明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

返回: 偏导函数

變數説明:

  • func: 函数
  • var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导)
  • epsilon: 偏移量

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     Args:
@@ -47,16 +47,16 @@
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源碼
python
def partial_derivative_func(*args: Var) -> Var:
+        raise ValueError('Invalid var type')

func partial_derivative_func() -> Var

源碼
python
def partial_derivative_func(*args: Var) -> Var:
     args_list_plus = list(args)
     args_list_plus[var] += epsilon
     args_list_minus = list(args)
     args_list_minus[var] -= epsilon
-    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源碼
python
def high_order_partial_derivative_func(*args: Var) -> Var:
+    return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)

func high_order_partial_derivative_func() -> Var

源碼
python
def high_order_partial_derivative_func(*args: Var) -> Var:
     result_func = func
     for v in var:
         result_func = get_partial_derivative_func(result_func, v, epsilon)
-    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

曲线方程。

變數説明:

  • x_func: x函数

  • y_func: y函数

  • z_func: z函数

源碼
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
+    return result_func(*args)

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

説明: 曲线方程。

變數説明:

  • x_func: x函数
  • y_func: y函数
  • z_func: z函数
源碼
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
     """
         曲线方程。
         Args:
@@ -66,7 +66,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

计算曲线上的点。

變數説明:

  • *t:

  • 参数:

源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

method __call__(self) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:
源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -79,7 +79,7 @@
         return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
     else:
         return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])
- + \ No newline at end of file diff --git a/zht/api/mp_math/index.html b/zht/api/mp_math/index.html index 24707ce..93ba339 100644 --- a/zht/api/mp_math/index.html +++ b/zht/api/mp_math/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zht/api/mp_math/line.html b/zht/api/mp_math/line.html index 9672a3b..43508ed 100644 --- a/zht/api/mp_math/line.html +++ b/zht/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

三维空间中的直线。由一个点和一个方向向量确定。

變數説明:

  • point: 直线上的一点

  • direction: 直线的方向向量

源碼
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

class Line3

method __init__(self, point: Point3, direction: Vector3)

説明: 三维空间中的直线。由一个点和一个方向向量确定。

變數説明:

  • point: 直线上的一点
  • direction: 直线的方向向量
源碼
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
     """
         三维空间中的直线。由一个点和一个方向向量确定。
         Args:
@@ -25,7 +25,7 @@
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

判断两条直线是否近似相等。

變數説明:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

method approx(self, other: Line3, epsilon: float = APPROX) -> bool

説明: 判断两条直线是否近似相等。

返回: 是否近似相等

變數説明:

  • other: 另一条直线
  • epsilon: 误差
源碼
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
     """
         判断两条直线是否近似相等。
         Args:
@@ -34,7 +34,7 @@
         Returns:
             是否近似相等
         """
-    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

计算直线和直线之间的夹角。

變數説明:

  • other: 另一条直线

返回:

  • 夹角弧度

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
+    return self.is_approx_parallel(other, epsilon) and (self.point - other.point).is_approx_parallel(self.direction, epsilon)

method cal_angle(self, other: Line3) -> AnyAngle

説明: 计算直线和直线之间的夹角。

返回: 夹角弧度

變數説明:

  • other: 另一条直线

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
     """
         计算直线和直线之间的夹角。
         Args:
@@ -44,7 +44,7 @@
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

计算直线和直线或点之间的距离。

變數説明:

  • other: 平行直线或点

返回:

  • 距离

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
+    return self.direction.cal_angle(other.direction)

method cal_distance(self, other: Line3 | Point3) -> float

説明: 计算直线和直线或点之间的距离。

返回: 距离

變數説明:

  • other: 平行直线或点

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Line3 | Point3') -> float:
     """
         计算直线和直线或点之间的距离。
         Args:
@@ -67,7 +67,7 @@
     elif isinstance(other, Point3):
         return (other - self.point).cross(self.direction).length / self.direction.length
     else:
-        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

计算两条直线的交点。

變數説明:

  • other: 另一条直线

返回:

  • 交点

抛出:

  • ValueError 直线平行

  • ValueError 直线不共面

源碼
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

method cal_intersection(self, other: Line3) -> Point3

説明: 计算两条直线的交点。

返回: 交点

變數説明:

  • other: 另一条直线

抛出:

  • ValueError 直线平行
  • ValueError 直线不共面
源碼
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
     """
         计算两条直线的交点。
         Args:
@@ -82,7 +82,7 @@
         raise ValueError('Lines are parallel and do not intersect.')
     if not self.is_coplanar(other):
         raise ValueError('Lines are not coplanar and do not intersect.')
-    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

计算直线经过指定点p的垂线。

變數説明:

  • point: 指定点

返回:

  • 垂线
源碼
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
+    return self.point + self.direction.cross(other.direction) @ other.direction.cross(self.point - other.point) / self.direction.cross(other.direction).length ** 2 * self.direction

method cal_perpendicular(self, point: Point3) -> Line3

説明: 计算直线经过指定点p的垂线。

返回: 垂线

變數説明:

  • point: 指定点
源碼
python
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
     """
         计算直线经过指定点p的垂线。
         Args:
@@ -90,7 +90,7 @@
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

變數説明:

  • t: 参数t

返回:

源碼
python
def get_point(self, t: RealNumber) -> 'Point3':
+    return Line3(point, self.direction.cross(point - self.point))

method get_point(self, t: RealNumber) -> Point3

説明: 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。

返回: 点

變數説明:

  • t: 参数t
源碼
python
def get_point(self, t: RealNumber) -> 'Point3':
     """
         获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
         Args:
@@ -98,13 +98,13 @@
         Returns:
 
         """
-    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

获取直线的参数方程。

返回:

  • x(t), y(t), z(t)
源碼
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
+    return self.point + t * self.direction

method get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]

説明: 获取直线的参数方程。

返回: x(t), y(t), z(t)

源碼
python
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
     """
         获取直线的参数方程。
         Returns:
             x(t), y(t), z(t)
         """
-    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

判断两条直线是否近似平行。

變數説明:

  • other: 另一条直线

  • epsilon: 误差

返回:

  • 是否近似平行
源碼
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
+    return (lambda t: self.point.x + self.direction.x * t, lambda t: self.point.y + self.direction.y * t, lambda t: self.point.z + self.direction.z * t)

method is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool

説明: 判断两条直线是否近似平行。

返回: 是否近似平行

變數説明:

  • other: 另一条直线
  • epsilon: 误差
源碼
python
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
     """
         判断两条直线是否近似平行。
         Args:
@@ -113,7 +113,7 @@
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

判断两条直线是否平行。

變數説明:

  • other: 另一条直线

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

method is_parallel(self, other: Line3) -> bool

説明: 判断两条直线是否平行。

返回: 是否平行

變數説明:

  • other: 另一条直线
源碼
python
def is_parallel(self, other: 'Line3') -> bool:
     """
         判断两条直线是否平行。
         Args:
@@ -121,7 +121,7 @@
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

判断两条直线是否共线。

變數説明:

  • other: 另一条直线

返回:

  • 是否共线
源碼
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

method is_collinear(self, other: Line3) -> bool

説明: 判断两条直线是否共线。

返回: 是否共线

變數説明:

  • other: 另一条直线
源碼
python
def is_collinear(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共线。
         Args:
@@ -129,7 +129,7 @@
         Returns:
             是否共线
         """
-    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

判断点是否在直线上。

變數説明:

  • point: 点

返回:

  • 是否在直线上
源碼
python
def is_point_on(self, point: 'Point3') -> bool:
+    return self.is_parallel(other) and (self.point - other.point).is_parallel(self.direction)

method is_point_on(self, point: Point3) -> bool

説明: 判断点是否在直线上。

返回: 是否在直线上

變數説明:

  • point: 点
源碼
python
def is_point_on(self, point: 'Point3') -> bool:
     """
         判断点是否在直线上。
         Args:
@@ -137,7 +137,7 @@
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

變數説明:

  • other: 另一条直线

返回:

  • 是否共面
源碼
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

method is_coplanar(self, other: Line3) -> bool

説明: 判断两条直线是否共面。 充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。

返回: 是否共面

變數説明:

  • other: 另一条直线
源碼
python
def is_coplanar(self, other: 'Line3') -> bool:
     """
         判断两条直线是否共面。
         充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
@@ -146,7 +146,7 @@
         Returns:
             是否共面
         """
-    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源碼
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

method simplify(self)

説明: 简化直线方程,等价相等。 自体简化,不返回值。

按照可行性一次对x y z 化 0 处理,并对向量单位化

源碼
python
def simplify(self):
     """
         简化直线方程,等价相等。
         自体简化,不返回值。
@@ -159,7 +159,7 @@
     if self.direction.y == 0:
         self.point.y = 0
     if self.direction.z == 0:
-        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

工厂函数 由两点构造直线。

變數説明:

  • p1: 点1

  • p2: 点2

返回:

  • 直线
源碼
python
@classmethod
+        self.point.z = 0

@classmethod

method from_two_points(cls, p1: Point3, p2: Point3) -> Line3

説明: 工厂函数 由两点构造直线。

返回: 直线

變數説明:

  • p1: 点1
  • p2: 点2
源碼
python
@classmethod
 def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
     """
         工厂函数 由两点构造直线。
@@ -170,7 +170,7 @@
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

變數説明:

  • other: 另一条直线

返回:

  • 交点
源碼
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

method __and__(self, other: Line3) -> Line3 | Point3 | None

説明: 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。

返回: 交点

變數説明:

  • other: 另一条直线
源碼
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
     """
         计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
         Args:
@@ -183,7 +183,7 @@
     elif self.is_parallel(other) or not self.is_coplanar(other):
         return None
     else:
-        return self.cal_intersection(other)

method __eq__(self, other) -> bool

判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

變數説明:

  • other:
源碼
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

method __eq__(self, other) -> bool

説明: 判断两条直线是否等价。

v1 // v2 ∧ (p1 - p2) // v1

變數説明:

  • other:
源碼
python
def __eq__(self, other) -> bool:
     """
         判断两条直线是否等价。
 
@@ -195,7 +195,7 @@
 
         """
     return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
- + \ No newline at end of file diff --git a/zht/api/mp_math/mp_math_typing.html b/zht/api/mp_math/mp_math_typing.html index 083017f..06bd653 100644 --- a/zht/api/mp_math/mp_math_typing.html +++ b/zht/api/mp_math/mp_math_typing.html @@ -18,7 +18,7 @@
Skip to content

var RealNumber = int | float

  • 類型: TypeAlias

var Number = RealNumber | complex

  • 類型: TypeAlias

var Var = SingleVar | ArrayVar

  • 類型: TypeAlias

var OneSingleVarFunc = Callable[[SingleVar], SingleVar]

  • 類型: TypeAlias

var OneArrayFunc = Callable[[ArrayVar], ArrayVar]

  • 類型: TypeAlias

var OneVarFunc = OneSingleVarFunc | OneArrayFunc

  • 類型: TypeAlias

var TwoSingleVarsFunc = Callable[[SingleVar, SingleVar], SingleVar]

  • 類型: TypeAlias

var TwoArraysFunc = Callable[[ArrayVar, ArrayVar], ArrayVar]

  • 類型: TypeAlias

var TwoVarsFunc = TwoSingleVarsFunc | TwoArraysFunc

  • 類型: TypeAlias

var ThreeSingleVarsFunc = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]

  • 類型: TypeAlias

var ThreeArraysFunc = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]

  • 類型: TypeAlias

var ThreeVarsFunc = ThreeSingleVarsFunc | ThreeArraysFunc

  • 類型: TypeAlias

var MultiSingleVarsFunc = Callable[..., SingleVar]

  • 類型: TypeAlias

var MultiArraysFunc = Callable[..., ArrayVar]

  • 類型: TypeAlias

var MultiVarsFunc = MultiSingleVarsFunc | MultiArraysFunc

  • 類型: TypeAlias
- + \ No newline at end of file diff --git a/zht/api/mp_math/plane.html b/zht/api/mp_math/plane.html index 613fc6b..fa99191 100644 --- a/zht/api/mp_math/plane.html +++ b/zht/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

平面方程:ax + by + cz + d = 0

變數説明:

  • a: x系数

  • b: y系数

  • c: z系数

  • d: 常数项

源碼
python
def __init__(self, a: float, b: float, c: float, d: float):
+    
Skip to content

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

説明: 平面方程:ax + by + cz + d = 0

變數説明:

  • a: x系数
  • b: y系数
  • c: z系数
  • d: 常数项
源碼
python
def __init__(self, a: float, b: float, c: float, d: float):
     """
         平面方程:ax + by + cz + d = 0
         Args:
@@ -29,7 +29,7 @@
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

method approx(self, other: Plane3) -> bool

判断两个平面是否近似相等。

變數説明:

  • other: 另一个平面

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

method approx(self, other: Plane3) -> bool

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

返回: 是否近似相等

變數説明:

  • other: 另一个平面
源碼
python
def approx(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否近似相等。
         Args:
@@ -47,7 +47,7 @@
         k = other.c / self.c
         return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
     else:
-        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

计算平面与平面之间的夹角。

變數説明:

  • other: 另一个平面

返回:

  • 夹角弧度

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
+        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

説明: 计算平面与平面之间的夹角。

返回: 夹角弧度

變數説明:

  • other: 另一个平面

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
     """
         计算平面与平面之间的夹角。
         Args:
@@ -62,7 +62,7 @@
     elif isinstance(other, Plane3):
         return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

计算平面与平面或点之间的距离。

變數説明:

  • other: 另一个平面或点

返回:

  • 距离

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

説明: 计算平面与平面或点之间的距离。

返回: 距离

變數説明:

  • other: 另一个平面或点

抛出:

  • TypeError 不支持的类型
源碼
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
     """
         计算平面与平面或点之间的距离。
         Args:
@@ -77,7 +77,7 @@
     elif isinstance(other, Point3):
         return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
     else:
-        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

计算两平面的交线。

變數説明:

  • other: 另一个平面

返回:

  • 两平面的交线
源碼
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

説明: 计算两平面的交线。

返回: 两平面的交线

變數説明:

  • other: 另一个平面
源碼
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
     """
         计算两平面的交线。
         Args:
@@ -102,7 +102,7 @@
         A = np.array([[self.a, self.b], [other.a, other.b]])
         B = np.array([-self.d, -other.d])
         x, y = np.linalg.solve(A, B)
-    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

计算平面与直线的交点。

變數説明:

  • other: 不与平面平行或在平面上的直线

返回:

  • 交点

抛出:

  • ValueError 平面与直线平行或重合
源碼
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
+    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

説明: 计算平面与直线的交点。

返回: 交点

變數説明:

  • other: 不与平面平行或在平面上的直线

抛出:

  • ValueError 平面与直线平行或重合
源碼
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
     """
         计算平面与直线的交点。
         Args:
@@ -116,7 +116,7 @@
         raise ValueError('The plane and the line are parallel or coincident.')
     x, y, z = other.get_parametric_equations()
     t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
-    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

计算平行于该平面且过指定点的平面。

變數説明:

  • point: 指定点

返回:

  • 所求平面
源碼
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

説明: 计算平行于该平面且过指定点的平面。

返回: 所求平面

變數説明:

  • point: 指定点
源碼
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
     """
         计算平行于该平面且过指定点的平面。
         Args:
@@ -124,7 +124,7 @@
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

判断两个平面是否平行。

變數説明:

  • other: 另一个平面

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

説明: 判断两个平面是否平行。

返回: 是否平行

變數説明:

  • other: 另一个平面
源碼
python
def is_parallel(self, other: 'Plane3') -> bool:
     """
         判断两个平面是否平行。
         Args:
@@ -132,14 +132,14 @@
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

平面的法向量。

返回:

  • 法向量
源碼
python
@property
+    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

説明: 平面的法向量。

返回: 法向量

源碼
python
@property
 def normal(self) -> 'Vector3':
     """
         平面的法向量。
         Returns:
             法向量
         """
-    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

工厂函数 由点和法向量构造平面(点法式构造)。

變數説明:

  • point: 平面上的一点

  • normal: 法向量

返回:

  • 平面
源碼
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

説明: 工厂函数 由点和法向量构造平面(点法式构造)。

返回: 平面

變數説明:

  • point: 平面上的一点
  • normal: 法向量
源碼
python
@classmethod
 def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
     """
         工厂函数 由点和法向量构造平面(点法式构造)。
@@ -151,7 +151,7 @@
         """
     a, b, c = (normal.x, normal.y, normal.z)
     d = -a * point.x - b * point.y - c * point.z
-    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

工厂函数 由三点构造平面。

變數説明:

  • p1: 点1

  • p2: 点2

  • p3: 点3

返回:

  • 平面
源碼
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

説明: 工厂函数 由三点构造平面。

返回: 平面

變數説明:

  • p1: 点1
  • p2: 点2
  • p3: 点3
源碼
python
@classmethod
 def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
     """
         工厂函数 由三点构造平面。
@@ -165,7 +165,7 @@
     v1 = p2 - p1
     v2 = p3 - p1
     normal = v1.cross(v2)
-    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

工厂函数 由两直线构造平面。

變數説明:

  • l1: 直线1

  • l2: 直线2

返回:

  • 平面
源碼
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

説明: 工厂函数 由两直线构造平面。

返回: 平面

變數説明:

  • l1: 直线1
  • l2: 直线2
源碼
python
@classmethod
 def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
     """
         工厂函数 由两直线构造平面。
@@ -179,7 +179,7 @@
     v2 = l2.point - l1.point
     if v2 == zero_vector3:
         v2 = l2.get_point(1) - l1.point
-    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

工厂函数 由点和直线构造平面。

變數説明:

  • point: 面上一点

  • line: 面上直线,不包含点

返回:

  • 平面
源碼
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

説明: 工厂函数 由点和直线构造平面。

返回: 平面

變數説明:

  • point: 面上一点
  • line: 面上直线,不包含点
源碼
python
@classmethod
 def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
     """
         工厂函数 由点和直线构造平面。
@@ -189,11 +189,11 @@
         Returns:
             平面
         """
-    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源碼
python
@overload
+    return cls.from_point_and_normal(point, line.direction)

@overload

method __and__(self, other: Line3) -> Point3 | None

源碼
python
@overload
 def __and__(self, other: 'Line3') -> 'Point3 | None':
-    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源碼
python
@overload
+    ...

@overload

method __and__(self, other: Plane3) -> Line3 | None

源碼
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

取两平面的交集(人话:交线)

變數説明:

  • other:

返回:

  • 不平行平面的交线,平面平行返回None
源碼
python
def __and__(self, other):
+    ...

method __and__(self, other)

説明: 取两平面的交集(人话:交线)

返回: 不平行平面的交线,平面平行返回None

變數説明:

  • other:
源碼
python
def __and__(self, other):
     """
         取两平面的交集(人话:交线)
         Args:
@@ -210,10 +210,10 @@
             return None
         return self.cal_intersection_point3(other)
     else:
-        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源碼
python
def __eq__(self, other) -> bool:
-    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源碼
python
def __rand__(self, other: 'Line3') -> 'Point3':
+        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method __eq__(self, other) -> bool

源碼
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

method __rand__(self, other: Line3) -> Point3

源碼
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)
- + \ No newline at end of file diff --git a/zht/api/mp_math/point.html b/zht/api/mp_math/point.html index 7e10a1f..9c85ae2 100644 --- a/zht/api/mp_math/point.html +++ b/zht/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Point3

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

笛卡尔坐标系中的点。

變數説明:

  • x: x 坐标

  • y: y 坐标

  • z: z 坐标

源碼
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Point3

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

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

變數説明:

  • x: x 坐标
  • y: y 坐标
  • z: z 坐标
源碼
python
def __init__(self, x: float, y: float, z: float):
     """
         笛卡尔坐标系中的点。
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

變數説明:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

返回: 是否近似相等

變數説明:

  • other:
  • epsilon:
源碼
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
     """
         判断两个点是否近似相等。
         Args:
@@ -37,11 +37,11 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源碼
python
@overload
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

@overload

method self + other: Vector3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

P + V -> P P + P -> P

變數説明:

  • other:
源碼
python
def __add__(self, other):
+    ...

method self + other

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

變數説明:

  • other:
源碼
python
def __add__(self, other):
     """
         P + V -> P
         P + P -> P
@@ -49,14 +49,14 @@
             other:
         Returns:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

判断两个点是否相等。

變數説明:

  • other:
源碼
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

method __eq__(self, other)

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

變數説明:

  • other:
源碼
python
def __eq__(self, other):
     """
         判断两个点是否相等。
         Args:
             other:
         Returns:
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

P - P -> V

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

變數説明:

  • other:
源碼
python
def __sub__(self, other: 'Point3') -> 'Vector3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self - other: Point3 => Vector3

説明: P - P -> V

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

變數説明:

  • other:
源碼
python
def __sub__(self, other: 'Point3') -> 'Vector3':
     """
         P - P -> V
 
@@ -68,7 +68,7 @@
         """
     from .vector import Vector3
     return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
- + \ No newline at end of file diff --git a/zht/api/mp_math/segment.html b/zht/api/mp_math/segment.html index af1e2bc..7b55dd5 100644 --- a/zht/api/mp_math/segment.html +++ b/zht/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

三维空间中的线段。 :param p1: :param p2:

源碼
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

class Segment3

method __init__(self, p1: Point3, p2: Point3)

説明: 三维空间中的线段。 :param p1: :param p2:

源碼
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
     """
         三维空间中的线段。
         :param p1:
@@ -31,7 +31,7 @@
     self.length = self.direction.length
     '中心点'
     self.midpoint = Point3((self.p1.x + self.p2.x) / 2, (self.p1.y + self.p2.y) / 2, (self.p1.z + self.p2.z) / 2)
- + \ No newline at end of file diff --git a/zht/api/mp_math/utils.html b/zht/api/mp_math/utils.html index 1af571d..b5e20e5 100644 --- a/zht/api/mp_math/utils.html +++ b/zht/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

func clamp() -> float

区间限定函数

變數説明:

  • x: 待限定的值

  • min_: 最小值

  • max_: 最大值

返回:

  • 限制后的值
源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

func clamp() -> float

説明: 区间限定函数

返回: 限制后的值

變數説明:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值
源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,7 +28,7 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

變數説明:

  • x: 数1

  • y: 数2

  • epsilon: 误差

返回:

  • 是否近似相等
源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+    return max(min(x, max_), min_)

func approx(x: float = 0.0, y: float = APPROX) -> bool

説明: 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。

返回: 是否近似相等

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差
源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -38,7 +38,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

func sign(x: float = False) -> str

获取数的符号。

變數説明:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源碼
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

func sign(x: float = False) -> str

説明: 获取数的符号。

返回: 符号 + - ""

變數説明:

  • x: 数
  • only_neg: 是否只返回负数的符号
源碼
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -51,7 +51,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

func sign_format(x: float = False) -> str

格式化符号数 -1 -> -1 1 -> +1 0 -> ""

變數説明:

  • x: 数

  • only_neg: 是否只返回负数的符号

返回:

  • 符号 + - ""
源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

func sign_format(x: float = False) -> str

説明: 格式化符号数 -1 -> -1 1 -> +1 0 -> ""

返回: 符号 + - ""

變數説明:

  • x: 数
  • only_neg: 是否只返回负数的符号
源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -67,8 +67,8 @@
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''

class Approx

method __init__(self, value: RealNumber)

源碼
python
def __init__(self, value: RealNumber):
-    self.value = value

method __eq__(self, other)

源碼
python
def __eq__(self, other):
+        return ''

class Approx

method __init__(self, value: RealNumber)

源碼
python
def __init__(self, value: RealNumber):
+    self.value = value

method __eq__(self, other)

源碼
python
def __eq__(self, other):
     if isinstance(self.value, (float, int)):
         if isinstance(other, (float, int)):
             return abs(self.value - other) < APPROX
@@ -78,10 +78,10 @@
         if isinstance(other, (Vector3, Point3, Plane3, Line3)):
             return all([approx(self.value.x, other.x), approx(self.value.y, other.y), approx(self.value.z, other.z)])
         else:
-            self.raise_type_error(other)

method raise_type_error(self, other)

源碼
python
def raise_type_error(self, other):
-    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源碼
python
def __ne__(self, other):
+            self.raise_type_error(other)

method raise_type_error(self, other)

源碼
python
def raise_type_error(self, other):
+    raise TypeError(f'Unsupported type: {type(self.value)} and {type(other)}')

method __ne__(self, other)

源碼
python
def __ne__(self, other):
     return not self.__eq__(other)
- + \ No newline at end of file diff --git a/zht/api/mp_math/vector.html b/zht/api/mp_math/vector.html index 08f7f2b..e1cf350 100644 --- a/zht/api/mp_math/vector.html +++ b/zht/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

class Vector3

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

3维向量

變數説明:

  • x: x轴分量

  • y: y轴分量

  • z: z轴分量

源碼
python
def __init__(self, x: float, y: float, z: float):
+    
Skip to content

class Vector3

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

説明: 3维向量

變數説明:

  • x: x轴分量
  • y: y轴分量
  • z: z轴分量
源碼
python
def __init__(self, x: float, y: float, z: float):
     """
         3维向量
         Args:
@@ -27,7 +27,7 @@
         """
     self.x = x
     self.y = y
-    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似相等。

變數説明:

  • other:

  • epsilon:

返回:

  • 是否近似相等
源碼
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

method approx(self, other: Vector3, epsilon: float = APPROX) -> bool

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

返回: 是否近似相等

變數説明:

  • other:
  • epsilon:
源碼
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似相等。
         Args:
@@ -37,7 +37,7 @@
         Returns:
             是否近似相等
         """
-    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

计算两个向量之间的夹角。

變數説明:

  • other: 另一个向量

返回:

  • 夹角
源碼
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
+    return all([abs(self.x - other.x) < epsilon, abs(self.y - other.y) < epsilon, abs(self.z - other.z) < epsilon])

method cal_angle(self, other: Vector3) -> AnyAngle

説明: 计算两个向量之间的夹角。

返回: 夹角

變數説明:

  • other: 另一个向量
源碼
python
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
     """
         计算两个向量之间的夹角。
         Args:
@@ -45,7 +45,7 @@
         Returns:
             夹角
         """
-    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

變數説明:

  • other:

返回:

  • 行列式的结果
源碼
python
def cross(self, other: 'Vector3') -> 'Vector3':
+    return AnyAngle(math.acos(self @ other / (self.length * other.length)), is_radian=True)

method cross(self, other: Vector3) -> Vector3

説明: 向量积 叉乘:v1 cross v2 -> v3

叉乘为0,则两向量平行。 其余结果的模为平行四边形的面积。

返回: 行列式的结果

變數説明:

  • other:
源碼
python
def cross(self, other: 'Vector3') -> 'Vector3':
     """
         向量积 叉乘:v1 cross v2 -> v3
 
@@ -65,7 +65,7 @@
         Returns:
             行列式的结果
         """
-    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

判断两个向量是否近似平行。

變數説明:

  • other: 另一个向量

  • epsilon: 允许的误差

返回:

  • 是否近似平行
源碼
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    return Vector3(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

method is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool

説明: 判断两个向量是否近似平行。

返回: 是否近似平行

變數説明:

  • other: 另一个向量
  • epsilon: 允许的误差
源碼
python
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
     """
         判断两个向量是否近似平行。
         Args:
@@ -74,7 +74,7 @@
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

判断两个向量是否平行。

變數説明:

  • other: 另一个向量

返回:

  • 是否平行
源碼
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

method is_parallel(self, other: Vector3) -> bool

説明: 判断两个向量是否平行。

返回: 是否平行

變數説明:

  • other: 另一个向量
源碼
python
def is_parallel(self, other: 'Vector3') -> bool:
     """
         判断两个向量是否平行。
         Args:
@@ -82,7 +82,7 @@
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

将向量归一化。

自体归一化,不返回值。

源碼
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

method normalize(self)

説明: 将向量归一化。

自体归一化,不返回值。

源碼
python
def normalize(self):
     """
         将向量归一化。
 
@@ -91,32 +91,32 @@
     length = self.length
     self.x /= length
     self.y /= length
-    self.z /= length

@property

method np_array(self) -> np.ndarray

源碼
python
@property
+    self.z /= length

@property

method np_array(self) -> np.ndarray

源碼
python
@property
 def np_array(self) -> 'np.ndarray':
     """
         返回numpy数组
         Returns:
         """
-    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

向量的模。

返回:

源碼
python
@property
+    return np.array([self.x, self.y, self.z])

@property

method length(self) -> float

説明: 向量的模。

返回: 模

源碼
python
@property
 def length(self) -> float:
     """
         向量的模。
         Returns:
 
         """
-    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

获取该向量的单位向量。

返回:

  • 单位向量
源碼
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

method unit(self) -> Vector3

説明: 获取该向量的单位向量。

返回: 单位向量

源碼
python
@property
 def unit(self) -> 'Vector3':
     """
         获取该向量的单位向量。
         Returns:
             单位向量
         """
-    return self / self.length

method __abs__(self)

源碼
python
def __abs__(self):
-    return self.length

@overload

method self + other: Vector3 => Vector3

源碼
python
@overload
+    return self / self.length

method __abs__(self)

源碼
python
def __abs__(self):
+    return self.length

@overload

method self + other: Vector3 => Vector3

源碼
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self + other: Point3 => Point3

源碼
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

V + P -> P

V + V -> V

變數説明:

  • other:
源碼
python
def __add__(self, other):
+    ...

method self + other

説明: V + P -> P

V + V -> V

變數説明:

  • other:
源碼
python
def __add__(self, other):
     """
         V + P -> P
 
@@ -131,7 +131,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x + other.x, self.y + other.y, self.z + other.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

判断两个向量是否相等。

變數説明:

  • other:

返回:

  • 是否相等
源碼
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

method __eq__(self, other)

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

返回: 是否相等

變數説明:

  • other:
源碼
python
def __eq__(self, other):
     """
         判断两个向量是否相等。
         Args:
@@ -139,7 +139,7 @@
         Returns:
             是否相等
         """
-    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

P + V -> P

别去点那边实现了。 :param other: :return:

源碼
python
def __radd__(self, other: 'Point3') -> 'Point3':
+    return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z)

method self + other: Point3 => Point3

説明: P + V -> P

别去点那边实现了。 :param other: :return:

源碼
python
def __radd__(self, other: 'Point3') -> 'Point3':
     """
         P + V -> P
 
@@ -147,11 +147,11 @@
         :param other:
         :return:
         """
-    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源碼
python
@overload
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

@overload

method self - other: Vector3 => Vector3

源碼
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

method self - other: Point3 => Point3

源碼
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

V - P -> P

V - V -> V

變數説明:

  • other:
源碼
python
def __sub__(self, other):
+    ...

method self - other

説明: V - P -> P

V - V -> V

變數説明:

  • other:
源碼
python
def __sub__(self, other):
     """
         V - P -> P
 
@@ -165,7 +165,7 @@
     elif isinstance(other, Point3):
         return Point3(self.x - other.x, self.y - other.y, self.z - other.z)
     else:
-        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

P - V -> P

變數説明:

  • other:
源碼
python
def __rsub__(self, other: 'Point3'):
+        raise TypeError(f'unsupported operand type(s) for -: "Vector3" and "{type(other)}"')

method self - other: Point3

説明: P - V -> P

變數説明:

  • other:
源碼
python
def __rsub__(self, other: 'Point3'):
     """
         P - V -> P
         Args:
@@ -176,11 +176,11 @@
     if isinstance(other, Point3):
         return Point3(other.x - self.x, other.y - self.y, other.z - self.z)
     else:
-        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源碼
python
@overload
+        raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")

@overload

method self * other: Vector3 => Vector3

源碼
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
+    ...

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

method self * other: int | float | Vector3 => Vector3

数组运算 非点乘。点乘使用@,叉乘使用cross。

變數説明:

  • other:
源碼
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

method self * other: int | float | Vector3 => Vector3

説明: 数组运算 非点乘。点乘使用@,叉乘使用cross。

變數説明:

  • other:
源碼
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
     """
         数组运算 非点乘。点乘使用@,叉乘使用cross。
         Args:
@@ -193,18 +193,18 @@
     elif isinstance(other, (float, int)):
         return Vector3(self.x * other, self.y * other, self.z * other)
     else:
-        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源碼
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
-    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

点乘。

變數説明:

  • other:
源碼
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
+        raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")

method self * other: RealNumber => Vector3

源碼
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

method self @ other: Vector3 => RealNumber

説明: 点乘。

變數説明:

  • other:
源碼
python
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
     """
         点乘。
         Args:
             other:
         Returns:
         """
-    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源碼
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
-    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源碼
python
def __neg__(self):
+    return self.x * other.x + self.y * other.y + self.z * other.z

method self / other: RealNumber => Vector3

源碼
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

method - self

源碼
python
def __neg__(self):
     return Vector3(-self.x, -self.y, -self.z)

var zero_vector3 = Vector3(0, 0, 0)

  • 類型: Vector3

  • 説明: 零向量

var x_axis = Vector3(1, 0, 0)

  • 類型: Vector3

  • 説明: x轴单位向量

var y_axis = Vector3(0, 1, 0)

  • 類型: Vector3

  • 説明: y轴单位向量

var z_axis = Vector3(0, 0, 1)

  • 類型: Vector3

  • 説明: z轴单位向量

- + \ No newline at end of file diff --git a/zht/api/particle/index.html b/zht/api/particle/index.html index 702706e..a1fc62b 100644 --- a/zht/api/particle/index.html +++ b/zht/api/particle/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zht/api/presets/index.html b/zht/api/presets/index.html index 4896ac4..e46bfab 100644 --- a/zht/api/presets/index.html +++ b/zht/api/presets/index.html @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/zht/api/presets/model/index.html b/zht/api/presets/model/index.html index d916d8f..4edce2d 100644 --- a/zht/api/presets/model/index.html +++ b/zht/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

生成球体上的点集。

變數説明:

  • radius:

  • density:

返回:

  • List[Point3]: 球体上的点集。
源碼
python
@staticmethod
+    
Skip to content

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

説明: 生成球体上的点集。

返回: List[Point3]: 球体上的点集。

變數説明:

  • radius:
  • density:
源碼
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -35,7 +35,7 @@
     y_array = radius * np.sin(phi_list) * np.sin(theta_list)
     z_array = radius * np.cos(phi_list)
     return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
- + \ No newline at end of file