diff --git a/404.html b/404.html index 13d4be0..6e6b349 100644 --- a/404.html +++ b/404.html @@ -15,7 +15,7 @@
- + \ No newline at end of file diff --git a/api/index.html b/api/index.html index cffb79b..b8c878f 100644 --- a/api/index.html +++ b/api/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp

说明: 本模块塞了一些预设的粒子生成器

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

mbcp

说明: 本模块塞了一些预设的粒子生成器

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/api/mp_math/angle.html b/api/mp_math/angle.html index 8231900..ae4b06b 100644 --- a/api/mp_math/angle.html +++ b/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.angle

说明: 本模块定义了角度相关的类

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

mbcp.mp_math.angle

说明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

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

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

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

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def self / other: float => AnyAngle

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

@overload

method self / other: AnyAngle => float

源代码
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

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

method self / other

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

def self / other

源代码
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/const.html b/api/mp_math/const.html index 1d59785..493c095 100644 --- a/api/mp_math/const.html +++ b/api/mp_math/const.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.const

说明: 本模块定义了一些常用的常量

var PI = math.pi

  • 说明: 常量 π

var E = math.e

  • 说明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 说明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 说明: 欧拉常数

var EPSILON = 0.0001

  • 说明: 精度误差

var APPROX = 0.001

  • 说明: 约等于判定误差

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math.const

说明: 本模块定义了一些常用的常量

var PI = math.pi

  • 说明: 常量 π

var E = math.e

  • 说明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 说明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 说明: 欧拉常数

var EPSILON = 0.0001

  • 说明: 精度误差

var APPROX = 0.001

  • 说明: 约等于判定误差

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/api/mp_math/equation.html b/api/mp_math/equation.html index 522b9bb..db33f59 100644 --- a/api/mp_math/equation.html +++ b/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.equation

说明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+    
Skip to content

mbcp.mp_math.equation

说明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -27,7 +27,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:

返回: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:

返回: 目标点

源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -39,7 +39,7 @@
     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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

参数:

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

返回: 偏导函数

引发:

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

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

参数:

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

返回: 偏导函数

引发:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

说明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

参数:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源代码
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

说明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

参数:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源代码
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
@@ -97,7 +97,7 @@
         """@litedoc-hide"""
         return func(*args, *args2)
     return curried_func

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/function.html b/api/mp_math/function.html index 428cce7..7ba5e11 100644 --- a/api/mp_math/function.html +++ b/api/mp_math/function.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.function

说明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

说明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

参数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源代码
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    
Skip to content

mbcp.mp_math.function

说明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

说明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

参数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源代码
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
     """
     计算三元函数在某点的梯度向量。
     > [!tip]
@@ -34,7 +34,7 @@
     dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
     dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
     return Vector3(dx, dy, dz)

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/index.html b/api/mp_math/index.html index 37d6d9b..dee8923 100644 --- a/api/mp_math/index.html +++ b/api/mp_math/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math

说明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math

说明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/api/mp_math/line.html b/api/mp_math/line.html index 8599ff3..efbed45 100644 --- a/api/mp_math/line.html +++ b/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.line

说明: 本模块定义了三维空间中的直线类

class Line3

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

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

参数:

  • point: 直线上的一点
  • direction: 直线的方向向量
源代码
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

mbcp.mp_math.line

说明: 本模块定义了三维空间中的直线类

class Line3

def __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

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

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

def 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.')

def 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

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

def 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

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

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

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

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

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

def 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

def 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

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

def __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)

def __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)

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ 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 55660ca..7bf6888 100644 --- a/api/mp_math/mp_math_typing.html +++ b/api/mp_math/mp_math_typing.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.mp_math_typing

说明: 本模块用于内部类型提示

var RealNumber = int | float

  • 类型: TypeAlias

  • 说明: 实数

var Number = RealNumber | complex

  • 类型: TypeAlias

  • 说明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 说明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 说明: 数组变量

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

  • 说明: 多元函数

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math.mp_math_typing

说明: 本模块用于内部类型提示

var RealNumber = int | float

  • 类型: TypeAlias

  • 说明: 实数

var Number = RealNumber | complex

  • 类型: TypeAlias

  • 说明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 说明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 说明: 数组变量

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

  • 说明: 多元函数

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/api/mp_math/plane.html b/api/mp_math/plane.html index 9b51a98..db97c97 100644 --- a/api/mp_math/plane.html +++ b/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.plane

说明: 本模块定义了三维空间中的平面类

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

mbcp.mp_math.plane

说明: 本模块定义了三维空间中的平面类

class Plane3

def __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

def 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

def 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)}')

def 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)}')

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

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

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

def 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

def 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

def 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

def 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

def 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

def 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

def __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

def __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):
+    ...

def __and__(self, other)

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

参数:

  • other:

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

源代码
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)}'")

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)

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/point.html b/api/mp_math/point.html index bc74f54..1755b52 100644 --- a/api/mp_math/point.html +++ b/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.point

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

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

mbcp.mp_math.point

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

class Point3

def __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

def 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

def self + other: Vector3 => Point3

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

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

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

def __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)

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

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/segment.html b/api/mp_math/segment.html index 4ccd97f..10a2794 100644 --- a/api/mp_math/segment.html +++ b/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.segment

说明: 本模块定义了三维空间中的线段类

class Segment3

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

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

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

mbcp.mp_math.segment

说明: 本模块定义了三维空间中的线段类

class Segment3

def __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)

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/utils.html b/api/mp_math/utils.html index a698fa7..ad2f2cd 100644 --- a/api/mp_math/utils.html +++ b/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.utils

说明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> float

说明: 区间限定函数

参数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

源代码
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

mbcp.mp_math.utils

说明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

说明: 区间限定函数

参数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

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

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

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

def __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
@@ -39,9 +39,9 @@
         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)

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

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

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

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

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

说明: 获取数的符号。

参数:

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

返回: 符号 + - ""

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

def sign(x: float, only_neg: bool = False) -> str

说明: 获取数的符号。

参数:

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

返回: 符号 + - ""

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

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

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

参数:

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

返回: 符号 + - ""

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

def sign_format(x: float, only_neg: bool = 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
@@ -81,7 +81,7 @@
         return f'-{abs(x)}'
     else:
         return ''

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/mp_math/vector.html b/api/mp_math/vector.html index 42fc7fb..5402d2f 100644 --- a/api/mp_math/vector.html +++ b/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.vector

说明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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

mbcp.mp_math.vector

说明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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

def 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])

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

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

def 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

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

def 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

def 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

def 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

def 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

def __abs__(self)

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

@overload

def self + other: Vector3 => Vector3

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

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}'")

def __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)

def 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

def self - other: Vector3 => Vector3

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

@overload

method self - other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}"')

def 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

def self * other: Vector3 => Vector3

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

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
+    ...

@overload

def 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':
+    ...

def 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)}'")

def self * other: RealNumber => Vector3

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

def 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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/api/particle/index.html b/api/particle/index.html index 2478857..44eab28 100644 --- a/api/particle/index.html +++ b/api/particle/index.html @@ -17,8 +17,8 @@ - - + + \ No newline at end of file diff --git a/api/presets/index.html b/api/presets/index.html index acc2501..3fa76e6 100644 --- a/api/presets/index.html +++ b/api/presets/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.presets

说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.presets

说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/api/presets/model/index.html b/api/presets/model/index.html index f2e63e5..4a87dfc 100644 --- a/api/presets/model/index.html +++ b/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.presets.model

说明: 几何模型点集

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

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

参数:

  • radius:
  • density:

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

源代码
python
@staticmethod
+    
Skip to content

mbcp.presets.model

说明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

参数:

  • radius:
  • density:

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

源代码
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)]

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/assets/en_api_mp_math_angle.md.DI0aMl64.js b/assets/api_mp_math_angle.md.vKQLLqTS.js similarity index 56% rename from assets/en_api_mp_math_angle.md.DI0aMl64.js rename to assets/api_mp_math_angle.md.vKQLLqTS.js index f2fd506..31fd76e 100644 --- a/assets/en_api_mp_math_angle.md.DI0aMl64.js +++ b/assets/api_mp_math_angle.md.vKQLLqTS.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),t={name:"en/api/mp_math/angle.md"},e=n(`

mbcp.mp_math.angle

Description: 本模块定义了角度相关的类

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"zh/api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n(`

mbcp.mp_math.angle

说明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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.C94oF1kp.js";const c
     if is_radian:
         self.radian = value
     else:
-        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

Description: 余角:两角的和为90°。

Return: 余角

Source code
python
@property
+        self.radian = value * PI / 180

@property

def 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

Description: 补角:两角的和为180°。

Return: 补角

Source code
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

def 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

Description: 角度。

Return: 弧度

Source code
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

def degree(self) -> float

说明: 角度。

返回: 弧度

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

@property

method minimum_positive(self) -> AnyAngle

Description: 最小正角。

Return: 最小正角度

Source code
python
@property
+    return self.radian * 180 / PI

@property

def minimum_positive(self) -> AnyAngle

说明: 最小正角。

返回: 最小正角度

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

@property

method maximum_negative(self) -> AnyAngle

Description: 最大负角。

Return: 最大负角度

Source code
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

def 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

Description: 正弦值。

Return: 正弦值

Source code
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

def sin(self) -> float

说明: 正弦值。

返回: 正弦值

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

@property

method cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code
python
@property
+    return math.sin(self.radian)

@property

def cos(self) -> float

说明: 余弦值。

返回: 余弦值

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

@property

method tan(self) -> float

Description: 正切值。

Return: 正切值

Source code
python
@property
+    return math.cos(self.radian)

@property

def tan(self) -> float

说明: 正切值。

返回: 正切值

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

@property

method cot(self) -> float

Description: 余切值。

Return: 余切值

Source code
python
@property
+    return math.tan(self.radian)

@property

def cot(self) -> float

说明: 余切值。

返回: 余切值

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

@property

method sec(self) -> float

Description: 正割值。

Return: 正割值

Source code
python
@property
+    return 1 / math.tan(self.radian)

@property

def sec(self) -> float

说明: 正割值。

返回: 正割值

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

@property

method csc(self) -> float

Description: 余割值。

Return: 余割值

Source code
python
@property
+    return 1 / math.cos(self.radian)

@property

def csc(self) -> float

说明: 余割值。

返回: 余割值

源代码
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)

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

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

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def self / other: float => AnyAngle

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

@overload

method self / other: AnyAngle => float

Source code
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

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

method self / other

Source code
python
def __truediv__(self, other):
+    ...

def self / other

源代码
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,80),l=[e];function h(p,k,r,o,d,g){return a(),i("div",null,l)}const F=s(t,[["render",h]]);export{c as __pageData,F as default}; + return AnyAngle(self.radian / other, is_radian=True)
`,80),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}; diff --git a/assets/api_mp_math_angle.md.iDErkOWa.lean.js b/assets/api_mp_math_angle.md.vKQLLqTS.lean.js similarity index 86% rename from assets/api_mp_math_angle.md.iDErkOWa.lean.js rename to assets/api_mp_math_angle.md.vKQLLqTS.lean.js index d242364..9e9de3c 100644 --- a/assets/api_mp_math_angle.md.iDErkOWa.lean.js +++ b/assets/api_mp_math_angle.md.vKQLLqTS.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"zh/api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n("",80),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}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"zh/api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n("",80),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}; diff --git a/assets/ja_api_mp_math_equation.md.Bx4R1cWT.js b/assets/api_mp_math_equation.md.DpRfW_6Z.js similarity index 68% rename from assets/ja_api_mp_math_equation.md.Bx4R1cWT.js rename to assets/api_mp_math_equation.md.DpRfW_6Z.js index 26eeafe..c9e00a8 100644 --- a/assets/ja_api_mp_math_equation.md.Bx4R1cWT.js +++ b/assets/api_mp_math_equation.md.DpRfW_6Z.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"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(`

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"zh/api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n(`

mbcp.mp_math.equation

说明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:

戻り値: 目标点

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:

返回: 目标点

源代码
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -20,7 +20,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

引数:

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

戻り値: 偏导函数

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

参数:

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

返回: 偏导函数

引发:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

引数:

  • func: 函数
  • *args: 参数

戻り値: 柯里化后的函数

ソースコード
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

说明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

参数:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源代码
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
diff --git a/assets/api_mp_math_equation.md.Di7kIkyq.lean.js b/assets/api_mp_math_equation.md.DpRfW_6Z.lean.js
similarity index 100%
rename from assets/api_mp_math_equation.md.Di7kIkyq.lean.js
rename to assets/api_mp_math_equation.md.DpRfW_6Z.lean.js
diff --git a/assets/api_mp_math_function.md.Cj4FyaYl.js b/assets/api_mp_math_function.md.Cj4FyaYl.js
new file mode 100644
index 0000000..e994972
--- /dev/null
+++ b/assets/api_mp_math_function.md.Cj4FyaYl.js
@@ -0,0 +1,17 @@
+import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"api/mp_math/function.md","filePath":"zh/api/mp_math/function.md"}'),l={name:"api/mp_math/function.md"},n=a('

mbcp.mp_math.function

说明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

说明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

参数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源代码
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    """
+    计算三元函数在某点的梯度向量。
+    > [!tip]
+    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
+    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
+    Args:
+        func: 三元函数
+        p: 点
+        epsilon: 偏移量
+    Returns:
+        梯度
+    """
+    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
+    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
+    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
+    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/api_mp_math_function.md.roDde0nH.lean.js b/assets/api_mp_math_function.md.Cj4FyaYl.lean.js similarity index 94% rename from assets/api_mp_math_function.md.roDde0nH.lean.js rename to assets/api_mp_math_function.md.Cj4FyaYl.lean.js index c77d22b..9b33d81 100644 --- a/assets/api_mp_math_function.md.roDde0nH.lean.js +++ b/assets/api_mp_math_function.md.Cj4FyaYl.lean.js @@ -1 +1 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"api/mp_math/function.md","filePath":"zh/api/mp_math/function.md"}'),n={name:"api/mp_math/function.md"},l=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; +import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"api/mp_math/function.md","filePath":"zh/api/mp_math/function.md"}'),l={name:"api/mp_math/function.md"},n=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/api_mp_math_function.md.roDde0nH.js b/assets/api_mp_math_function.md.roDde0nH.js deleted file mode 100644 index 8437b8c..0000000 --- a/assets/api_mp_math_function.md.roDde0nH.js +++ /dev/null @@ -1,17 +0,0 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"api/mp_math/function.md","filePath":"zh/api/mp_math/function.md"}'),n={name:"api/mp_math/function.md"},l=a('

mbcp.mp_math.function

说明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

说明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

参数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源代码
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
-    """
-    计算三元函数在某点的梯度向量。
-    > [!tip]
-    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
-    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
-    Args:
-        func: 三元函数
-        p: 点
-        epsilon: 偏移量
-    Returns:
-        梯度
-    """
-    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
-    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
-    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
-    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/en_api_mp_math_line.md.BI7jrk5A.js b/assets/api_mp_math_line.md.DPWL9O-M.js similarity index 63% rename from assets/en_api_mp_math_line.md.BI7jrk5A.js rename to assets/api_mp_math_line.md.DPWL9O-M.js index 05b7bb9..c39f908 100644 --- a/assets/en_api_mp_math_line.md.BI7jrk5A.js +++ b/assets/api_mp_math_line.md.DPWL9O-M.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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(`

mbcp.mp_math.line

Description: 本模块定义了三维空间中的直线类

class Line3

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

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

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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"zh/api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n(`

mbcp.mp_math.line

说明: 本模块定义了三维空间中的直线类

class Line3

def __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.C94oF1kp.js";const E
             direction: 直线的方向向量
         """
     self.point = point
-    self.direction = direction

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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似相等

Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

def 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.C94oF1kp.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

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

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)

def 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.C94oF1kp.js";const E
         Raises:
             TypeError: 不支持的类型
         """
-    return self.direction.cal_angle(other.direction)

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

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

Arguments:

  • other: 平行直线或点

Return: 距离

Raises:

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

def 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.C94oF1kp.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

Description: 计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return: 交点

Raises:

  • ValueError 直线平行
  • ValueError 直线不共面
Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

def 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.C94oF1kp.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

Description: 计算直线经过指定点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

def 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.C94oF1kp.js";const E
         Returns:
             垂线
         """
-    return Line3(point, self.direction.cross(point - self.point))

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

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

Arguments:

  • t: 参数t

Return: 点

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

def 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.C94oF1kp.js";const E
         Returns:
 
         """
-    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]:
+    return self.point + t * self.direction

def 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

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

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)

def 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.C94oF1kp.js";const E
         Returns:
             是否近似平行
         """
-    return self.direction.is_approx_parallel(other.direction, epsilon)

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

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

Arguments:

  • other: 另一条直线

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

def 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.C94oF1kp.js";const E
         Returns:
             是否平行
         """
-    return self.direction.is_parallel(other.direction)

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

Description: 判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return: 是否共线

Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

def 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.C94oF1kp.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

Description: 判断点是否在直线上。

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)

def 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.C94oF1kp.js";const E
         Returns:
             是否在直线上
         """
-    return (point - self.point).is_parallel(self.direction)

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

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

Arguments:

  • other: 另一条直线

Return: 是否共面

Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

def 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.C94oF1kp.js";const E
         Returns:
             是否共面
         """
-    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):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

def 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.C94oF1kp.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

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

Arguments:

  • p1: 点1
  • p2: 点2

Return: 直线

Source code
python
@classmethod
+        self.point.z = 0

@classmethod

def 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.C94oF1kp.js";const E
             直线
         """
     direction = p2 - p1
-    return cls(p1, direction)

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

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

Arguments:

  • other: 另一条直线

Return: 交点

Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

def __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.C94oF1kp.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

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

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

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

def __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.C94oF1kp.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,107),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}; + return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_line.md.DbfheWE4.lean.js b/assets/api_mp_math_line.md.DPWL9O-M.lean.js similarity index 57% rename from assets/api_mp_math_line.md.DbfheWE4.lean.js rename to assets/api_mp_math_line.md.DPWL9O-M.lean.js index 5f010ab..29f45da 100644 --- a/assets/api_mp_math_line.md.DbfheWE4.lean.js +++ b/assets/api_mp_math_line.md.DPWL9O-M.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"zh/api/mp_math/line.md"}'),t={name:"api/mp_math/line.md"},l=n("",107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"zh/api/mp_math/line.md"}'),l={name:"api/mp_math/line.md"},t=n("",107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/en_api_mp_math_plane.md.C6JEigTz.js b/assets/api_mp_math_plane.md.DTAJAb0P.js similarity index 72% rename from assets/en_api_mp_math_plane.md.C6JEigTz.js rename to assets/api_mp_math_plane.md.DTAJAb0P.js index ca9c8b8..a3869df 100644 --- a/assets/en_api_mp_math_plane.md.C6JEigTz.js +++ b/assets/api_mp_math_plane.md.DTAJAb0P.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},t=n(`

mbcp.mp_math.plane

Description: 本模块定义了三维空间中的平面类

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"zh/api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

mbcp.mp_math.plane

说明: 本模块定义了三维空间中的平面类

class Plane3

def __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.C94oF1kp.js";const F
     self.a = a
     self.b = b
     self.c = c
-    self.d = d

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

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

Arguments:

  • other: 另一个平面

Return: 是否近似相等

Source code
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

def 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.C94oF1kp.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

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

Arguments:

  • other: 另一个平面

Return: 夹角弧度

Raises:

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

def 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.C94oF1kp.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

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

Arguments:

  • other: 另一个平面或点

Return: 距离

Raises:

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

def 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.C94oF1kp.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

Description: 计算两平面的交线。

Arguments:

  • other: 另一个平面

Return: 两平面的交线

Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

def 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.C94oF1kp.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

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

Arguments:

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

Return: 交点

Raises:

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

def 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.C94oF1kp.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

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

Arguments:

  • point: 指定点

Return: 所求平面

Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

def 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.C94oF1kp.js";const F
         Returns:
             所求平面
         """
-    return Plane3.from_point_and_normal(point, self.normal)

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

Description: 判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

def 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.C94oF1kp.js";const F
         Returns:
             是否平行
         """
-    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

Description: 平面的法向量。

Return: 法向量

Source code
python
@property
+    return self.normal.is_parallel(other.normal)

@property

def 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

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

Arguments:

  • point: 平面上的一点
  • normal: 法向量

Return: 平面

Source code
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

def 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.C94oF1kp.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

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

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3

Return: 平面

Source code
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

def 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.C94oF1kp.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

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

Arguments:

  • l1: 直线1
  • l2: 直线2

Return: 平面

Source code
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

def 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.C94oF1kp.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

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

Arguments:

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

Return: 平面

Source code
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

def 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.C94oF1kp.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

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

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

@overload

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

Source code
python
@overload
+    ...

@overload

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

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

method __and__(self, other)

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

Arguments:

  • other:

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

Source code
python
def __and__(self, other):
+    ...

def __and__(self, other)

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

参数:

  • other:

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

源代码
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.C94oF1kp.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)
`,105),h=[t];function p(e,k,r,d,o,E){return a(),i("div",null,h)}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)}'")

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)
`,105),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.DLuC3Mxh.lean.js b/assets/api_mp_math_plane.md.DTAJAb0P.lean.js similarity index 100% rename from assets/api_mp_math_plane.md.DLuC3Mxh.lean.js rename to assets/api_mp_math_plane.md.DTAJAb0P.lean.js diff --git a/assets/api_mp_math_point.md.DAQFtNol.js b/assets/api_mp_math_point.md.vtgIded6.js similarity index 64% rename from assets/api_mp_math_point.md.DAQFtNol.js rename to assets/api_mp_math_point.md.vtgIded6.js index 8d71459..0929386 100644 --- a/assets/api_mp_math_point.md.DAQFtNol.js +++ b/assets/api_mp_math_point.md.vtgIded6.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"zh/api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},h=t(`

mbcp.mp_math.point

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

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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"zh/api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},l=t(`

mbcp.mp_math.point

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

class Point3

def __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.C94oF1kp.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

def 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.C94oF1kp.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

def self + other: Vector3 => Point3

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

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)

def __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)

def 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.C94oF1kp.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),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)
`,36),h=[l];function e(p,k,r,o,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.DAQFtNol.lean.js b/assets/api_mp_math_point.md.vtgIded6.lean.js similarity index 72% rename from assets/api_mp_math_point.md.DAQFtNol.lean.js rename to assets/api_mp_math_point.md.vtgIded6.lean.js index 0322ca7..f1c7b94 100644 --- a/assets/api_mp_math_point.md.DAQFtNol.lean.js +++ b/assets/api_mp_math_point.md.vtgIded6.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"zh/api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},h=t("",36),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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"api/mp_math/point.md","filePath":"zh/api/mp_math/point.md"}'),n={name:"api/mp_math/point.md"},l=t("",36),h=[l];function e(p,k,r,o,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.CQz_FDoI.js b/assets/api_mp_math_segment.md.D-8aRB8W.js similarity index 77% rename from assets/api_mp_math_segment.md.CQz_FDoI.js rename to assets/api_mp_math_segment.md.D-8aRB8W.js index 69e900d..858fe2f 100644 --- a/assets/api_mp_math_segment.md.CQz_FDoI.js +++ b/assets/api_mp_math_segment.md.D-8aRB8W.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"zh/api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n(`

mbcp.mp_math.segment

说明: 本模块定义了三维空间中的线段类

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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"zh/api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},p=n(`

mbcp.mp_math.segment

说明: 本模块定义了三维空间中的线段类

class Segment3

def __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.C94oF1kp.js";const F
     '长度'
     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)
`,6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F 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)
`,6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_segment.md.CQz_FDoI.lean.js b/assets/api_mp_math_segment.md.D-8aRB8W.lean.js similarity index 58% rename from assets/api_mp_math_segment.md.CQz_FDoI.lean.js rename to assets/api_mp_math_segment.md.D-8aRB8W.lean.js index a3483a7..411b9f3 100644 --- a/assets/api_mp_math_segment.md.CQz_FDoI.lean.js +++ b/assets/api_mp_math_segment.md.D-8aRB8W.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"zh/api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},h=n("",6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"api/mp_math/segment.md","filePath":"zh/api/mp_math/segment.md"}'),t={name:"api/mp_math/segment.md"},p=n("",6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/api_mp_math_utils.md.C2moaW8N.js b/assets/api_mp_math_utils.md.DaaoR634.js similarity index 63% rename from assets/api_mp_math_utils.md.C2moaW8N.js rename to assets/api_mp_math_utils.md.DaaoR634.js index 52e1927..515a6f5 100644 --- a/assets/api_mp_math_utils.md.C2moaW8N.js +++ b/assets/api_mp_math_utils.md.DaaoR634.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"zh/api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n(`

mbcp.mp_math.utils

说明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> 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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"zh/api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n(`

mbcp.mp_math.utils

说明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

说明: 区间限定函数

参数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

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

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

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

def __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
@@ -20,9 +20,9 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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)

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

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

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

源代码
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

参数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

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

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

说明: 获取数的符号。

参数:

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

返回: 符号 + - ""

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

def sign(x: float, only_neg: bool = False) -> str

说明: 获取数的符号。

参数:

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

返回: 符号 + - ""

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

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

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

参数:

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

返回: 符号 + - ""

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

def sign_format(x: float, only_neg: bool = 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
@@ -61,4 +61,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''
`,35),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 ''
`,35),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}; diff --git a/assets/api_mp_math_utils.md.C2moaW8N.lean.js b/assets/api_mp_math_utils.md.DaaoR634.lean.js similarity index 86% rename from assets/api_mp_math_utils.md.C2moaW8N.lean.js rename to assets/api_mp_math_utils.md.DaaoR634.lean.js index 8ce45d9..aa06c91 100644 --- a/assets/api_mp_math_utils.md.C2moaW8N.lean.js +++ b/assets/api_mp_math_utils.md.DaaoR634.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"zh/api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n("",35),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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"api/mp_math/utils.md","filePath":"zh/api/mp_math/utils.md"}'),l={name:"api/mp_math/utils.md"},t=n("",35),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}; diff --git a/assets/ja_api_mp_math_vector.md.BIkkuu3D.js b/assets/api_mp_math_vector.md.BTnPeAKR.js similarity index 64% rename from assets/ja_api_mp_math_vector.md.BIkkuu3D.js rename to assets/api_mp_math_vector.md.BTnPeAKR.js index 92128df..a376927 100644 --- a/assets/ja_api_mp_math_vector.md.BIkkuu3D.js +++ b/assets/api_mp_math_vector.md.BTnPeAKR.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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(`

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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 n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"zh/api/mp_math/vector.md"}'),t={name:"api/mp_math/vector.md"},l=n(`

mbcp.mp_math.vector

说明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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.C94oF1kp.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

def 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.C94oF1kp.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])

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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

def 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

def 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

def __abs__(self)

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

@overload

def self + other: Vector3 => Vector3

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

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}'")

def __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.C94oF1kp.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)

def 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.C94oF1kp.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

def self - other: Vector3 => Vector3

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

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}"')

def 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.C94oF1kp.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

def self * other: Vector3 => Vector3

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

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
+    ...

@overload

def 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':
+    ...

def 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.C94oF1kp.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)}'")

def self * other: RealNumber => Vector3

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

def 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轴单位向量

`,127),l=[h];function e(p,k,r,o,d,g){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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

`,127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.BTnPeAKR.lean.js b/assets/api_mp_math_vector.md.BTnPeAKR.lean.js new file mode 100644 index 0000000..43fec61 --- /dev/null +++ b/assets/api_mp_math_vector.md.BTnPeAKR.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"zh/api/mp_math/vector.md"}'),t={name:"api/mp_math/vector.md"},l=n("",127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/api_mp_math_vector.md.BiNus8y5.lean.js b/assets/api_mp_math_vector.md.BiNus8y5.lean.js deleted file mode 100644 index e586017..0000000 --- a/assets/api_mp_math_vector.md.BiNus8y5.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"zh/api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t("",127),l=[h];function e(p,k,r,o,d,g){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.CJMO-ffZ.js b/assets/api_presets_model_index.md.gO0Notp6.js similarity index 84% rename from assets/api_presets_model_index.md.CJMO-ffZ.js rename to assets/api_presets_model_index.md.gO0Notp6.js index 11bb8bb..6293b88 100644 --- a/assets/api_presets_model_index.md.CJMO-ffZ.js +++ b/assets/api_presets_model_index.md.gO0Notp6.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"zh/api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n(`

mbcp.presets.model

说明: 几何模型点集

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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"zh/api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n(`

mbcp.presets.model

说明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

参数:

  • radius:
  • density:

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

源代码
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.C94oF1kp.js";const y
     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)]
`,10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/api_presets_model_index.md.CJMO-ffZ.lean.js b/assets/api_presets_model_index.md.gO0Notp6.lean.js similarity index 64% rename from assets/api_presets_model_index.md.CJMO-ffZ.lean.js rename to assets/api_presets_model_index.md.gO0Notp6.lean.js index 1c76908..fdc554c 100644 --- a/assets/api_presets_model_index.md.CJMO-ffZ.lean.js +++ b/assets/api_presets_model_index.md.gO0Notp6.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"zh/api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n("",10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"api/presets/model/index.md","filePath":"zh/api/presets/model/index.md"}'),t={name:"api/presets/model/index.md"},h=n("",10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/api_mp_math_angle.md.iDErkOWa.js b/assets/en_api_mp_math_angle.md.Bu07wjnV.js similarity index 61% rename from assets/api_mp_math_angle.md.iDErkOWa.js rename to assets/en_api_mp_math_angle.md.Bu07wjnV.js index 51df1f0..3965a1b 100644 --- a/assets/api_mp_math_angle.md.iDErkOWa.js +++ b/assets/en_api_mp_math_angle.md.Bu07wjnV.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"zh/api/mp_math/angle.md"}'),t={name:"api/mp_math/angle.md"},e=n(`

mbcp.mp_math.angle

说明: 本模块定义了角度相关的类

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.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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(`

mbcp.mp_math.angle

Description: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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.C94oF1kp.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

def 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°。

返回: 补角

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

@property

def 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

说明: 角度。

返回: 弧度

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

@property

def 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

说明: 最小正角。

返回: 最小正角度

源代码
python
@property
+    return self.radian * 180 / PI

@property

def 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

说明: 最大负角。

返回: 最大负角度

源代码
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

def 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

说明: 正弦值。

返回: 正弦值

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

@property

def sin(self) -> float

Description: 正弦值。

Return: 正弦值

Source code
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

def cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code
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

def tan(self) -> float

Description: 正切值。

Return: 正切值

Source code
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

def 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

说明: 正割值。

返回: 正割值

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

@property

def 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

说明: 余割值。

返回: 余割值

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

@property

def 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

源代码
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)

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def self / other: float => AnyAngle

Source code
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源代码
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

Source code
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

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

def 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)
`,80),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}; + return AnyAngle(self.radian / other, is_radian=True)
`,80),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.DI0aMl64.lean.js b/assets/en_api_mp_math_angle.md.Bu07wjnV.lean.js similarity index 58% rename from assets/en_api_mp_math_angle.md.DI0aMl64.lean.js rename to assets/en_api_mp_math_angle.md.Bu07wjnV.lean.js index 1a9c359..b67133d 100644 --- a/assets/en_api_mp_math_angle.md.DI0aMl64.lean.js +++ b/assets/en_api_mp_math_angle.md.Bu07wjnV.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"headers":[],"relativePath":"en/api/mp_math/angle.md","filePath":"en/api/mp_math/angle.md"}'),t={name:"en/api/mp_math/angle.md"},e=n("",80),l=[e];function h(p,k,r,o,d,g){return a(),i("div",null,l)}const F=s(t,[["render",h]]);export{c as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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("",80),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.CFa2gNNX.js b/assets/en_api_mp_math_equation.md.DqlD6s-6.js similarity index 71% rename from assets/en_api_mp_math_equation.md.CFa2gNNX.js rename to assets/en_api_mp_math_equation.md.DqlD6s-6.js index 5a4e5e5..e6a66b1 100644 --- a/assets/en_api_mp_math_equation.md.CFa2gNNX.js +++ b/assets/en_api_mp_math_equation.md.DqlD6s-6.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),t={name:"en/api/mp_math/equation.md"},l=n(`

mbcp.mp_math.equation

Description: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"en/api/mp_math/equation.md","filePath":"en/api/mp_math/equation.md"}'),t={name:"en/api/mp_math/equation.md"},l=n(`

mbcp.mp_math.equation

Description: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:

Return: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:

Return: 目标点

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -20,7 +20,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

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:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

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:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     > [!warning]
@@ -62,7 +62,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

Description: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

Arguments:

  • func: 函数
  • *args: 参数

Return: 柯里化后的函数

Source code
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

Description: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

Arguments:

  • func: 函数
  • *args: 参数

Return: 柯里化后的函数

Source code
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
diff --git a/assets/en_api_mp_math_equation.md.CFa2gNNX.lean.js b/assets/en_api_mp_math_equation.md.DqlD6s-6.lean.js
similarity index 100%
rename from assets/en_api_mp_math_equation.md.CFa2gNNX.lean.js
rename to assets/en_api_mp_math_equation.md.DqlD6s-6.lean.js
diff --git a/assets/en_api_mp_math_function.md.Bgn-YygZ.js b/assets/en_api_mp_math_function.md.Bgn-YygZ.js
new file mode 100644
index 0000000..af447d5
--- /dev/null
+++ b/assets/en_api_mp_math_function.md.Bgn-YygZ.js
@@ -0,0 +1,17 @@
+import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"en/api/mp_math/function.md","filePath":"en/api/mp_math/function.md"}'),n={name:"en/api/mp_math/function.md"},l=a('

mbcp.mp_math.function

Description: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

Description: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

Arguments:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

Return: 梯度

Source code
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    """
+    计算三元函数在某点的梯度向量。
+    > [!tip]
+    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
+    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
+    Args:
+        func: 三元函数
+        p: 点
+        epsilon: 偏移量
+    Returns:
+        梯度
+    """
+    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
+    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
+    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
+    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/en_api_mp_math_function.md.D5HNykIX.lean.js b/assets/en_api_mp_math_function.md.Bgn-YygZ.lean.js similarity index 100% rename from assets/en_api_mp_math_function.md.D5HNykIX.lean.js rename to assets/en_api_mp_math_function.md.Bgn-YygZ.lean.js diff --git a/assets/en_api_mp_math_function.md.D5HNykIX.js b/assets/en_api_mp_math_function.md.D5HNykIX.js deleted file mode 100644 index e1fab56..0000000 --- a/assets/en_api_mp_math_function.md.D5HNykIX.js +++ /dev/null @@ -1,17 +0,0 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"en/api/mp_math/function.md","filePath":"en/api/mp_math/function.md"}'),n={name:"en/api/mp_math/function.md"},l=a('

mbcp.mp_math.function

Description: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

Description: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

Arguments:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

Return: 梯度

Source code
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
-    """
-    计算三元函数在某点的梯度向量。
-    > [!tip]
-    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
-    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
-    Args:
-        func: 三元函数
-        p: 点
-        epsilon: 偏移量
-    Returns:
-        梯度
-    """
-    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
-    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
-    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
-    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/ja_api_mp_math_line.md.CUb8HcBw.js b/assets/en_api_mp_math_line.md.BGq09mco.js similarity index 61% rename from assets/ja_api_mp_math_line.md.CUb8HcBw.js rename to assets/en_api_mp_math_line.md.BGq09mco.js index 281c949..c6d7568 100644 --- a/assets/ja_api_mp_math_line.md.CUb8HcBw.js +++ b/assets/en_api_mp_math_line.md.BGq09mco.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),t={name:"ja/api/mp_math/line.md"},l=n(`

mbcp.mp_math.line

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

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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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(`

mbcp.mp_math.line

Description: 本模块定义了三维空间中的直线类

class Line3

def __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.C94oF1kp.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

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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似相等

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.C94oF1kp.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)

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

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

Arguments:

  • other: 另一条直线

Return: 夹角弧度

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.C94oF1kp.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)

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

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

Arguments:

  • other: 平行直线或点

Return: 距离

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.C94oF1kp.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.')

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

Description: 计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return: 交点

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.C94oF1kp.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

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

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

Arguments:

  • point: 指定点

Return: 垂线

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.C94oF1kp.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))

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

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

Arguments:

  • t: 参数t

Return: 点

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.C94oF1kp.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

def 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

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

引数:

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

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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似平行

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.C94oF1kp.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)

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

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

Arguments:

  • other: 另一条直线

Return: 是否平行

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.C94oF1kp.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)

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

Description: 判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return: 是否共线

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.C94oF1kp.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)

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

Description: 判断点是否在直线上。

Arguments:

  • point: 点

Return: 是否在直线上

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.C94oF1kp.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)

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

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

Arguments:

  • other: 另一条直线

Return: 是否共面

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.C94oF1kp.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

def 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.C94oF1kp.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

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

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

Arguments:

  • p1: 点1
  • p2: 点2

Return: 直线

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.C94oF1kp.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)

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

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

Arguments:

  • other: 另一条直线

Return: 交点

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.C94oF1kp.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)

def __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.C94oF1kp.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["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)
`,107),e=[t];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(l,[["render",p]]);export{E as __pageData,c as default}; diff --git a/assets/en_api_mp_math_line.md.BI7jrk5A.lean.js b/assets/en_api_mp_math_line.md.BGq09mco.lean.js similarity index 58% rename from assets/en_api_mp_math_line.md.BI7jrk5A.lean.js rename to assets/en_api_mp_math_line.md.BGq09mco.lean.js index 57a3677..9841c6a 100644 --- a/assets/en_api_mp_math_line.md.BI7jrk5A.lean.js +++ b/assets/en_api_mp_math_line.md.BGq09mco.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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("",107),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}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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("",107),e=[t];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(l,[["render",p]]);export{E as __pageData,c as default}; diff --git a/assets/ja_api_mp_math_plane.md.CzPHp-i-.js b/assets/en_api_mp_math_plane.md.C3KPGKE4.js similarity index 72% rename from assets/ja_api_mp_math_plane.md.CzPHp-i-.js rename to assets/en_api_mp_math_plane.md.C3KPGKE4.js index 161ca85..5a2f8ed 100644 --- a/assets/ja_api_mp_math_plane.md.CzPHp-i-.js +++ b/assets/en_api_mp_math_plane.md.C3KPGKE4.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"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(`

mbcp.mp_math.plane

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

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},t=n(`

mbcp.mp_math.plane

Description: 本模块定义了三维空间中的平面类

class Plane3

def __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.C94oF1kp.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

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

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

Arguments:

  • other: 另一个平面

Return: 是否近似相等

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.C94oF1kp.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

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

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

Arguments:

  • other: 另一个平面

Return: 夹角弧度

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.C94oF1kp.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)}')

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

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

Arguments:

  • other: 另一个平面或点

Return: 距离

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.C94oF1kp.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)}')

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

Description: 计算两平面的交线。

Arguments:

  • other: 另一个平面

Return: 两平面的交线

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.C94oF1kp.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)

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

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

Arguments:

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

Return: 交点

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.C94oF1kp.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))

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

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

Arguments:

  • point: 指定点

Return: 所求平面

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.C94oF1kp.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)

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

Description: 判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return: 是否平行

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.C94oF1kp.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

def 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

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

引数:

  • point: 平面上的一点
  • normal: 法向量

戻り値: 平面

ソースコード
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

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

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

Arguments:

  • point: 平面上的一点
  • normal: 法向量

Return: 平面

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.C94oF1kp.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

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

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

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3

Return: 平面

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.C94oF1kp.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

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

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

Arguments:

  • l1: 直线1
  • l2: 直线2

Return: 平面

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.C94oF1kp.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

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

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

Arguments:

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

Return: 平面

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.C94oF1kp.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

def __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

ソースコード
python
@overload
+    ...

@overload

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

Source code
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

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

引数:

  • other:

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

ソースコード
python
def __and__(self, other):
+    ...

def __and__(self, other)

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

Arguments:

  • other:

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

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.C94oF1kp.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)
`,105),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)}'")

def __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

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

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
+    return self.cal_intersection_point3(other)
`,105),h=[t];function p(k,e,r,d,E,o){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_plane.md.C6JEigTz.lean.js b/assets/en_api_mp_math_plane.md.C3KPGKE4.lean.js similarity index 86% rename from assets/en_api_mp_math_plane.md.C6JEigTz.lean.js rename to assets/en_api_mp_math_plane.md.C3KPGKE4.lean.js index 921f178..7a6f73a 100644 --- a/assets/en_api_mp_math_plane.md.C6JEigTz.lean.js +++ b/assets/en_api_mp_math_plane.md.C3KPGKE4.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},t=n("",105),h=[t];function p(e,k,r,d,o,E){return a(),i("div",null,h)}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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"en/api/mp_math/plane.md","filePath":"en/api/mp_math/plane.md"}'),l={name:"en/api/mp_math/plane.md"},t=n("",105),h=[t];function p(k,e,r,d,E,o){return a(),i("div",null,h)}const y=s(l,[["render",p]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_point.md.DgKVopYL.js b/assets/en_api_mp_math_point.md.D7ZdR7VM.js similarity index 63% rename from assets/en_api_mp_math_point.md.DgKVopYL.js rename to assets/en_api_mp_math_point.md.D7ZdR7VM.js index 1a81585..60064a4 100644 --- a/assets/en_api_mp_math_point.md.DgKVopYL.js +++ b/assets/en_api_mp_math_point.md.D7ZdR7VM.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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(`

mbcp.mp_math.point

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

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):
+import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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(`

mbcp.mp_math.point

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

class Point3

def __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.C94oF1kp.js";const c
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

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.C94oF1kp.js";const c
         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

def 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

def self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

Description: P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

def 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.C94oF1kp.js";const c
             other:
         Returns:
         """
-    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):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

def __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

Description: 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)

def 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.C94oF1kp.js";const c
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const y=s(n,[["render",e]]);export{c as __pageData,y as default}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),e=[l];function h(p,k,o,r,d,E){return a(),i("div",null,e)}const c=s(n,[["render",h]]);export{y as __pageData,c as default}; diff --git a/assets/en_api_mp_math_point.md.DgKVopYL.lean.js b/assets/en_api_mp_math_point.md.D7ZdR7VM.lean.js similarity index 55% rename from assets/en_api_mp_math_point.md.DgKVopYL.lean.js rename to assets/en_api_mp_math_point.md.D7ZdR7VM.lean.js index 1b6dad3..8b54859 100644 --- a/assets/en_api_mp_math_point.md.DgKVopYL.lean.js +++ b/assets/en_api_mp_math_point.md.D7ZdR7VM.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const c=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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("",36),h=[l];function e(p,k,o,r,d,E){return a(),i("div",null,h)}const y=s(n,[["render",e]]);export{c as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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("",36),e=[l];function h(p,k,o,r,d,E){return a(),i("div",null,e)}const c=s(n,[["render",h]]);export{y as __pageData,c as default}; diff --git a/assets/zht_api_mp_math_segment.md.BZQVMFnu.js b/assets/en_api_mp_math_segment.md.DMW-YUfw.js similarity index 81% rename from assets/zht_api_mp_math_segment.md.BZQVMFnu.js rename to assets/en_api_mp_math_segment.md.DMW-YUfw.js index d4c23d6..bc304eb 100644 --- a/assets/zht_api_mp_math_segment.md.BZQVMFnu.js +++ b/assets/en_api_mp_math_segment.md.DMW-YUfw.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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(`

mbcp.mp_math.segment

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

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},p=n(`

mbcp.mp_math.segment

Description: 本模块定义了三维空间中的线段类

class Segment3

def __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.C94oF1kp.js";const F
     '长度'
     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)
`,6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F 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)
`,6),h=[p];function e(l,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_segment.md.GweOoNT9.lean.js b/assets/en_api_mp_math_segment.md.DMW-YUfw.lean.js similarity index 72% rename from assets/en_api_mp_math_segment.md.GweOoNT9.lean.js rename to assets/en_api_mp_math_segment.md.DMW-YUfw.lean.js index cfa19a5..0053b23 100644 --- a/assets/en_api_mp_math_segment.md.GweOoNT9.lean.js +++ b/assets/en_api_mp_math_segment.md.DMW-YUfw.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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("",6),p=[h];function e(l,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",e]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"en/api/mp_math/segment.md","filePath":"en/api/mp_math/segment.md"}'),t={name:"en/api/mp_math/segment.md"},p=n("",6),h=[p];function e(l,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{F as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.VHDSe3i2.js b/assets/en_api_mp_math_utils.md.B3i5gz_2.js similarity index 61% rename from assets/en_api_mp_math_utils.md.VHDSe3i2.js rename to assets/en_api_mp_math_utils.md.B3i5gz_2.js index 8b7cd19..1bf53b6 100644 --- a/assets/en_api_mp_math_utils.md.VHDSe3i2.js +++ b/assets/en_api_mp_math_utils.md.B3i5gz_2.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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(`

mbcp.mp_math.utils

Description: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> float

Description: 区间限定函数

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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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(`

mbcp.mp_math.utils

Description: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

Description: 区间限定函数

Arguments:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

Return: 限制后的值

Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,8 +9,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value

def __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
@@ -20,9 +20,9 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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)

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

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

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差

Return: 是否近似相等

Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            self.raise_type_error(other)

def 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)}')

def __ne__(self, other)

Source code
python
def __ne__(self, other):
+    return not self.__eq__(other)

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

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

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差

Return: 是否近似相等

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

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

Description: 获取数的符号。

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

Description: 获取数的符号。

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -45,7 +45,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

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

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

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = False) -> str

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

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -61,4 +61,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''
`,35),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; + return ''
`,35),h=[t];function e(p,k,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/en_api_mp_math_utils.md.VHDSe3i2.lean.js b/assets/en_api_mp_math_utils.md.B3i5gz_2.lean.js similarity index 58% rename from assets/en_api_mp_math_utils.md.VHDSe3i2.lean.js rename to assets/en_api_mp_math_utils.md.B3i5gz_2.lean.js index d52826c..d363c07 100644 --- a/assets/en_api_mp_math_utils.md.VHDSe3i2.lean.js +++ b/assets/en_api_mp_math_utils.md.B3i5gz_2.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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("",35),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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("",35),h=[t];function e(p,k,r,d,o,g){return a(),i("div",null,h)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/en_api_mp_math_vector.md.BlzUS0V3.lean.js b/assets/en_api_mp_math_vector.md.BlzUS0V3.lean.js deleted file mode 100644 index 960c528..0000000 --- a/assets/en_api_mp_math_vector.md.BlzUS0V3.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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("",127),e=[h];function l(p,k,r,o,d,g){return a(),i("div",null,e)}const c=s(n,[["render",l]]);export{y as __pageData,c as default}; diff --git a/assets/en_api_mp_math_vector.md.BlzUS0V3.js b/assets/en_api_mp_math_vector.md.CgtIoM4A.js similarity index 65% rename from assets/en_api_mp_math_vector.md.BlzUS0V3.js rename to assets/en_api_mp_math_vector.md.CgtIoM4A.js index be30ddf..a4afb99 100644 --- a/assets/en_api_mp_math_vector.md.BlzUS0V3.js +++ b/assets/en_api_mp_math_vector.md.CgtIoM4A.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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(`

mbcp.mp_math.vector

Description: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),t={name:"en/api/mp_math/vector.md"},e=n(`

mbcp.mp_math.vector

Description: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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.C94oF1kp.js";const y
         """
     self.x = x
     self.y = y
-    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

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.C94oF1kp.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

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

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

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

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

Arguments:

  • other: 另一个向量

Return: 夹角

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.C94oF1kp.js";const y
         Returns:
             夹角
         """
-    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,则两向量平行。 其余结果的模为平行四边形的面积。

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)

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

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

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

Arguments:

  • other:

Return: 行列式的结果

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.C94oF1kp.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

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

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)

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

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

Arguments:

  • other: 另一个向量
  • epsilon: 允许的误差

Return: 是否近似平行

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.C94oF1kp.js";const y
         Returns:
             是否近似平行
         """
-    return self.cross(other).length < epsilon

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

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

Arguments:

  • other: 另一个向量

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

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

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

Arguments:

  • other: 另一个向量

Return: 是否平行

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.C94oF1kp.js";const y
         Returns:
             是否平行
         """
-    return self.cross(other).approx(zero_vector3)

method normalize(self)

Description: 将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

def 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.C94oF1kp.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

def 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

Description: 向量的模。

Return: 模

Source code
python
@property
+    return np.array([self.x, self.y, self.z])

@property

def 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

Description: 获取该向量的单位向量。

Return: 单位向量

Source code
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

def 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

def __abs__(self)

Source code
python
def __abs__(self):
+    return self.length

@overload

def 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

def self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

Description: V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

def 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.C94oF1kp.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)

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

Arguments:

  • other:

Return: 是否相等

Source code
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

def __eq__(self, other)

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

Arguments:

  • other:

Return: 是否相等

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.C94oF1kp.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

Description: 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)

def 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.C94oF1kp.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

def 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

def self - other: Point3 => Point3

Source code
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

Description: V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
+    ...

def 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.C94oF1kp.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

Description: 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)}"')

def 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.C94oF1kp.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

def 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

def self * other: RealNumber => Vector3

Source code
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

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

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

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

def 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.C94oF1kp.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

Description: 点乘。

Arguments:

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

def self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

def 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轴单位向量

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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

`,127),l=[e];function h(p,k,r,o,d,g){return a(),i("div",null,l)}const F=s(t,[["render",h]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_mp_math_vector.md.CgtIoM4A.lean.js b/assets/en_api_mp_math_vector.md.CgtIoM4A.lean.js new file mode 100644 index 0000000..041914c --- /dev/null +++ b/assets/en_api_mp_math_vector.md.CgtIoM4A.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"en/api/mp_math/vector.md","filePath":"en/api/mp_math/vector.md"}'),t={name:"en/api/mp_math/vector.md"},e=n("",127),l=[e];function h(p,k,r,o,d,g){return a(),i("div",null,l)}const F=s(t,[["render",h]]);export{y as __pageData,F as default}; diff --git a/assets/en_api_presets_model_index.md.BOZde1R5.js b/assets/en_api_presets_model_index.md.pbEu-669.js similarity index 86% rename from assets/en_api_presets_model_index.md.BOZde1R5.js rename to assets/en_api_presets_model_index.md.pbEu-669.js index 208d48d..7409381 100644 --- a/assets/en_api_presets_model_index.md.BOZde1R5.js +++ b/assets/en_api_presets_model_index.md.pbEu-669.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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(`

mbcp.presets.model

Description: 几何模型点集

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

Description: 生成球体上的点集。

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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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(`

mbcp.presets.model

Description: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

Description: 生成球体上的点集。

Arguments:

  • radius:
  • density:

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

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.C94oF1kp.js";const y
     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)]
`,10),l=[h];function p(e,k,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; diff --git a/assets/en_api_presets_model_index.md.BOZde1R5.lean.js b/assets/en_api_presets_model_index.md.pbEu-669.lean.js similarity index 87% rename from assets/en_api_presets_model_index.md.BOZde1R5.lean.js rename to assets/en_api_presets_model_index.md.pbEu-669.lean.js index 59631d6..38a796b 100644 --- a/assets/en_api_presets_model_index.md.BOZde1R5.lean.js +++ b/assets/en_api_presets_model_index.md.pbEu-669.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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("",10),l=[h];function p(e,k,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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("",10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; diff --git a/assets/zht_api_mp_math_angle.md.BHWp5-Wz.js b/assets/ja_api_mp_math_angle.md.DTK1PNuJ.js similarity index 64% rename from assets/zht_api_mp_math_angle.md.BHWp5-Wz.js rename to assets/ja_api_mp_math_angle.md.DTK1PNuJ.js index 2b3ca5c..3a65e80 100644 --- a/assets/zht_api_mp_math_angle.md.BHWp5-Wz.js +++ b/assets/ja_api_mp_math_angle.md.DTK1PNuJ.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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(`

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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(`

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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.C94oF1kp.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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

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

def self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

def self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

def self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

def self / other: float => AnyAngle

ソースコード
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

源碼
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

ソースコード
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

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

def self / other

ソースコード
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,80),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}; + return AnyAngle(self.radian / other, is_radian=True)
`,80),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}; diff --git a/assets/ja_api_mp_math_angle.md.mNl1_TuR.lean.js b/assets/ja_api_mp_math_angle.md.DTK1PNuJ.lean.js similarity index 82% rename from assets/ja_api_mp_math_angle.md.mNl1_TuR.lean.js rename to assets/ja_api_mp_math_angle.md.DTK1PNuJ.lean.js index adc42fe..c63a8a6 100644 --- a/assets/ja_api_mp_math_angle.md.mNl1_TuR.lean.js +++ b/assets/ja_api_mp_math_angle.md.DTK1PNuJ.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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("",80),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}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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("",80),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}; diff --git a/assets/api_mp_math_equation.md.Di7kIkyq.js b/assets/ja_api_mp_math_equation.md.Bt8bfjRZ.js similarity index 73% rename from assets/api_mp_math_equation.md.Di7kIkyq.js rename to assets/ja_api_mp_math_equation.md.Bt8bfjRZ.js index 61c68a0..ed705c0 100644 --- a/assets/api_mp_math_equation.md.Di7kIkyq.js +++ b/assets/ja_api_mp_math_equation.md.Bt8bfjRZ.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"api/mp_math/equation.md","filePath":"zh/api/mp_math/equation.md"}'),l={name:"api/mp_math/equation.md"},t=n(`

mbcp.mp_math.equation

说明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"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(`

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

说明: 计算曲线上的点。

参数:

  • *t:
  • 参数:

返回: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:

戻り値: 目标点

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -20,7 +20,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

参数:

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

返回: 偏导函数

引发:

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

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

引数:

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

戻り値: 偏导函数

例外:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

说明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

参数:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源代码
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

引数:

  • func: 函数
  • *args: 参数

戻り値: 柯里化后的函数

ソースコード
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
diff --git a/assets/ja_api_mp_math_equation.md.Bx4R1cWT.lean.js b/assets/ja_api_mp_math_equation.md.Bt8bfjRZ.lean.js
similarity index 100%
rename from assets/ja_api_mp_math_equation.md.Bx4R1cWT.lean.js
rename to assets/ja_api_mp_math_equation.md.Bt8bfjRZ.lean.js
diff --git a/assets/ja_api_mp_math_function.md.Bx9H66-W.js b/assets/ja_api_mp_math_function.md.Bx9H66-W.js
new file mode 100644
index 0000000..556bda8
--- /dev/null
+++ b/assets/ja_api_mp_math_function.md.Bx9H66-W.js
@@ -0,0 +1,17 @@
+import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/function.md","filePath":"ja/api/mp_math/function.md"}'),l={name:"ja/api/mp_math/function.md"},n=a('

mbcp.mp_math.function

説明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

引数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

戻り値: 梯度

ソースコード
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    """
+    计算三元函数在某点的梯度向量。
+    > [!tip]
+    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
+    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
+    Args:
+        func: 三元函数
+        p: 点
+        epsilon: 偏移量
+    Returns:
+        梯度
+    """
+    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
+    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
+    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
+    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/ja_api_mp_math_function.md.D1A2lXjy.lean.js b/assets/ja_api_mp_math_function.md.Bx9H66-W.lean.js similarity index 95% rename from assets/ja_api_mp_math_function.md.D1A2lXjy.lean.js rename to assets/ja_api_mp_math_function.md.Bx9H66-W.lean.js index ef9c878..6b86c70 100644 --- a/assets/ja_api_mp_math_function.md.D1A2lXjy.lean.js +++ b/assets/ja_api_mp_math_function.md.Bx9H66-W.lean.js @@ -1 +1 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/function.md","filePath":"ja/api/mp_math/function.md"}'),n={name:"ja/api/mp_math/function.md"},l=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; +import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/function.md","filePath":"ja/api/mp_math/function.md"}'),l={name:"ja/api/mp_math/function.md"},n=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/ja_api_mp_math_function.md.D1A2lXjy.js b/assets/ja_api_mp_math_function.md.D1A2lXjy.js deleted file mode 100644 index 79abebd..0000000 --- a/assets/ja_api_mp_math_function.md.D1A2lXjy.js +++ /dev/null @@ -1,17 +0,0 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/function.md","filePath":"ja/api/mp_math/function.md"}'),n={name:"ja/api/mp_math/function.md"},l=a('

mbcp.mp_math.function

説明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

引数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

戻り値: 梯度

ソースコード
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
-    """
-    计算三元函数在某点的梯度向量。
-    > [!tip]
-    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
-    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
-    Args:
-        func: 三元函数
-        p: 点
-        epsilon: 偏移量
-    Returns:
-        梯度
-    """
-    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
-    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
-    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
-    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/api_mp_math_line.md.DbfheWE4.js b/assets/ja_api_mp_math_line.md.DYJV4KNE.js similarity index 76% rename from assets/api_mp_math_line.md.DbfheWE4.js rename to assets/ja_api_mp_math_line.md.DYJV4KNE.js index 5a9b352..6782857 100644 --- a/assets/api_mp_math_line.md.DbfheWE4.js +++ b/assets/ja_api_mp_math_line.md.DYJV4KNE.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"api/mp_math/line.md","filePath":"zh/api/mp_math/line.md"}'),t={name:"api/mp_math/line.md"},l=n(`

mbcp.mp_math.line

说明: 本模块定义了三维空间中的直线类

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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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(`

mbcp.mp_math.line

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

class Line3

def __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.C94oF1kp.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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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.')

def 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.C94oF1kp.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

def 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.C94oF1kp.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))

def 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.C94oF1kp.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

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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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)

def __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.C94oF1kp.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)

def __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.C94oF1kp.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["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)
`,107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_line.md.CUb8HcBw.lean.js b/assets/ja_api_mp_math_line.md.DYJV4KNE.lean.js similarity index 58% rename from assets/ja_api_mp_math_line.md.CUb8HcBw.lean.js rename to assets/ja_api_mp_math_line.md.DYJV4KNE.lean.js index 69f2dae..5fb9a23 100644 --- a/assets/ja_api_mp_math_line.md.CUb8HcBw.lean.js +++ b/assets/ja_api_mp_math_line.md.DYJV4KNE.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/line.md","filePath":"ja/api/mp_math/line.md"}'),t={name:"ja/api/mp_math/line.md"},l=n("",107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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("",107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/api_mp_math_plane.md.DLuC3Mxh.js b/assets/ja_api_mp_math_plane.md.D-yHaxP-.js similarity index 77% rename from assets/api_mp_math_plane.md.DLuC3Mxh.js rename to assets/ja_api_mp_math_plane.md.D-yHaxP-.js index 0911194..9872d64 100644 --- a/assets/api_mp_math_plane.md.DLuC3Mxh.js +++ b/assets/ja_api_mp_math_plane.md.D-yHaxP-.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"zh/api/mp_math/plane.md"}'),l={name:"api/mp_math/plane.md"},h=n(`

mbcp.mp_math.plane

说明: 本模块定义了三维空间中的平面类

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"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(`

mbcp.mp_math.plane

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

class Plane3

def __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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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)}')

def 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.C94oF1kp.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)}')

def 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.C94oF1kp.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)

def 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.C94oF1kp.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))

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def __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

def __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):
+    ...

def __and__(self, other)

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

引数:

  • other:

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

ソースコード
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.C94oF1kp.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':
+        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)
`,105),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.CzPHp-i-.lean.js b/assets/ja_api_mp_math_plane.md.D-yHaxP-.lean.js similarity index 100% rename from assets/ja_api_mp_math_plane.md.CzPHp-i-.lean.js rename to assets/ja_api_mp_math_plane.md.D-yHaxP-.lean.js diff --git a/assets/ja_api_mp_math_point.md.1OBHSorb.js b/assets/ja_api_mp_math_point.md.DjHRkHI5.js similarity index 62% rename from assets/ja_api_mp_math_point.md.1OBHSorb.js rename to assets/ja_api_mp_math_point.md.DjHRkHI5.js index 10a18fa..b9735ff 100644 --- a/assets/ja_api_mp_math_point.md.1OBHSorb.js +++ b/assets/ja_api_mp_math_point.md.DjHRkHI5.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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(`

mbcp.mp_math.point

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

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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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(`

mbcp.mp_math.point

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

class Point3

def __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.C94oF1kp.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

def 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.C94oF1kp.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

def self + other: Vector3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)

def __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)

def 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.C94oF1kp.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),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}; + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),h=[l];function e(p,k,r,o,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.1OBHSorb.lean.js b/assets/ja_api_mp_math_point.md.DjHRkHI5.lean.js similarity index 86% rename from assets/ja_api_mp_math_point.md.1OBHSorb.lean.js rename to assets/ja_api_mp_math_point.md.DjHRkHI5.lean.js index ceb0b23..83beb8b 100644 --- a/assets/ja_api_mp_math_point.md.1OBHSorb.lean.js +++ b/assets/ja_api_mp_math_point.md.DjHRkHI5.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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("",36),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}; +import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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("",36),h=[l];function e(p,k,r,o,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.Elu4YWS-.js b/assets/ja_api_mp_math_segment.md.37V8kAc1.js similarity index 78% rename from assets/ja_api_mp_math_segment.md.Elu4YWS-.js rename to assets/ja_api_mp_math_segment.md.37V8kAc1.js index ab70f79..2a61ac7 100644 --- a/assets/ja_api_mp_math_segment.md.Elu4YWS-.js +++ b/assets/ja_api_mp_math_segment.md.37V8kAc1.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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(`

mbcp.mp_math.segment

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

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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},p=n(`

mbcp.mp_math.segment

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

class Segment3

def __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.C94oF1kp.js";const F
     '长度'
     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)
`,6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F 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)
`,6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/ja_api_mp_math_segment.md.Elu4YWS-.lean.js b/assets/ja_api_mp_math_segment.md.37V8kAc1.lean.js similarity index 59% rename from assets/ja_api_mp_math_segment.md.Elu4YWS-.lean.js rename to assets/ja_api_mp_math_segment.md.37V8kAc1.lean.js index 5a2fd16..399c379 100644 --- a/assets/ja_api_mp_math_segment.md.Elu4YWS-.lean.js +++ b/assets/ja_api_mp_math_segment.md.37V8kAc1.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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("",6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/segment.md","filePath":"ja/api/mp_math/segment.md"}'),t={name:"ja/api/mp_math/segment.md"},p=n("",6),h=[p];function l(e,k,r,d,E,g){return a(),i("div",null,h)}const y=s(t,[["render",l]]);export{o as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_utils.md.CAphuB0R.js b/assets/ja_api_mp_math_utils.md.BbdhM1tp.js similarity index 66% rename from assets/zht_api_mp_math_utils.md.CAphuB0R.js rename to assets/ja_api_mp_math_utils.md.BbdhM1tp.js index 5100857..7c674b7 100644 --- a/assets/zht_api_mp_math_utils.md.CAphuB0R.js +++ b/assets/ja_api_mp_math_utils.md.BbdhM1tp.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),t={name:"zht/api/mp_math/utils.md"},l=n(`

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> 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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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(`

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

引数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

戻り値: 限制后的值

ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -9,8 +9,8 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value

def __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
@@ -20,9 +20,9 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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)

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

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

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

戻り値: 是否近似相等

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -32,7 +32,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

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

説明: 获取数的符号。

變數説明:

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

返回: 符号 + - ""

源碼
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

説明: 获取数的符号。

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -45,7 +45,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return '-'
     else:
-        return ''

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

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

變數説明:

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

返回: 符号 + - ""

源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = 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
@@ -61,4 +61,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''
`,35),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; + return ''
`,35),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}; diff --git a/assets/ja_api_mp_math_utils.md.DdUJsEiD.lean.js b/assets/ja_api_mp_math_utils.md.BbdhM1tp.lean.js similarity index 86% rename from assets/ja_api_mp_math_utils.md.DdUJsEiD.lean.js rename to assets/ja_api_mp_math_utils.md.BbdhM1tp.lean.js index 9543877..f674376 100644 --- a/assets/ja_api_mp_math_utils.md.DdUJsEiD.lean.js +++ b/assets/ja_api_mp_math_utils.md.BbdhM1tp.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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("",35),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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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("",35),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}; diff --git a/assets/api_mp_math_vector.md.BiNus8y5.js b/assets/ja_api_mp_math_vector.md.BBVnCwJa.js similarity index 67% rename from assets/api_mp_math_vector.md.BiNus8y5.js rename to assets/ja_api_mp_math_vector.md.BBVnCwJa.js index 029bd4a..386905a 100644 --- a/assets/api_mp_math_vector.md.BiNus8y5.js +++ b/assets/ja_api_mp_math_vector.md.BBVnCwJa.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"api/mp_math/vector.md","filePath":"zh/api/mp_math/vector.md"}'),n={name:"api/mp_math/vector.md"},h=t(`

mbcp.mp_math.vector

说明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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 n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),t={name:"ja/api/mp_math/vector.md"},l=n(`

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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.C94oF1kp.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

def 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.C94oF1kp.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])

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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

def 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

def 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

def __abs__(self)

ソースコード
python
def __abs__(self):
+    return self.length

@overload

def self + other: Vector3 => Vector3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}'")

def __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.C94oF1kp.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)

def 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.C94oF1kp.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

def self - other: Vector3 => Vector3

ソースコード
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

源代码
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}"')

def 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.C94oF1kp.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

def self * other: Vector3 => Vector3

ソースコード
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

源代码
python
@overload
+    ...

@overload

def 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':
+    ...

def 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.C94oF1kp.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)}'")

def self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

def 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轴单位向量

`,127),l=[h];function e(p,k,r,o,d,g){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

def self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

def - 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轴单位向量

`,127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_vector.md.BBVnCwJa.lean.js b/assets/ja_api_mp_math_vector.md.BBVnCwJa.lean.js new file mode 100644 index 0000000..1e17985 --- /dev/null +++ b/assets/ja_api_mp_math_vector.md.BBVnCwJa.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"ja/api/mp_math/vector.md","filePath":"ja/api/mp_math/vector.md"}'),t={name:"ja/api/mp_math/vector.md"},l=n("",127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_vector.md.BIkkuu3D.lean.js b/assets/ja_api_mp_math_vector.md.BIkkuu3D.lean.js deleted file mode 100644 index d1736cc..0000000 --- a/assets/ja_api_mp_math_vector.md.BIkkuu3D.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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("",127),l=[h];function e(p,k,r,o,d,g){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.DGIEt4ke.js b/assets/ja_api_presets_model_index.md.C-Ypf-qh.js similarity index 84% rename from assets/ja_api_presets_model_index.md.DGIEt4ke.js rename to assets/ja_api_presets_model_index.md.C-Ypf-qh.js index 5d13f5f..4ff335d 100644 --- a/assets/ja_api_presets_model_index.md.DGIEt4ke.js +++ b/assets/ja_api_presets_model_index.md.C-Ypf-qh.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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(`

mbcp.presets.model

説明: 几何模型点集

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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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(`

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

引数:

  • radius:
  • density:

戻り値: List[Point3]: 球体上的点集。

ソースコード
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.C94oF1kp.js";const y
     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)]
`,10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_presets_model_index.md.DGIEt4ke.lean.js b/assets/ja_api_presets_model_index.md.C-Ypf-qh.lean.js similarity index 64% rename from assets/ja_api_presets_model_index.md.DGIEt4ke.lean.js rename to assets/ja_api_presets_model_index.md.C-Ypf-qh.lean.js index 2a8e5fd..17ebf41 100644 --- a/assets/ja_api_presets_model_index.md.DGIEt4ke.lean.js +++ b/assets/ja_api_presets_model_index.md.C-Ypf-qh.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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("",10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(t,[["render",p]]);export{y as __pageData,c as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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("",10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/ja_api_mp_math_angle.md.mNl1_TuR.js b/assets/zht_api_mp_math_angle.md.lzcXwnW6.js similarity index 58% rename from assets/ja_api_mp_math_angle.md.mNl1_TuR.js rename to assets/zht_api_mp_math_angle.md.lzcXwnW6.js index f1764e4..9003c28 100644 --- a/assets/ja_api_mp_math_angle.md.mNl1_TuR.js +++ b/assets/zht_api_mp_math_angle.md.lzcXwnW6.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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(`

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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(`

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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.C94oF1kp.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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

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

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

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

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def self / other: float => AnyAngle

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

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

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

method self / other

ソースコード
python
def __truediv__(self, other):
+    ...

def self / other

源碼
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
-    return AnyAngle(self.radian / other, is_radian=True)
`,80),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}; + return AnyAngle(self.radian / other, is_radian=True)
`,80),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}; diff --git a/assets/zht_api_mp_math_angle.md.BHWp5-Wz.lean.js b/assets/zht_api_mp_math_angle.md.lzcXwnW6.lean.js similarity index 82% rename from assets/zht_api_mp_math_angle.md.BHWp5-Wz.lean.js rename to assets/zht_api_mp_math_angle.md.lzcXwnW6.lean.js index ecf0ccf..07adbfd 100644 --- a/assets/zht_api_mp_math_angle.md.BHWp5-Wz.lean.js +++ b/assets/zht_api_mp_math_angle.md.lzcXwnW6.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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("",80),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}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle","editLink":false},"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("",80),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}; diff --git a/assets/zht_api_mp_math_equation.md.Da-XfzS0.js b/assets/zht_api_mp_math_equation.md.Bn6MiQ1c.js similarity index 70% rename from assets/zht_api_mp_math_equation.md.Da-XfzS0.js rename to assets/zht_api_mp_math_equation.md.Bn6MiQ1c.js index 3952e8c..893d175 100644 --- a/assets/zht_api_mp_math_equation.md.Da-XfzS0.js +++ b/assets/zht_api_mp_math_equation.md.Bn6MiQ1c.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),t={name:"zht/api/mp_math/equation.md"},l=n(`

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"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(`

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -8,7 +8,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:

返回: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:

返回: 目标点

源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -20,7 +20,7 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

變數説明:

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

返回: 偏导函数

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

變數説明:

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

返回: 偏导函数

抛出:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

變數説明:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源碼
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

變數説明:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源碼
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
@@ -77,4 +77,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u
     def curried_func(*args2: Var) -> Var:
         """@litedoc-hide"""
         return func(*args, *args2)
-    return curried_func
`,30),p=[l];function h(k,e,r,E,d,g){return a(),i("div",null,p)}const F=s(t,[["render",h]]);export{u as __pageData,F as default}; + return curried_func
`,30),p=[t];function h(k,e,r,E,d,g){return a(),i("div",null,p)}const F=s(l,[["render",h]]);export{u as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_equation.md.Da-XfzS0.lean.js b/assets/zht_api_mp_math_equation.md.Bn6MiQ1c.lean.js similarity index 60% rename from assets/zht_api_mp_math_equation.md.Da-XfzS0.lean.js rename to assets/zht_api_mp_math_equation.md.Bn6MiQ1c.lean.js index 6dbb689..6da5510 100644 --- a/assets/zht_api_mp_math_equation.md.Da-XfzS0.lean.js +++ b/assets/zht_api_mp_math_equation.md.Bn6MiQ1c.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),t={name:"zht/api/mp_math/equation.md"},l=n("",30),p=[l];function h(k,e,r,E,d,g){return a(),i("div",null,p)}const F=s(t,[["render",h]]);export{u as __pageData,F as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","editLink":false},"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("",30),p=[t];function h(k,e,r,E,d,g){return a(),i("div",null,p)}const F=s(l,[["render",h]]);export{u as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_function.md.C6pPUbwO.js b/assets/zht_api_mp_math_function.md.C6pPUbwO.js new file mode 100644 index 0000000..21aa198 --- /dev/null +++ b/assets/zht_api_mp_math_function.md.C6pPUbwO.js @@ -0,0 +1,17 @@ +import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/function.md","filePath":"zht/api/mp_math/function.md"}'),l={name:"zht/api/mp_math/function.md"},n=a('

mbcp.mp_math.function

説明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

變數説明:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源碼
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    """
+    计算三元函数在某点的梯度向量。
+    > [!tip]
+    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
+    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
+    Args:
+        func: 三元函数
+        p: 点
+        epsilon: 偏移量
+    Returns:
+        梯度
+    """
+    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
+    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
+    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
+    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/zht_api_mp_math_function.md.CFVTTeOW.lean.js b/assets/zht_api_mp_math_function.md.C6pPUbwO.lean.js similarity index 95% rename from assets/zht_api_mp_math_function.md.CFVTTeOW.lean.js rename to assets/zht_api_mp_math_function.md.C6pPUbwO.lean.js index 99228b7..b3cc230 100644 --- a/assets/zht_api_mp_math_function.md.CFVTTeOW.lean.js +++ b/assets/zht_api_mp_math_function.md.C6pPUbwO.lean.js @@ -1 +1 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/function.md","filePath":"zht/api/mp_math/function.md"}'),n={name:"zht/api/mp_math/function.md"},l=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; +import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/function.md","filePath":"zht/api/mp_math/function.md"}'),l={name:"zht/api/mp_math/function.md"},n=a("",4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a("",1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a("",1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a("",1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a("",4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[n,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(l,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/zht_api_mp_math_function.md.CFVTTeOW.js b/assets/zht_api_mp_math_function.md.CFVTTeOW.js deleted file mode 100644 index 9480db4..0000000 --- a/assets/zht_api_mp_math_function.md.CFVTTeOW.js +++ /dev/null @@ -1,17 +0,0 @@ -import{_ as i,c as s,j as t,a as T,a2 as a,o as Q}from"./chunks/framework.C94oF1kp.js";const v=JSON.parse('{"title":"mbcp.mp_math.function","description":"","frontmatter":{"title":"mbcp.mp_math.function","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/function.md","filePath":"zht/api/mp_math/function.md"}'),n={name:"zht/api/mp_math/function.md"},l=a('

mbcp.mp_math.function

説明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

',4),e={class:"tip custom-block github-alert"},h=t("p",{class:"custom-block-title"},"TIP",-1),r={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"8.471ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 3744.3 1000","aria-hidden":"true"},p=a('',1),o=[p],m=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("mi",null,"x"),t("mo",null,","),t("mi",null,"y"),t("mo",null,","),t("mi",null,"z"),t("mo",{stretchy:"false"},")")])],-1),k={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},g={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"10.19ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 4504 1000","aria-hidden":"true"},c=a('',1),y=[c],u=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")")])],-1),f={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},E={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.469ex"},xmlns:"http://www.w3.org/2000/svg",width:"29.427ex",height:"4.07ex",role:"img",focusable:"false",viewBox:"0 -1149.5 13006.8 1799","aria-hidden":"true"},F=a('',1),_=[F],w=t("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[t("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[t("mi",{mathvariant:"normal"},"∇"),t("mi",null,"f"),t("mo",{stretchy:"false"},"("),t("msub",null,[t("mi",null,"x"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"y"),t("mn",null,"0")]),t("mo",null,","),t("msub",null,[t("mi",null,"z"),t("mn",null,"0")]),t("mo",{stretchy:"false"},")"),t("mo",null,"="),t("mrow",{"data-mjx-texclass":"INNER"},[t("mo",{"data-mjx-texclass":"OPEN"},"("),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"x")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"y")])]),t("mo",null,","),t("mfrac",null,[t("mrow",null,[t("mi",null,"∂"),t("mi",null,"f")]),t("mrow",null,[t("mi",null,"∂"),t("mi",null,"z")])]),t("mo",{"data-mjx-texclass":"CLOSE"},")")])])],-1),x=a(`

變數説明:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源碼
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
-    """
-    计算三元函数在某点的梯度向量。
-    > [!tip]
-    > 已知一个函数$f(x, y, z)$,则其在点$(x_0, y_0, z_0)$处的梯度向量为:
-    $\\\\nabla f(x_0, y_0, z_0) = \\\\left(\\\\frac{\\\\partial f}{\\\\partial x}, \\\\frac{\\\\partial f}{\\\\partial y}, \\\\frac{\\\\partial f}{\\\\partial z}\\\\right)$
-    Args:
-        func: 三元函数
-        p: 点
-        epsilon: 偏移量
-    Returns:
-        梯度
-    """
-    dx = (func(p.x + epsilon, p.y, p.z) - func(p.x - epsilon, p.y, p.z)) / (2 * epsilon)
-    dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
-    dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
-    return Vector3(dx, dy, dz)
`,4);function L(C,H,M,Z,b,D){return Q(),s("div",null,[l,t("div",e,[h,t("p",null,[T("已知一个函数"),t("mjx-container",r,[(Q(),s("svg",d,o)),m]),T(",则其在点"),t("mjx-container",k,[(Q(),s("svg",g,y)),u]),T("处的梯度向量为: "),t("mjx-container",f,[(Q(),s("svg",E,_)),w])])]),x])}const V=i(n,[["render",L]]);export{v as __pageData,V as default}; diff --git a/assets/zht_api_mp_math_line.md.CERQpbvD.js b/assets/zht_api_mp_math_line.md.DX62bgjZ.js similarity index 63% rename from assets/zht_api_mp_math_line.md.CERQpbvD.js rename to assets/zht_api_mp_math_line.md.DX62bgjZ.js index 8113729..8038235 100644 --- a/assets/zht_api_mp_math_line.md.CERQpbvD.js +++ b/assets/zht_api_mp_math_line.md.DX62bgjZ.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),t={name:"zht/api/mp_math/line.md"},l=n(`

mbcp.mp_math.line

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

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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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(`

mbcp.mp_math.line

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

class Line3

def __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.C94oF1kp.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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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.')

def 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.C94oF1kp.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

def 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.C94oF1kp.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))

def 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.C94oF1kp.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

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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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)

def __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.C94oF1kp.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)

def __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.C94oF1kp.js";const E
         Returns:
 
         """
-    return self.direction.is_parallel(other.direction) and (self.point - other.point).is_parallel(self.direction)
`,107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["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)
`,107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_line.md.CERQpbvD.lean.js b/assets/zht_api_mp_math_line.md.DX62bgjZ.lean.js similarity index 58% rename from assets/zht_api_mp_math_line.md.CERQpbvD.lean.js rename to assets/zht_api_mp_math_line.md.DX62bgjZ.lean.js index 297756a..55a0c8a 100644 --- a/assets/zht_api_mp_math_line.md.CERQpbvD.lean.js +++ b/assets/zht_api_mp_math_line.md.DX62bgjZ.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/line.md","filePath":"zht/api/mp_math/line.md"}'),t={name:"zht/api/mp_math/line.md"},l=n("",107),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.line","description":"","frontmatter":{"title":"mbcp.mp_math.line","editLink":false},"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("",107),p=[t];function e(h,k,r,o,d,g){return a(),i("div",null,p)}const y=s(l,[["render",e]]);export{E as __pageData,y as default}; diff --git a/assets/zht_api_mp_math_plane.md.8lFm9uJ1.js b/assets/zht_api_mp_math_plane.md.DJ_9NQFz.js similarity index 73% rename from assets/zht_api_mp_math_plane.md.8lFm9uJ1.js rename to assets/zht_api_mp_math_plane.md.DJ_9NQFz.js index 157e98d..9046d88 100644 --- a/assets/zht_api_mp_math_plane.md.8lFm9uJ1.js +++ b/assets/zht_api_mp_math_plane.md.DJ_9NQFz.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"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(`

mbcp.mp_math.plane

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

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.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","editLink":false},"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(`

mbcp.mp_math.plane

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

class Plane3

def __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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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)}')

def 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.C94oF1kp.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)}')

def 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.C94oF1kp.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)

def 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.C94oF1kp.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))

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def 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.C94oF1kp.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

def __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

def __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):
+    ...

def __and__(self, other)

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

變數説明:

  • other:

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

源碼
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.C94oF1kp.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':
+        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)
`,105),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.8lFm9uJ1.lean.js b/assets/zht_api_mp_math_plane.md.DJ_9NQFz.lean.js similarity index 100% rename from assets/zht_api_mp_math_plane.md.8lFm9uJ1.lean.js rename to assets/zht_api_mp_math_plane.md.DJ_9NQFz.lean.js diff --git a/assets/zht_api_mp_math_point.md.CH6HpvMW.js b/assets/zht_api_mp_math_point.md.D1nAiRP0.js similarity index 62% rename from assets/zht_api_mp_math_point.md.CH6HpvMW.js rename to assets/zht_api_mp_math_point.md.D1nAiRP0.js index c1ab724..006128b 100644 --- a/assets/zht_api_mp_math_point.md.CH6HpvMW.js +++ b/assets/zht_api_mp_math_point.md.D1nAiRP0.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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(`

mbcp.mp_math.point

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

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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/point.md","filePath":"zht/api/mp_math/point.md"}'),n={name:"zht/api/mp_math/point.md"},l=t(`

mbcp.mp_math.point

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

class Point3

def __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.C94oF1kp.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

def 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.C94oF1kp.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

def self + other: Vector3 => Point3

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

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)

def __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)

def 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.C94oF1kp.js";const y
 
         """
     from .vector import Vector3
-    return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)
`,36),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)
`,36),h=[l];function e(p,k,r,o,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.CH6HpvMW.lean.js b/assets/zht_api_mp_math_point.md.D1nAiRP0.lean.js similarity index 72% rename from assets/zht_api_mp_math_point.md.CH6HpvMW.lean.js rename to assets/zht_api_mp_math_point.md.D1nAiRP0.lean.js index f80dac1..6468bc9 100644 --- a/assets/zht_api_mp_math_point.md.CH6HpvMW.lean.js +++ b/assets/zht_api_mp_math_point.md.D1nAiRP0.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"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("",36),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.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.point","description":"","frontmatter":{"title":"mbcp.mp_math.point","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/point.md","filePath":"zht/api/mp_math/point.md"}'),n={name:"zht/api/mp_math/point.md"},l=t("",36),h=[l];function e(p,k,r,o,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.GweOoNT9.js b/assets/zht_api_mp_math_segment.md.CMRey-MG.js similarity index 71% rename from assets/en_api_mp_math_segment.md.GweOoNT9.js rename to assets/zht_api_mp_math_segment.md.CMRey-MG.js index c04bd2a..0e722a3 100644 --- a/assets/en_api_mp_math_segment.md.GweOoNT9.js +++ b/assets/zht_api_mp_math_segment.md.CMRey-MG.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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(`

mbcp.mp_math.segment

Description: 本模块定义了三维空间中的线段类

class Segment3

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

Description: 三维空间中的线段。 :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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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(`

mbcp.mp_math.segment

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

class Segment3

def __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.C94oF1kp.js";const F
     '长度'
     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)
`,6),p=[h];function e(l,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",e]]);export{F 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)
`,6),p=[h];function l(e,k,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.BZQVMFnu.lean.js b/assets/zht_api_mp_math_segment.md.CMRey-MG.lean.js similarity index 73% rename from assets/zht_api_mp_math_segment.md.BZQVMFnu.lean.js rename to assets/zht_api_mp_math_segment.md.CMRey-MG.lean.js index 6a4431d..e6d60ae 100644 --- a/assets/zht_api_mp_math_segment.md.BZQVMFnu.lean.js +++ b/assets/zht_api_mp_math_segment.md.CMRey-MG.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const F=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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("",6),p=[h];function l(e,k,r,d,E,g){return a(),i("div",null,p)}const y=s(t,[["render",l]]);export{F as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.mp_math.segment","description":"","frontmatter":{"title":"mbcp.mp_math.segment","editLink":false},"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("",6),p=[h];function l(e,k,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.DdUJsEiD.js b/assets/zht_api_mp_math_utils.md.BDpW2Fd4.js similarity index 61% rename from assets/ja_api_mp_math_utils.md.DdUJsEiD.js rename to assets/zht_api_mp_math_utils.md.BDpW2Fd4.js index 7bdfe21..d351925 100644 --- a/assets/ja_api_mp_math_utils.md.DdUJsEiD.js +++ b/assets/zht_api_mp_math_utils.md.BDpW2Fd4.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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(`

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> 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.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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(`

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

變數説明:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

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

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

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

def __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
@@ -20,9 +20,9 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.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)

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

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

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

戻り値: 是否近似相等

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

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

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

説明: 获取数的符号。

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

説明: 获取数的符号。

變數説明:

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

返回: 符号 + - ""

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

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

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

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = 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
@@ -61,4 +61,4 @@ import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E
     elif x < 0:
         return f'-{abs(x)}'
     else:
-        return ''
`,35),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 ''
`,35),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}; diff --git a/assets/zht_api_mp_math_utils.md.CAphuB0R.lean.js b/assets/zht_api_mp_math_utils.md.BDpW2Fd4.lean.js similarity index 58% rename from assets/zht_api_mp_math_utils.md.CAphuB0R.lean.js rename to assets/zht_api_mp_math_utils.md.BDpW2Fd4.lean.js index 0997936..e56152e 100644 --- a/assets/zht_api_mp_math_utils.md.CAphuB0R.lean.js +++ b/assets/zht_api_mp_math_utils.md.BDpW2Fd4.lean.js @@ -1 +1 @@ -import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/utils.md","filePath":"zht/api/mp_math/utils.md"}'),t={name:"zht/api/mp_math/utils.md"},l=n("",35),h=[l];function p(e,k,r,o,d,g){return a(),i("div",null,h)}const y=s(t,[["render",p]]);export{E as __pageData,y as default}; +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const E=JSON.parse('{"title":"mbcp.mp_math.utils","description":"","frontmatter":{"title":"mbcp.mp_math.utils","editLink":false},"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("",35),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}; diff --git a/assets/zht_api_mp_math_vector.md.B57rC4-I.lean.js b/assets/zht_api_mp_math_vector.md.B57rC4-I.lean.js deleted file mode 100644 index 344491f..0000000 --- a/assets/zht_api_mp_math_vector.md.B57rC4-I.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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("",127),l=[h];function e(p,k,r,o,d,g){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.B57rC4-I.js b/assets/zht_api_mp_math_vector.md.DGVOQo3Y.js similarity index 67% rename from assets/zht_api_mp_math_vector.md.B57rC4-I.js rename to assets/zht_api_mp_math_vector.md.DGVOQo3Y.js index cefe23c..49dab6e 100644 --- a/assets/zht_api_mp_math_vector.md.B57rC4-I.js +++ b/assets/zht_api_mp_math_vector.md.DGVOQo3Y.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"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(`

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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 n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),t={name:"zht/api/mp_math/vector.md"},l=n(`

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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.C94oF1kp.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

def 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.C94oF1kp.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])

def 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.C94oF1kp.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)

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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.C94oF1kp.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)

def 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.C94oF1kp.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

def 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

def 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

def 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

def __abs__(self)

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

@overload

def self + other: Vector3 => Vector3

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

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}'")

def __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.C94oF1kp.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)

def 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.C94oF1kp.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

def self - other: Vector3 => Vector3

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

@overload

method self - other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

def 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.C94oF1kp.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)}"')

def 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.C94oF1kp.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

def self * other: Vector3 => Vector3

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

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
+    ...

@overload

def 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':
+    ...

def 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.C94oF1kp.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)}'")

def self * other: RealNumber => Vector3

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

def 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轴单位向量

`,127),l=[h];function e(p,k,r,o,d,g){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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

`,127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_mp_math_vector.md.DGVOQo3Y.lean.js b/assets/zht_api_mp_math_vector.md.DGVOQo3Y.lean.js new file mode 100644 index 0000000..dd2cd98 --- /dev/null +++ b/assets/zht_api_mp_math_vector.md.DGVOQo3Y.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.mp_math.vector","description":"","frontmatter":{"title":"mbcp.mp_math.vector","editLink":false},"headers":[],"relativePath":"zht/api/mp_math/vector.md","filePath":"zht/api/mp_math/vector.md"}'),t={name:"zht/api/mp_math/vector.md"},l=n("",127),h=[l];function e(p,k,r,o,d,g){return a(),i("div",null,h)}const F=s(t,[["render",e]]);export{y as __pageData,F as default}; diff --git a/assets/zht_api_presets_model_index.md.D2Dc7np7.js b/assets/zht_api_presets_model_index.md.BJWX_k6K.js similarity index 83% rename from assets/zht_api_presets_model_index.md.D2Dc7np7.js rename to assets/zht_api_presets_model_index.md.BJWX_k6K.js index 879cc9e..2b61760 100644 --- a/assets/zht_api_presets_model_index.md.D2Dc7np7.js +++ b/assets/zht_api_presets_model_index.md.BJWX_k6K.js @@ -1,4 +1,4 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),n={name:"zht/api/presets/model/index.md"},h=t(`

mbcp.presets.model

説明: 几何模型点集

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.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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(`

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

變數説明:

  • radius:
  • density:

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

源碼
python
@staticmethod
 def sphere(radius: float, density: float):
     """
         生成球体上的点集。
@@ -15,4 +15,4 @@ import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y
     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)]
`,10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(n,[["render",p]]);export{y as __pageData,c as default}; + return [Point3(x_array[i], y_array[i], z_array[i]) for i in range(num)]
`,10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/zht_api_presets_model_index.md.BJWX_k6K.lean.js b/assets/zht_api_presets_model_index.md.BJWX_k6K.lean.js new file mode 100644 index 0000000..664af76 --- /dev/null +++ b/assets/zht_api_presets_model_index.md.BJWX_k6K.lean.js @@ -0,0 +1 @@ +import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.C94oF1kp.js";const o=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"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("",10),l=[h];function p(k,e,r,d,E,g){return a(),i("div",null,l)}const F=s(t,[["render",p]]);export{o as __pageData,F as default}; diff --git a/assets/zht_api_presets_model_index.md.D2Dc7np7.lean.js b/assets/zht_api_presets_model_index.md.D2Dc7np7.lean.js deleted file mode 100644 index 13a4beb..0000000 --- a/assets/zht_api_presets_model_index.md.D2Dc7np7.lean.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as s,c as i,o as a,a2 as t}from"./chunks/framework.C94oF1kp.js";const y=JSON.parse('{"title":"mbcp.presets.model","description":"","frontmatter":{"title":"mbcp.presets.model","editLink":false,"collapsed":true},"headers":[],"relativePath":"zht/api/presets/model/index.md","filePath":"zht/api/presets/model/index.md"}'),n={name:"zht/api/presets/model/index.md"},h=t("",10),l=[h];function p(k,e,r,d,E,o){return a(),i("div",null,l)}const c=s(n,[["render",p]]);export{y as __pageData,c as default}; diff --git a/demo/index.html b/demo/index.html index 8f0caf0..ab81d17 100644 --- a/demo/index.html +++ b/demo/index.html @@ -17,8 +17,8 @@ -
Skip to content

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/en/api/index.html b/en/api/index.html index 44a40ab..4d927c0 100644 --- a/en/api/index.html +++ b/en/api/index.html @@ -18,7 +18,7 @@
Skip to content

mbcp

Description: 本模块塞了一些预设的粒子生成器

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/angle.html b/en/api/mp_math/angle.html index c9dc1c7..4d30d87 100644 --- a/en/api/mp_math/angle.html +++ b/en/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.angle

Description: 本模块定义了角度相关的类

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):
+    
Skip to content

mbcp.mp_math.angle

Description: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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

Description: 余角:两角的和为90°。

Return: 余角

Source code
python
@property
+        self.radian = value * PI / 180

@property

def 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

Description: 补角:两角的和为180°。

Return: 补角

Source code
python
@property
+    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

def 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

Description: 角度。

Return: 弧度

Source code
python
@property
+    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

def 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

Description: 最小正角。

Return: 最小正角度

Source code
python
@property
+    return self.radian * 180 / PI

@property

def 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

Description: 最大负角。

Return: 最大负角度

Source code
python
@property
+    return AnyAngle(self.radian % (2 * PI))

@property

def 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

Description: 正弦值。

Return: 正弦值

Source code
python
@property
+    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

def sin(self) -> float

Description: 正弦值。

Return: 正弦值

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

@property

method cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code
python
@property
+    return math.sin(self.radian)

@property

def cos(self) -> float

Description: 余弦值。

Return: 余弦值

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

@property

method tan(self) -> float

Description: 正切值。

Return: 正切值

Source code
python
@property
+    return math.cos(self.radian)

@property

def tan(self) -> float

Description: 正切值。

Return: 正切值

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

@property

method cot(self) -> float

Description: 余切值。

Return: 余切值

Source code
python
@property
+    return math.tan(self.radian)

@property

def 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

Description: 正割值。

Return: 正割值

Source code
python
@property
+    return 1 / math.tan(self.radian)

@property

def 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

Description: 余割值。

Return: 余割值

Source code
python
@property
+    return 1 / math.cos(self.radian)

@property

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

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

Source code
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def 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

def self / other: AnyAngle => float

Source code
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

Source code
python
def __truediv__(self, other):
+    ...

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

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/const.html b/en/api/mp_math/const.html index cb13e4d..67de2e8 100644 --- a/en/api/mp_math/const.html +++ b/en/api/mp_math/const.html @@ -18,7 +18,7 @@
Skip to content

mbcp.mp_math.const

Description: 本模块定义了一些常用的常量

var PI = math.pi

  • Description: 常量 π

var E = math.e

  • Description: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • Description: 黄金分割比

var GAMMA = 0.5772156649015329

  • Description: 欧拉常数

var EPSILON = 0.0001

  • Description: 精度误差

var APPROX = 0.001

  • Description: 约等于判定误差

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/equation.html b/en/api/mp_math/equation.html index 33d6292..f80fc8d 100644 --- a/en/api/mp_math/equation.html +++ b/en/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.equation

Description: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+    
Skip to content

mbcp.mp_math.equation

Description: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -27,7 +27,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:

Return: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

Description: 计算曲线上的点。

Arguments:

  • *t:
  • 参数:

Return: 目标点

Source code
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -39,7 +39,7 @@
     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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

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:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

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:
     """
     求N元函数一阶偏导函数。这玩意不太稳定,慎用。
     > [!warning]
@@ -81,7 +81,7 @@
             return result_func(*args)
         return high_order_partial_derivative_func
     else:
-        raise ValueError('Invalid var type')

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

Description: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

Arguments:

  • func: 函数
  • *args: 参数

Return: 柯里化后的函数

Source code
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

Description: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

Arguments:

  • func: 函数
  • *args: 参数

Return: 柯里化后的函数

Source code
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
@@ -97,7 +97,7 @@
         """@litedoc-hide"""
         return func(*args, *args2)
     return curried_func

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/function.html b/en/api/mp_math/function.html index 67619ec..6afaf93 100644 --- a/en/api/mp_math/function.html +++ b/en/api/mp_math/function.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.function

Description: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

Description: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

Arguments:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

Return: 梯度

Source code
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    
Skip to content

mbcp.mp_math.function

Description: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

Description: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

Arguments:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

Return: 梯度

Source code
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
     """
     计算三元函数在某点的梯度向量。
     > [!tip]
@@ -34,7 +34,7 @@
     dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
     dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
     return Vector3(dx, dy, dz)

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/index.html b/en/api/mp_math/index.html index 56c9efa..18a459a 100644 --- a/en/api/mp_math/index.html +++ b/en/api/mp_math/index.html @@ -18,7 +18,7 @@
Skip to content

mbcp.mp_math

Description: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/line.html b/en/api/mp_math/line.html index 98f8802..d10eef1 100644 --- a/en/api/mp_math/line.html +++ b/en/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.line

Description: 本模块定义了三维空间中的直线类

class Line3

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

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

Arguments:

  • point: 直线上的一点
  • direction: 直线的方向向量
Source code
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

mbcp.mp_math.line

Description: 本模块定义了三维空间中的直线类

class Line3

def __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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似相等

Source code
python
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
+    self.direction = direction

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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似相等

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

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

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)

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

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

Arguments:

  • other: 另一条直线

Return: 夹角弧度

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

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

Arguments:

  • other: 平行直线或点

Return: 距离

Raises:

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

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

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

Arguments:

  • other: 平行直线或点

Return: 距离

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

Description: 计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return: 交点

Raises:

  • ValueError 直线平行
  • ValueError 直线不共面
Source code
python
def cal_intersection(self, other: 'Line3') -> 'Point3':
+        raise TypeError('Unsupported type.')

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

Description: 计算两条直线的交点。

Arguments:

  • other: 另一条直线

Return: 交点

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

Description: 计算直线经过指定点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

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

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

Arguments:

  • point: 指定点

Return: 垂线

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

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

Arguments:

  • t: 参数t

Return: 点

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

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

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

Arguments:

  • t: 参数t

Return: 点

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]

Description: 获取直线的参数方程。

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

def 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

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

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)

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

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

Arguments:

  • other: 另一条直线
  • epsilon: 误差

Return: 是否近似平行

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

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

Arguments:

  • other: 另一条直线

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Line3') -> bool:
+    return self.direction.is_approx_parallel(other.direction, epsilon)

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

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

Arguments:

  • other: 另一条直线

Return: 是否平行

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

Description: 判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return: 是否共线

Source code
python
def is_collinear(self, other: 'Line3') -> bool:
+    return self.direction.is_parallel(other.direction)

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

Description: 判断两条直线是否共线。

Arguments:

  • other: 另一条直线

Return: 是否共线

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

Description: 判断点是否在直线上。

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)

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

Description: 判断点是否在直线上。

Arguments:

  • point: 点

Return: 是否在直线上

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

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

Arguments:

  • other: 另一条直线

Return: 是否共面

Source code
python
def is_coplanar(self, other: 'Line3') -> bool:
+    return (point - self.point).is_parallel(self.direction)

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

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

Arguments:

  • other: 另一条直线

Return: 是否共面

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)

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

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

Source code
python
def simplify(self):
+    return self.direction.cross(other.direction) @ (self.point - other.point) == 0

def 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

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

Arguments:

  • p1: 点1
  • p2: 点2

Return: 直线

Source code
python
@classmethod
+        self.point.z = 0

@classmethod

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

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

Arguments:

  • p1: 点1
  • p2: 点2

Return: 直线

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

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

Arguments:

  • other: 另一条直线

Return: 交点

Source code
python
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
+    return cls(p1, direction)

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

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

Arguments:

  • other: 另一条直线

Return: 交点

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

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

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

Arguments:

  • other:
Source code
python
def __eq__(self, other) -> bool:
+        return self.cal_intersection(other)

def __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)

Documentation built with VitePress | API references generated by litedoc

- + \ 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 0fe9850..d794901 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

mbcp.mp_math.mp_math_typing

Description: 本模块用于内部类型提示

var RealNumber = int | float

  • Type: TypeAlias

  • Description: 实数

var Number = RealNumber | complex

  • Type: TypeAlias

  • Description: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • Description: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • Description: 数组变量

var Var = SingleVar | ArrayVar

  • Type: TypeAlias

  • Description: 变量

var OneSingleVarFunc = Callable[[SingleVar], SingleVar]

  • Type: TypeAlias

  • Description: 一元单变量函数

var OneArrayFunc = Callable[[ArrayVar], ArrayVar]

  • Type: TypeAlias

  • Description: 一元数组函数

var OneVarFunc = OneSingleVarFunc | OneArrayFunc

  • Type: TypeAlias

  • Description: 一元函数

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

  • Type: TypeAlias

  • Description: 二元单变量函数

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

  • Type: TypeAlias

  • Description: 二元数组函数

var TwoVarsFunc = TwoSingleVarsFunc | TwoArraysFunc

  • Type: TypeAlias

  • Description: 二元函数

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

  • Type: TypeAlias

  • Description: 三元单变量函数

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

  • Type: TypeAlias

  • Description: 三元数组函数

var ThreeVarsFunc = ThreeSingleVarsFunc | ThreeArraysFunc

  • Type: TypeAlias

  • Description: 三元函数

var MultiSingleVarsFunc = Callable[..., SingleVar]

  • Type: TypeAlias

  • Description: 多元单变量函数

var MultiArraysFunc = Callable[..., ArrayVar]

  • Type: TypeAlias

  • Description: 多元数组函数

var MultiVarsFunc = MultiSingleVarsFunc | MultiArraysFunc

  • Type: TypeAlias

  • Description: 多元函数

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/plane.html b/en/api/mp_math/plane.html index d4eff0d..30fadac 100644 --- a/en/api/mp_math/plane.html +++ b/en/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.plane

Description: 本模块定义了三维空间中的平面类

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):
+    
Skip to content

mbcp.mp_math.plane

Description: 本模块定义了三维空间中的平面类

class Plane3

def __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

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

Arguments:

  • other: 另一个平面

Return: 是否近似相等

Source code
python
def approx(self, other: 'Plane3') -> bool:
+    self.d = d

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

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

Arguments:

  • other: 另一个平面

Return: 是否近似相等

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

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

Arguments:

  • other: 另一个平面

Return: 夹角弧度

Raises:

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

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

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

Arguments:

  • other: 另一个平面

Return: 夹角弧度

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

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

Arguments:

  • other: 另一个平面或点

Return: 距离

Raises:

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

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

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

Arguments:

  • other: 另一个平面或点

Return: 距离

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

Description: 计算两平面的交线。

Arguments:

  • other: 另一个平面

Return: 两平面的交线

Source code
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
+        raise TypeError(f'Unsupported type: {type(other)}')

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

Description: 计算两平面的交线。

Arguments:

  • other: 另一个平面

Return: 两平面的交线

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

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

Arguments:

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

Return: 交点

Raises:

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

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

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

Arguments:

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

Return: 交点

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

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

Arguments:

  • point: 指定点

Return: 所求平面

Source code
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
+    return Point3(x(t), y(t), z(t))

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

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

Arguments:

  • point: 指定点

Return: 所求平面

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

Description: 判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Plane3') -> bool:
+    return Plane3.from_point_and_normal(point, self.normal)

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

Description: 判断两个平面是否平行。

Arguments:

  • other: 另一个平面

Return: 是否平行

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

Description: 平面的法向量。

Return: 法向量

Source code
python
@property
+    return self.normal.is_parallel(other.normal)

@property

def 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

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

Arguments:

  • point: 平面上的一点
  • normal: 法向量

Return: 平面

Source code
python
@classmethod
+    return Vector3(self.a, self.b, self.c)

@classmethod

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

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

Arguments:

  • point: 平面上的一点
  • normal: 法向量

Return: 平面

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

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

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3

Return: 平面

Source code
python
@classmethod
+    return cls(a, b, c, d)

@classmethod

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

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

Arguments:

  • p1: 点1
  • p2: 点2
  • p3: 点3

Return: 平面

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

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

Arguments:

  • l1: 直线1
  • l2: 直线2

Return: 平面

Source code
python
@classmethod
+    return cls.from_point_and_normal(p1, normal)

@classmethod

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

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

Arguments:

  • l1: 直线1
  • l2: 直线2

Return: 平面

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

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

Arguments:

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

Return: 平面

Source code
python
@classmethod
+    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

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

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

Arguments:

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

Return: 平面

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

def __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

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

Source code
python
@overload
 def __and__(self, other: 'Plane3') -> 'Line3 | None':
-    ...

method __and__(self, other)

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

Arguments:

  • other:

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

Source code
python
def __and__(self, other):
+    ...

def __and__(self, other)

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

Arguments:

  • other:

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

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)}'")

def __eq__(self, other) -> bool

Source code
python
def __eq__(self, other) -> bool:
+    return self.approx(other)

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

Source code
python
def __rand__(self, other: 'Line3') -> 'Point3':
     return self.cal_intersection_point3(other)

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/point.html b/en/api/mp_math/point.html index be89964..e2003ec 100644 --- a/en/api/mp_math/point.html +++ b/en/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.point

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

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):
+    
Skip to content

mbcp.mp_math.point

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

class Point3

def __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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

Source code
python
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

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

def 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

def self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

Description: P + V -> P P + P -> P

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

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

Description: 判断两个点是否相等。

Arguments:

  • other:
Source code
python
def __eq__(self, other):
+    return Point3(self.x + other.x, self.y + other.y, self.z + other.z)

def __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

Description: 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)

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

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/segment.html b/en/api/mp_math/segment.html index 4ee1140..7bc4bf5 100644 --- a/en/api/mp_math/segment.html +++ b/en/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.segment

Description: 本模块定义了三维空间中的线段类

class Segment3

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

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

Source code
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

mbcp.mp_math.segment

Description: 本模块定义了三维空间中的线段类

class Segment3

def __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)

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/utils.html b/en/api/mp_math/utils.html index 3f06c18..96bbc04 100644 --- a/en/api/mp_math/utils.html +++ b/en/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.utils

Description: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> float

Description: 区间限定函数

Arguments:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

Return: 限制后的值

Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

mbcp.mp_math.utils

Description: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

Description: 区间限定函数

Arguments:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

Return: 限制后的值

Source code
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,8 +28,8 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

Source code
python
def __init__(self, value: RealNumber):
+    self.value = value

def __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
@@ -39,9 +39,9 @@
         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)

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

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

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差

Return: 是否近似相等

Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            self.raise_type_error(other)

def 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)}')

def __ne__(self, other)

Source code
python
def __ne__(self, other):
+    return not self.__eq__(other)

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

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

Arguments:

  • x: 数1
  • y: 数2
  • epsilon: 误差

Return: 是否近似相等

Source code
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -51,7 +51,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

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

Description: 获取数的符号。

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

Description: 获取数的符号。

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -64,7 +64,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

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

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

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = False) -> str

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

Arguments:

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

Return: 符号 + - ""

Source code
python
def sign_format(x: float, only_neg: bool=False) -> str:
     """格式化符号数
     -1 -> -1
     1 -> +1
@@ -81,7 +81,7 @@
         return f'-{abs(x)}'
     else:
         return ''

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/mp_math/vector.html b/en/api/mp_math/vector.html index cbece0e..98a57ff 100644 --- a/en/api/mp_math/vector.html +++ b/en/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.vector

Description: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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):
+    
Skip to content

mbcp.mp_math.vector

Description: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

Source code
python
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
+    self.z = z

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

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

Arguments:

  • other:
  • epsilon:

Return: 是否近似相等

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

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

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

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

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

Arguments:

  • other: 另一个向量

Return: 夹角

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

Description: 向量积 叉乘: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)

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

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

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

Arguments:

  • other:

Return: 行列式的结果

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

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

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)

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

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

Arguments:

  • other: 另一个向量
  • epsilon: 允许的误差

Return: 是否近似平行

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

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

Arguments:

  • other: 另一个向量

Return: 是否平行

Source code
python
def is_parallel(self, other: 'Vector3') -> bool:
+    return self.cross(other).length < epsilon

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

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

Arguments:

  • other: 另一个向量

Return: 是否平行

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)

Description: 将向量归一化。

自体归一化,不返回值。

Source code
python
def normalize(self):
+    return self.cross(other).approx(zero_vector3)

def 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

def 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

Description: 向量的模。

Return: 模

Source code
python
@property
+    return np.array([self.x, self.y, self.z])

@property

def 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

Description: 获取该向量的单位向量。

Return: 单位向量

Source code
python
@property
+    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)

@property

def 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

def __abs__(self)

Source code
python
def __abs__(self):
+    return self.length

@overload

def 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

def self + other: Point3 => Point3

Source code
python
@overload
 def __add__(self, other: 'Point3') -> 'Point3':
-    ...

method self + other

Description: V + P -> P

V + V -> V

Arguments:

  • other:
Source code
python
def __add__(self, other):
+    ...

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

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

Arguments:

  • other:

Return: 是否相等

Source code
python
def __eq__(self, other):
+        raise TypeError(f"unsupported operand type(s) for +: 'Vector3' and '{type(other)}'")

def __eq__(self, other)

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

Arguments:

  • other:

Return: 是否相等

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

Description: 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)

def 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

def 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

def self - other: Point3 => Point3

Source code
python
@overload
 def __sub__(self, other: 'Point3') -> 'Point3':
-    ...

method self - other

Description: V - P -> P

V - V -> V

Arguments:

  • other:
Source code
python
def __sub__(self, other):
+    ...

def 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

Description: 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)}"')

def 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

def 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

def self * other: RealNumber => Vector3

Source code
python
@overload
 def __mul__(self, other: RealNumber) -> 'Vector3':
-    ...

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

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

Arguments:

  • other:
Source code
python
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
+    ...

def 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

Description: 点乘。

Arguments:

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

def self * other: RealNumber => Vector3

Source code
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

def 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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/particle/index.html b/en/api/particle/index.html index 8397aeb..3287e44 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 bf38084..8612f65 100644 --- a/en/api/presets/index.html +++ b/en/api/presets/index.html @@ -18,7 +18,7 @@
Skip to content

mbcp.presets

Description: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/api/presets/model/index.html b/en/api/presets/model/index.html index 712fabb..86e63a0 100644 --- a/en/api/presets/model/index.html +++ b/en/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.presets.model

Description: 几何模型点集

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

Description: 生成球体上的点集。

Arguments:

  • radius:
  • density:

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

Source code
python
@staticmethod
+    
Skip to content

mbcp.presets.model

Description: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

Description: 生成球体上的点集。

Arguments:

  • radius:
  • density:

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

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

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/guide/index.html b/en/guide/index.html index 1d6b4c9..9303b4e 100644 --- a/en/guide/index.html +++ b/en/guide/index.html @@ -18,7 +18,7 @@
Skip to content

开始不了一点

12x111

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/en/index.html b/en/index.html index 5f91acb..06c73ec 100644 --- a/en/index.html +++ b/en/index.html @@ -18,7 +18,7 @@
Skip to content

MBCP docs

More basic change particle

A Library for Python to create particle effects and geometric figures

Documentation built with VitePress | API references generated by litedoc

- + \ No newline at end of file diff --git a/guide/index.html b/guide/index.html index 4b1214a..bef4a29 100644 --- a/guide/index.html +++ b/guide/index.html @@ -17,8 +17,8 @@ -
Skip to content

开始不了一点

12x111

AAA

BBB

C

ddd

文档由 VitePress 构建 | API引用由 litedoc 生成

- +
Skip to content

开始不了一点

12x111

AAA

BBB

C

ddd

文档由 VitePress 构建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/hashmap.json b/hashmap.json index 5c5309b..58658c2 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"api_index.md":"C_wESrrY","api_mp_math_angle.md":"iDErkOWa","api_mp_math_const.md":"BAf8mK4W","api_mp_math_equation.md":"Di7kIkyq","api_mp_math_function.md":"roDde0nH","api_mp_math_index.md":"BNf7bQqL","api_mp_math_line.md":"DbfheWE4","api_mp_math_mp_math_typing.md":"DlnJmkos","api_mp_math_plane.md":"DLuC3Mxh","api_mp_math_point.md":"DAQFtNol","api_mp_math_segment.md":"CQz_FDoI","api_mp_math_utils.md":"C2moaW8N","api_mp_math_vector.md":"BiNus8y5","api_particle_index.md":"Cm3Vk-es","api_presets_index.md":"CD62I2gv","api_presets_model_index.md":"CJMO-ffZ","demo_index.md":"D-H9zRUE","en_api_index.md":"Dj_5nFTt","en_api_mp_math_angle.md":"DI0aMl64","en_api_mp_math_const.md":"gGpXUShq","en_api_mp_math_equation.md":"CFa2gNNX","en_api_mp_math_function.md":"D5HNykIX","en_api_mp_math_index.md":"BEjLBMpH","en_api_mp_math_line.md":"BI7jrk5A","en_api_mp_math_mp_math_typing.md":"Dnl2aJQ4","en_api_mp_math_plane.md":"C6JEigTz","en_api_mp_math_point.md":"DgKVopYL","en_api_mp_math_segment.md":"GweOoNT9","en_api_mp_math_utils.md":"VHDSe3i2","en_api_mp_math_vector.md":"BlzUS0V3","en_api_particle_index.md":"BfyNQiRg","en_api_presets_index.md":"BWb2fpTg","en_api_presets_model_index.md":"BOZde1R5","en_guide_index.md":"DrDHTYCZ","en_index.md":"MCm69eyE","guide_index.md":"Cfmzk2IH","index.md":"BjJ9-kbE","ja_api_index.md":"CnUeuifx","ja_api_mp_math_angle.md":"mNl1_TuR","ja_api_mp_math_const.md":"DGXAgDfn","ja_api_mp_math_equation.md":"Bx4R1cWT","ja_api_mp_math_function.md":"D1A2lXjy","ja_api_mp_math_index.md":"CTZZ-p9Z","ja_api_mp_math_line.md":"CUb8HcBw","ja_api_mp_math_mp_math_typing.md":"BNymgrCT","ja_api_mp_math_plane.md":"CzPHp-i-","ja_api_mp_math_point.md":"1OBHSorb","ja_api_mp_math_segment.md":"Elu4YWS-","ja_api_mp_math_utils.md":"DdUJsEiD","ja_api_mp_math_vector.md":"BIkkuu3D","ja_api_particle_index.md":"Jr41Y3TS","ja_api_presets_index.md":"CQqdQbIZ","ja_api_presets_model_index.md":"DGIEt4ke","ja_guide_index.md":"BxGnZYwR","ja_index.md":"CtozMsIU","zht_api_index.md":"CgZH6aHQ","zht_api_mp_math_angle.md":"BHWp5-Wz","zht_api_mp_math_const.md":"xwQvuYck","zht_api_mp_math_equation.md":"Da-XfzS0","zht_api_mp_math_function.md":"CFVTTeOW","zht_api_mp_math_index.md":"mmeMMriu","zht_api_mp_math_line.md":"CERQpbvD","zht_api_mp_math_mp_math_typing.md":"CNiSnuMw","zht_api_mp_math_plane.md":"8lFm9uJ1","zht_api_mp_math_point.md":"CH6HpvMW","zht_api_mp_math_segment.md":"BZQVMFnu","zht_api_mp_math_utils.md":"CAphuB0R","zht_api_mp_math_vector.md":"B57rC4-I","zht_api_particle_index.md":"8GaGB1ul","zht_api_presets_index.md":"DvOViSox","zht_api_presets_model_index.md":"D2Dc7np7","zht_guide_index.md":"CsuFVFxu","zht_index.md":"V9U3SwDR"} +{"api_index.md":"C_wESrrY","api_mp_math_angle.md":"vKQLLqTS","api_mp_math_const.md":"BAf8mK4W","api_mp_math_equation.md":"DpRfW_6Z","api_mp_math_function.md":"Cj4FyaYl","api_mp_math_index.md":"BNf7bQqL","api_mp_math_line.md":"DPWL9O-M","api_mp_math_mp_math_typing.md":"DlnJmkos","api_mp_math_plane.md":"DTAJAb0P","api_mp_math_point.md":"vtgIded6","api_mp_math_segment.md":"D-8aRB8W","api_mp_math_utils.md":"DaaoR634","api_mp_math_vector.md":"BTnPeAKR","api_particle_index.md":"Cm3Vk-es","api_presets_index.md":"CD62I2gv","api_presets_model_index.md":"gO0Notp6","demo_index.md":"D-H9zRUE","en_api_index.md":"Dj_5nFTt","en_api_mp_math_angle.md":"Bu07wjnV","en_api_mp_math_const.md":"gGpXUShq","en_api_mp_math_equation.md":"DqlD6s-6","en_api_mp_math_function.md":"Bgn-YygZ","en_api_mp_math_index.md":"BEjLBMpH","en_api_mp_math_line.md":"BGq09mco","en_api_mp_math_mp_math_typing.md":"Dnl2aJQ4","en_api_mp_math_plane.md":"C3KPGKE4","en_api_mp_math_point.md":"D7ZdR7VM","en_api_mp_math_segment.md":"DMW-YUfw","en_api_mp_math_utils.md":"B3i5gz_2","en_api_mp_math_vector.md":"CgtIoM4A","en_api_particle_index.md":"BfyNQiRg","en_api_presets_index.md":"BWb2fpTg","en_api_presets_model_index.md":"pbEu-669","en_guide_index.md":"DrDHTYCZ","en_index.md":"MCm69eyE","guide_index.md":"Cfmzk2IH","index.md":"BjJ9-kbE","ja_api_index.md":"CnUeuifx","ja_api_mp_math_angle.md":"DTK1PNuJ","ja_api_mp_math_const.md":"DGXAgDfn","ja_api_mp_math_equation.md":"Bt8bfjRZ","ja_api_mp_math_function.md":"Bx9H66-W","ja_api_mp_math_index.md":"CTZZ-p9Z","ja_api_mp_math_line.md":"DYJV4KNE","ja_api_mp_math_mp_math_typing.md":"BNymgrCT","ja_api_mp_math_plane.md":"D-yHaxP-","ja_api_mp_math_point.md":"DjHRkHI5","ja_api_mp_math_segment.md":"37V8kAc1","ja_api_mp_math_utils.md":"BbdhM1tp","ja_api_mp_math_vector.md":"BBVnCwJa","ja_api_particle_index.md":"Jr41Y3TS","ja_api_presets_index.md":"CQqdQbIZ","ja_api_presets_model_index.md":"C-Ypf-qh","ja_guide_index.md":"BxGnZYwR","ja_index.md":"CtozMsIU","zht_api_index.md":"CgZH6aHQ","zht_api_mp_math_angle.md":"lzcXwnW6","zht_api_mp_math_const.md":"xwQvuYck","zht_api_mp_math_equation.md":"Bn6MiQ1c","zht_api_mp_math_function.md":"C6pPUbwO","zht_api_mp_math_index.md":"mmeMMriu","zht_api_mp_math_line.md":"DX62bgjZ","zht_api_mp_math_mp_math_typing.md":"CNiSnuMw","zht_api_mp_math_plane.md":"DJ_9NQFz","zht_api_mp_math_point.md":"D1nAiRP0","zht_api_mp_math_segment.md":"CMRey-MG","zht_api_mp_math_utils.md":"BDpW2Fd4","zht_api_mp_math_vector.md":"DGVOQo3Y","zht_api_particle_index.md":"8GaGB1ul","zht_api_presets_index.md":"DvOViSox","zht_api_presets_model_index.md":"BJWX_k6K","zht_guide_index.md":"CsuFVFxu","zht_index.md":"V9U3SwDR"} diff --git a/index.html b/index.html index 6ca285f..f9fb065 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@
Skip to content

MBCP docs

More basic change particle

用于几何运算和粒子制作的库

文档由 VitePress 构建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/ja/api/index.html b/ja/api/index.html index fcd9569..7bef607 100644 --- a/ja/api/index.html +++ b/ja/api/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp

説明: 本模块塞了一些预设的粒子生成器

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp

説明: 本模块塞了一些预设的粒子生成器

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/mp_math/angle.html b/ja/api/mp_math/angle.html index c58f388..a7b8eab 100644 --- a/ja/api/mp_math/angle.html +++ b/ja/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

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

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

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

def self + other: AnyAngle => AnyAngle

ソースコード
python
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian + other.radian, is_radian=True)

def __eq__(self, other)

ソースコード
python
def __eq__(self, other):
+    return approx(self.radian, other.radian)

def self - other: AnyAngle => AnyAngle

ソースコード
python
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
+    return AnyAngle(self.radian - other.radian, is_radian=True)

def self * other: float => AnyAngle

ソースコード
python
def __mul__(self, other: float) -> 'AnyAngle':
+    return AnyAngle(self.radian * other, is_radian=True)

@overload

def self / other: float => AnyAngle

ソースコード
python
@overload
 def __truediv__(self, other: float) -> 'AnyAngle':
-    ...

@overload

method self / other: AnyAngle => float

ソースコード
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

ソースコード
python
@overload
 def __truediv__(self, other: 'AnyAngle') -> float:
-    ...

method self / other

ソースコード
python
def __truediv__(self, other):
+    ...

def self / other

ソースコード
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/const.html b/ja/api/mp_math/const.html index 4f112d0..f82d18d 100644 --- a/ja/api/mp_math/const.html +++ b/ja/api/mp_math/const.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.const

説明: 本模块定义了一些常用的常量

var PI = math.pi

  • 説明: 常量 π

var E = math.e

  • 説明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 説明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 説明: 欧拉常数

var EPSILON = 0.0001

  • 説明: 精度误差

var APPROX = 0.001

  • 説明: 约等于判定误差

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp.mp_math.const

説明: 本模块定义了一些常用的常量

var PI = math.pi

  • 説明: 常量 π

var E = math.e

  • 説明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 説明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 説明: 欧拉常数

var EPSILON = 0.0001

  • 説明: 精度误差

var APPROX = 0.001

  • 説明: 约等于判定误差

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/mp_math/equation.html b/ja/api/mp_math/equation.html index 9886498..1c8f91e 100644 --- a/ja/api/mp_math/equation.html +++ b/ja/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+    
Skip to content

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -27,7 +27,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:

戻り値: 目标点

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
+    self.z_func = z_func

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

引数:

  • *t:
  • 参数:

戻り値: 目标点

ソースコード
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -39,7 +39,7 @@
     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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

引数:

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

戻り値: 偏导函数

例外:

  • ValueError 无效变量类型
ソースコード
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

引数:

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

戻り値: 偏导函数

例外:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

引数:

  • func: 函数
  • *args: 参数

戻り値: 柯里化后的函数

ソースコード
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

引数:

  • func: 函数
  • *args: 参数

戻り値: 柯里化后的函数

ソースコード
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
@@ -97,7 +97,7 @@
         """@litedoc-hide"""
         return func(*args, *args2)
     return curried_func

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/function.html b/ja/api/mp_math/function.html index deddb73..7b308fe 100644 --- a/ja/api/mp_math/function.html +++ b/ja/api/mp_math/function.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.function

説明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

引数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

戻り値: 梯度

ソースコード
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    
Skip to content

mbcp.mp_math.function

説明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

引数:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

戻り値: 梯度

ソースコード
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
     """
     计算三元函数在某点的梯度向量。
     > [!tip]
@@ -34,7 +34,7 @@
     dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
     dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
     return Vector3(dx, dy, dz)

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/index.html b/ja/api/mp_math/index.html index b95ec3b..dca66e0 100644 --- a/ja/api/mp_math/index.html +++ b/ja/api/mp_math/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math

説明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp.mp_math

説明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/mp_math/line.html b/ja/api/mp_math/line.html index 72ece41..565050c 100644 --- a/ja/api/mp_math/line.html +++ b/ja/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.line

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

class Line3

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

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

引数:

  • point: 直线上的一点
  • direction: 直线的方向向量
ソースコード
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

mbcp.mp_math.line

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

class Line3

def __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

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

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

def 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.')

def 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

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

def 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

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

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

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

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

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

def 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

def 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

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

def __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)

def __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)

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ 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 adec204..33c907e 100644 --- a/ja/api/mp_math/mp_math_typing.html +++ b/ja/api/mp_math/mp_math_typing.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.mp_math_typing

説明: 本模块用于内部类型提示

var RealNumber = int | float

  • タイプ: TypeAlias

  • 説明: 实数

var Number = RealNumber | complex

  • タイプ: TypeAlias

  • 説明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 説明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 説明: 数组变量

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

  • 説明: 多元函数

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp.mp_math.mp_math_typing

説明: 本模块用于内部类型提示

var RealNumber = int | float

  • タイプ: TypeAlias

  • 説明: 实数

var Number = RealNumber | complex

  • タイプ: TypeAlias

  • 説明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 説明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 説明: 数组变量

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

  • 説明: 多元函数

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/mp_math/plane.html b/ja/api/mp_math/plane.html index 5e2bcc5..eacc4e4 100644 --- a/ja/api/mp_math/plane.html +++ b/ja/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.plane

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

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

mbcp.mp_math.plane

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

class Plane3

def __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

def 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

def 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)}')

def 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)}')

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

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

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

def 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

def 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

def 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

def 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

def 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

def 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

def __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

def __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):
+    ...

def __and__(self, other)

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

引数:

  • other:

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

ソースコード
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)}'")

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)

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/point.html b/ja/api/mp_math/point.html index c7a9e47..b611b91 100644 --- a/ja/api/mp_math/point.html +++ b/ja/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.point

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

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

mbcp.mp_math.point

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

class Point3

def __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

def 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

def self + other: Vector3 => Point3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Point3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

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

def __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)

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

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/segment.html b/ja/api/mp_math/segment.html index b6a0953..844c070 100644 --- a/ja/api/mp_math/segment.html +++ b/ja/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.segment

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

class Segment3

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

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

ソースコード
python
def __init__(self, p1: 'Point3', p2: 'Point3'):
+    
Skip to content

mbcp.mp_math.segment

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

class Segment3

def __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)

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/utils.html b/ja/api/mp_math/utils.html index 7c25d8d..752c0f7 100644 --- a/ja/api/mp_math/utils.html +++ b/ja/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

引数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

戻り値: 限制后的值

ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

引数:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

戻り値: 限制后的值

ソースコード
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,8 +28,8 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

ソースコード
python
def __init__(self, value: RealNumber):
+    self.value = value

def __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
@@ -39,9 +39,9 @@
         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)

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

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

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

戻り値: 是否近似相等

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

引数:

  • x: 数1
  • y: 数2
  • epsilon: 误差

戻り値: 是否近似相等

ソースコード
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
     """
     判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
     Args:
@@ -51,7 +51,7 @@
     Returns:
         是否近似相等
     """
-    return abs(x - y) < epsilon

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

説明: 获取数的符号。

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

説明: 获取数的符号。

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -64,7 +64,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

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

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

引数:

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

戻り値: 符号 + - ""

ソースコード
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = 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
@@ -81,7 +81,7 @@
         return f'-{abs(x)}'
     else:
         return ''

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/mp_math/vector.html b/ja/api/mp_math/vector.html index 634030d..b88c083 100644 --- a/ja/api/mp_math/vector.html +++ b/ja/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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

def 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])

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

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

def 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

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

def 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

def 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

def 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

def 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

def __abs__(self)

ソースコード
python
def __abs__(self):
+    return self.length

@overload

def self + other: Vector3 => Vector3

ソースコード
python
@overload
 def __add__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self + other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}'")

def __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)

def 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

def self - other: Vector3 => Vector3

ソースコード
python
@overload
 def __sub__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self - other: Point3 => Point3

ソースコード
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}"')

def 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

def self * other: Vector3 => Vector3

ソースコード
python
@overload
 def __mul__(self, other: 'Vector3') -> 'Vector3':
-    ...

@overload

method self * other: RealNumber => Vector3

ソースコード
python
@overload
+    ...

@overload

def 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':
+    ...

def 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)}'")

def self * other: RealNumber => Vector3

ソースコード
python
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
+    return self.__mul__(other)

def 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

def self / other: RealNumber => Vector3

ソースコード
python
def __truediv__(self, other: RealNumber) -> 'Vector3':
+    return Vector3(self.x / other, self.y / other, self.z / other)

def - 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轴单位向量

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/api/particle/index.html b/ja/api/particle/index.html index 50979c4..90da9ab 100644 --- a/ja/api/particle/index.html +++ b/ja/api/particle/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.particle

説明: 本模块定义了粒子生成相关的工具

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp.particle

説明: 本模块定义了粒子生成相关的工具

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/presets/index.html b/ja/api/presets/index.html index 8b5ea3e..e154c81 100644 --- a/ja/api/presets/index.html +++ b/ja/api/presets/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.presets

説明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

mbcp.presets

説明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/api/presets/model/index.html b/ja/api/presets/model/index.html index 3b933c3..a2504ba 100644 --- a/ja/api/presets/model/index.html +++ b/ja/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

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

引数:

  • radius:
  • density:

戻り値: List[Point3]: 球体上的点集。

ソースコード
python
@staticmethod
+    
Skip to content

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

引数:

  • radius:
  • density:

戻り値: List[Point3]: 球体上的点集。

ソースコード
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)]

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/ja/guide/index.html b/ja/guide/index.html index 17b2f07..6e22213 100644 --- a/ja/guide/index.html +++ b/ja/guide/index.html @@ -17,8 +17,8 @@ -
Skip to content

开始不了一点

12x111

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- +
Skip to content

开始不了一点

12x111

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

+ \ No newline at end of file diff --git a/ja/index.html b/ja/index.html index f9213c8..272acdd 100644 --- a/ja/index.html +++ b/ja/index.html @@ -18,7 +18,7 @@
Skip to content

MBCP docs

More basic change particle

ジオメトリ演算とパーティクル作成のためのライブラリ

VitePress で構築されたドキュメント | litedoc によって生成されたAPIリファレンス

- + \ No newline at end of file diff --git a/zht/api/index.html b/zht/api/index.html index a08b205..5f70636 100644 --- a/zht/api/index.html +++ b/zht/api/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp

説明: 本模块塞了一些预设的粒子生成器

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

mbcp

説明: 本模块塞了一些预设的粒子生成器

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/api/mp_math/angle.html b/zht/api/mp_math/angle.html index 3bdddc5..7409d62 100644 --- a/zht/api/mp_math/angle.html +++ b/zht/api/mp_math/angle.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

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

mbcp.mp_math.angle

説明: 本模块定义了角度相关的类

class Angle

class AnyAngle(Angle)

def __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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

def 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

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

def self + other: AnyAngle => AnyAngle

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

def __eq__(self, other)

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

def self - other: AnyAngle => AnyAngle

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

def self * other: float => AnyAngle

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

@overload

def self / other: float => AnyAngle

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

@overload

method self / other: AnyAngle => float

源碼
python
@overload
+    ...

@overload

def self / other: AnyAngle => float

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

method self / other

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

def self / other

源碼
python
def __truediv__(self, other):
     if isinstance(other, AnyAngle):
         return self.radian / other.radian
     return AnyAngle(self.radian / other, is_radian=True)

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/const.html b/zht/api/mp_math/const.html index 571196d..76484cc 100644 --- a/zht/api/mp_math/const.html +++ b/zht/api/mp_math/const.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.const

説明: 本模块定义了一些常用的常量

var PI = math.pi

  • 説明: 常量 π

var E = math.e

  • 説明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 説明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 説明: 欧拉常数

var EPSILON = 0.0001

  • 説明: 精度误差

var APPROX = 0.001

  • 説明: 约等于判定误差

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math.const

説明: 本模块定义了一些常用的常量

var PI = math.pi

  • 説明: 常量 π

var E = math.e

  • 説明: 自然对数的底 exp(1)

var GOLDEN_RATIO = (1 + math.sqrt(5)) / 2

  • 説明: 黄金分割比

var GAMMA = 0.5772156649015329

  • 説明: 欧拉常数

var EPSILON = 0.0001

  • 説明: 精度误差

var APPROX = 0.001

  • 説明: 约等于判定误差

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/api/mp_math/equation.html b/zht/api/mp_math/equation.html index b86fd12..30b6bbf 100644 --- a/zht/api/mp_math/equation.html +++ b/zht/api/mp_math/equation.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

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):
+    
Skip to content

mbcp.mp_math.equation

説明: 本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

def __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:
@@ -27,7 +27,7 @@
         """
     self.x_func = x_func
     self.y_func = y_func
-    self.z_func = z_func

method __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:

返回: 目标点

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

def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

  • *t:
  • 参数:

返回: 目标点

源碼
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
     """
         计算曲线上的点。
         Args:
@@ -39,7 +39,7 @@
     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))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

變數説明:

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

返回: 偏导函数

抛出:

  • ValueError 无效变量类型
源碼
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
+        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 get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

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

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

變數説明:

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

返回: 偏导函数

抛出:

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

func curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

變數説明:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源碼
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
+        raise ValueError('Invalid var type')

def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc

説明: 对多参数函数进行柯里化。

TIP

有关函数柯里化,可参考函数式编程--柯理化(Currying)

變數説明:

  • func: 函数
  • *args: 参数

返回: 柯里化后的函数

源碼
python
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
     """
     对多参数函数进行柯里化。
     > [!tip]
@@ -97,7 +97,7 @@
         """@litedoc-hide"""
         return func(*args, *args2)
     return curried_func

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/function.html b/zht/api/mp_math/function.html index 11d5766..24c6474 100644 --- a/zht/api/mp_math/function.html +++ b/zht/api/mp_math/function.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.function

説明: AAA

func cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

變數説明:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源碼
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
+    
Skip to content

mbcp.mp_math.function

説明: AAA

def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3

説明: 计算三元函数在某点的梯度向量。

TIP

已知一个函数f(x,y,z),则其在点(x0,y0,z0)处的梯度向量为: f(x0,y0,z0)=(fx,fy,fz)

變數説明:

  • func: 三元函数
  • p: 点
  • epsilon: 偏移量

返回: 梯度

源碼
python
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float=EPSILON) -> Vector3:
     """
     计算三元函数在某点的梯度向量。
     > [!tip]
@@ -34,7 +34,7 @@
     dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
     dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
     return Vector3(dx, dy, dz)

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/index.html b/zht/api/mp_math/index.html index 9bae1c4..727e610 100644 --- a/zht/api/mp_math/index.html +++ b/zht/api/mp_math/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math

説明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math

説明: 本包定义了一些常用的导入,可直接从mbcp.mp_math导入使用 导入的类有:

  • AnyAngle:任意角
  • CurveEquation:曲线方程
  • Line3:三维直线
  • Plane3:三维平面
  • Point3:三维点
  • Segment3:三维线段
  • Vector3:三维向量

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/api/mp_math/line.html b/zht/api/mp_math/line.html index 3dae8a5..2429d44 100644 --- a/zht/api/mp_math/line.html +++ b/zht/api/mp_math/line.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.line

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

class Line3

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

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

變數説明:

  • point: 直线上的一点
  • direction: 直线的方向向量
源碼
python
def __init__(self, point: 'Point3', direction: 'Vector3'):
+    
Skip to content

mbcp.mp_math.line

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

class Line3

def __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

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

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

def 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.')

def 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

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

def 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

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

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

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

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

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

def 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

def 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

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

def __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)

def __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)

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ 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 aa369d1..b6349c9 100644 --- a/zht/api/mp_math/mp_math_typing.html +++ b/zht/api/mp_math/mp_math_typing.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.mp_math.mp_math_typing

説明: 本模块用于内部类型提示

var RealNumber = int | float

  • 類型: TypeAlias

  • 説明: 实数

var Number = RealNumber | complex

  • 類型: TypeAlias

  • 説明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 説明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 説明: 数组变量

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

  • 説明: 多元函数

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.mp_math.mp_math_typing

説明: 本模块用于内部类型提示

var RealNumber = int | float

  • 類型: TypeAlias

  • 説明: 实数

var Number = RealNumber | complex

  • 類型: TypeAlias

  • 説明: 数

var SingleVar = TypeVar('SingleVar', bound=Number)

  • 説明: 单变量

var ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])

  • 説明: 数组变量

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

  • 説明: 多元函数

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/api/mp_math/plane.html b/zht/api/mp_math/plane.html index a4aa312..6a51964 100644 --- a/zht/api/mp_math/plane.html +++ b/zht/api/mp_math/plane.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.plane

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

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

mbcp.mp_math.plane

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

class Plane3

def __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

def 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

def 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)}')

def 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)}')

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

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

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

def 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

def 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

def 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

def 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

def 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

def 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

def __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

def __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):
+    ...

def __and__(self, other)

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

變數説明:

  • other:

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

源碼
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)}'")

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)

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/point.html b/zht/api/mp_math/point.html index 2d19188..0f079ff 100644 --- a/zht/api/mp_math/point.html +++ b/zht/api/mp_math/point.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.point

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

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

mbcp.mp_math.point

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

class Point3

def __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

def 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

def self + other: Vector3 => Point3

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

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

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

def __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)

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

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/segment.html b/zht/api/mp_math/segment.html index 356df51..0d4a657 100644 --- a/zht/api/mp_math/segment.html +++ b/zht/api/mp_math/segment.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.segment

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

class Segment3

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

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

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

mbcp.mp_math.segment

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

class Segment3

def __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)

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/utils.html b/zht/api/mp_math/utils.html index 08e7e58..e64c2dc 100644 --- a/zht/api/mp_math/utils.html +++ b/zht/api/mp_math/utils.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

func clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

變數説明:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
+    
Skip to content

mbcp.mp_math.utils

説明: 本模块定义了一些常用的工具函数

def clamp(x: float, min_: float, max_: float) -> float

説明: 区间限定函数

變數説明:

  • x: 待限定的值
  • min_: 最小值
  • max_: 最大值

返回: 限制后的值

源碼
python
def clamp(x: float, min_: float, max_: float) -> float:
     """
     区间限定函数
     Args:
@@ -28,8 +28,8 @@
     Returns:
         限制后的值
     """
-    return max(min(x, max_), min_)

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 max(min(x, max_), min_)

class Approx

def __init__(self, value: RealNumber)

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

def __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
@@ -39,9 +39,9 @@
         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)

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

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

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

源碼
python
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
+            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)

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

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

變數説明:

  • x: 数1
  • y: 数2
  • epsilon: 误差

返回: 是否近似相等

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

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

説明: 获取数的符号。

變數説明:

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

返回: 符号 + - ""

源碼
python
def sign(x: float, only_neg: bool=False) -> str:
+    return abs(x - y) < epsilon

def sign(x: float, only_neg: bool = False) -> str

説明: 获取数的符号。

變數説明:

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

返回: 符号 + - ""

源碼
python
def sign(x: float, only_neg: bool=False) -> str:
     """获取数的符号。
     Args:
         x: 数
@@ -64,7 +64,7 @@
     elif x < 0:
         return '-'
     else:
-        return ''

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

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

變數説明:

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

返回: 符号 + - ""

源碼
python
def sign_format(x: float, only_neg: bool=False) -> str:
+        return ''

def sign_format(x: float, only_neg: bool = 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
@@ -81,7 +81,7 @@
         return f'-{abs(x)}'
     else:
         return ''

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/mp_math/vector.html b/zht/api/mp_math/vector.html index ad63774..b669081 100644 --- a/zht/api/mp_math/vector.html +++ b/zht/api/mp_math/vector.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

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

mbcp.mp_math.vector

説明: 本模块定义了3维向量的类Vector3,以及一些常用的向量。

class Vector3

def __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

def 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])

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

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

def 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

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

def 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

def 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

def 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

def 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

def __abs__(self)

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

@overload

def self + other: Vector3 => Vector3

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

@overload

method self + other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}'")

def __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)

def 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

def self - other: Vector3 => Vector3

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

@overload

method self - other: Point3 => Point3

源碼
python
@overload
+    ...

@overload

def 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):
+    ...

def 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)}"')

def 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

def self * other: Vector3 => Vector3

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

@overload

method self * other: RealNumber => Vector3

源碼
python
@overload
+    ...

@overload

def 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':
+    ...

def 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)}'")

def self * other: RealNumber => Vector3

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

def 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

def self / other: RealNumber => Vector3

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

def - 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轴单位向量

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/api/particle/index.html b/zht/api/particle/index.html index 5657670..11a51e0 100644 --- a/zht/api/particle/index.html +++ b/zht/api/particle/index.html @@ -17,8 +17,8 @@ - - + + \ No newline at end of file diff --git a/zht/api/presets/index.html b/zht/api/presets/index.html index 7f7face..209a505 100644 --- a/zht/api/presets/index.html +++ b/zht/api/presets/index.html @@ -17,8 +17,8 @@ -
Skip to content

mbcp.presets

説明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

mbcp.presets

説明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/12 下午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : init.py @Software: PyCharm

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/api/presets/model/index.html b/zht/api/presets/model/index.html index a47c2e1..698ab1d 100644 --- a/zht/api/presets/model/index.html +++ b/zht/api/presets/model/index.html @@ -12,12 +12,12 @@ - + -
Skip to content

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

method sphere(radius: float, density: float)

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

變數説明:

  • radius:
  • density:

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

源碼
python
@staticmethod
+    
Skip to content

mbcp.presets.model

説明: 几何模型点集

class GeometricModels

@staticmethod

def sphere(radius: float, density: float)

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

變數説明:

  • radius:
  • density:

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

源碼
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)]

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file diff --git a/zht/guide/index.html b/zht/guide/index.html index 991587c..bf837fe 100644 --- a/zht/guide/index.html +++ b/zht/guide/index.html @@ -17,8 +17,8 @@ -
Skip to content

开始不了一点

12x111

文檔由 VitePress 構建 | API引用由 litedoc 生成

- +
Skip to content

开始不了一点

12x111

文檔由 VitePress 構建 | API引用由 litedoc 生成

+ \ No newline at end of file diff --git a/zht/index.html b/zht/index.html index 124b40e..8fb156d 100644 --- a/zht/index.html +++ b/zht/index.html @@ -18,7 +18,7 @@
Skip to content

MBCP docs

More basic change particle

用於幾何運算和粒子製作的軟體庫

文檔由 VitePress 構建 | API引用由 litedoc 生成

- + \ No newline at end of file