mirror of
https://github.com/snowykami/mbcp.git
synced 2025-08-03 04:00:00 +00:00
📝 litedoc新增类继承显示,新增变量自动获取注释,新增类方法和函数的区分,新增魔术方法的特殊展示模式
This commit is contained in:
@ -1,16 +1,14 @@
|
||||
---
|
||||
title: mbcp.mp_math.angle
|
||||
---
|
||||
### ***class*** `Angle`
|
||||
|
||||
### ***class*** `AnyAngle`
|
||||
|
||||
### *def* `__init__(self, value: float, is_radian: bool = False)`
|
||||
### **class** `Angle`
|
||||
### **class** `AnyAngle(Angle)`
|
||||
### *method* `__init__(self, value: float, is_radian: bool = False)`
|
||||
|
||||
|
||||
任意角度。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- value: 角度或弧度值
|
||||
|
||||
@ -19,7 +17,7 @@ title: mbcp.mp_math.angle
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, value: float, is_radian: bool=False):
|
||||
@ -37,19 +35,19 @@ def __init__(self, value: float, is_radian: bool=False):
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `complementary(self) -> 'AnyAngle'`
|
||||
### *method* `complementary(self) -> AnyAngle`
|
||||
|
||||
|
||||
余角:两角的和为90°。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 余角
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -64,19 +62,19 @@ def complementary(self) -> 'AnyAngle':
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `supplementary(self) -> 'AnyAngle'`
|
||||
### *method* `supplementary(self) -> AnyAngle`
|
||||
|
||||
|
||||
补角:两角的和为180°。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 补角
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -91,19 +89,19 @@ def supplementary(self) -> 'AnyAngle':
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `degree(self) -> float`
|
||||
### *method* `degree(self) -> float`
|
||||
|
||||
|
||||
角度。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 弧度
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -118,19 +116,19 @@ def degree(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `minimum_positive(self) -> 'AnyAngle'`
|
||||
### *method* `minimum_positive(self) -> AnyAngle`
|
||||
|
||||
|
||||
最小正角。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 最小正角度
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -145,19 +143,19 @@ def minimum_positive(self) -> 'AnyAngle':
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `maximum_negative(self) -> 'AnyAngle'`
|
||||
### *method* `maximum_negative(self) -> AnyAngle`
|
||||
|
||||
|
||||
最大负角。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 最大负角度
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -172,19 +170,19 @@ def maximum_negative(self) -> 'AnyAngle':
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `sin(self) -> float`
|
||||
### *method* `sin(self) -> float`
|
||||
|
||||
|
||||
正弦值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 正弦值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -199,19 +197,19 @@ def sin(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `cos(self) -> float`
|
||||
### *method* `cos(self) -> float`
|
||||
|
||||
|
||||
余弦值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 余弦值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -226,19 +224,19 @@ def cos(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `tan(self) -> float`
|
||||
### *method* `tan(self) -> float`
|
||||
|
||||
|
||||
正切值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 正切值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -253,19 +251,19 @@ def tan(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `cot(self) -> float`
|
||||
### *method* `cot(self) -> float`
|
||||
|
||||
|
||||
余切值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 余切值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -280,19 +278,19 @@ def cot(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `sec(self) -> float`
|
||||
### *method* `sec(self) -> float`
|
||||
|
||||
|
||||
正割值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 正割值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -307,19 +305,19 @@ def sec(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `csc(self) -> float`
|
||||
### *method* `csc(self) -> float`
|
||||
|
||||
|
||||
余割值。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 余割值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -333,11 +331,11 @@ def csc(self) -> float:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__add__(self, other: 'AnyAngle') -> 'AnyAngle'`
|
||||
### *method* `self + other: AnyAngle => AnyAngle`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
|
||||
@ -345,11 +343,11 @@ def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other)`
|
||||
### *method* `__eq__(self, other)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other):
|
||||
@ -357,11 +355,11 @@ def __eq__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__sub__(self, other: 'AnyAngle') -> 'AnyAngle'`
|
||||
### *method* `self - other: AnyAngle => AnyAngle`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
|
||||
@ -369,11 +367,11 @@ def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__mul__(self, other: float) -> 'AnyAngle'`
|
||||
### *method* `self * other: float => AnyAngle`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __mul__(self, other: float) -> 'AnyAngle':
|
||||
@ -381,36 +379,12 @@ def __mul__(self, other: float) -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__repr__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __repr__(self):
|
||||
return f'AnyAngle({self.radian}, is_radian=True)'
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
return f'AnyAngle({self.degree}° or {self.radian} rad)'
|
||||
```
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__truediv__(self, other: float) -> 'AnyAngle'`
|
||||
### *method* `self / other: float => AnyAngle`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -420,11 +394,11 @@ def __truediv__(self, other: float) -> 'AnyAngle':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__truediv__(self, other: 'AnyAngle') -> float`
|
||||
### *method* `self / other: AnyAngle => float`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -433,11 +407,11 @@ def __truediv__(self, other: 'AnyAngle') -> float:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__truediv__(self, other)`
|
||||
### *method* `self / other`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __truediv__(self, other):
|
||||
|
@ -1,15 +1,3 @@
|
||||
---
|
||||
title: mbcp.mp_math.const
|
||||
---
|
||||
### ***var*** `PI = math.pi`
|
||||
|
||||
### ***var*** `E = math.e`
|
||||
|
||||
### ***var*** `GOLDEN_RATIO = (1 + math.sqrt(5)) / 2`
|
||||
|
||||
### ***var*** `GAMMA = 0.5772156649015329`
|
||||
|
||||
### ***var*** `EPSILON = 0.0001`
|
||||
|
||||
### ***var*** `APPROX = 0.001`
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
---
|
||||
title: mbcp.mp_math.equation
|
||||
---
|
||||
### *def* `get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc`
|
||||
### *func* `get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc`
|
||||
|
||||
|
||||
求N元函数一阶偏导函数。这玩意不太稳定,慎用。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- func: 函数
|
||||
|
||||
@ -14,10 +14,18 @@ title: mbcp.mp_math.equation
|
||||
|
||||
- epsilon: 偏移量
|
||||
|
||||
**返回**:
|
||||
|
||||
- 偏导函数
|
||||
|
||||
**引发**:
|
||||
|
||||
- ValueError 无效变量类型
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
|
||||
@ -54,11 +62,11 @@ def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...],
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `partial_derivative_func() -> Var`
|
||||
### *func* `partial_derivative_func() -> Var`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def partial_derivative_func(*args: Var) -> Var:
|
||||
@ -70,11 +78,11 @@ def partial_derivative_func(*args: Var) -> Var:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `high_order_partial_derivative_func() -> Var`
|
||||
### *func* `high_order_partial_derivative_func() -> Var`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def high_order_partial_derivative_func(*args: Var) -> Var:
|
||||
@ -85,14 +93,13 @@ def high_order_partial_derivative_func(*args: Var) -> Var:
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***class*** `CurveEquation`
|
||||
|
||||
### *def* `__init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)`
|
||||
### **class** `CurveEquation`
|
||||
### *method* `__init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)`
|
||||
|
||||
|
||||
曲线方程。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x_func: x函数
|
||||
|
||||
@ -103,7 +110,7 @@ def high_order_partial_derivative_func(*args: Var) -> Var:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
|
||||
@ -120,12 +127,12 @@ def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__call__(self) -> Point3 | tuple[Point3, ...]`
|
||||
### *method* `__call__(self) -> Point3 | tuple[Point3, ...]`
|
||||
|
||||
|
||||
计算曲线上的点。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- *t:
|
||||
|
||||
@ -134,7 +141,7 @@ def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
|
||||
@ -153,17 +160,3 @@ def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
return 'CurveEquation()'
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***var*** `result_func = get_partial_derivative_func(result_func, v, epsilon)`
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
---
|
||||
title: mbcp.mp_math.line
|
||||
---
|
||||
### ***class*** `Line3`
|
||||
|
||||
### *def* `__init__(self, point: 'Point3', direction: 'Vector3')`
|
||||
### **class** `Line3`
|
||||
### *method* `__init__(self, point: Point3, direction: Vector3)`
|
||||
|
||||
|
||||
三维空间中的直线。由一个点和一个方向向量确定。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 直线上的一点
|
||||
|
||||
@ -17,7 +16,7 @@ title: mbcp.mp_math.line
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, point: 'Point3', direction: 'Vector3'):
|
||||
@ -32,21 +31,25 @@ def __init__(self, point: 'Point3', direction: 'Vector3'):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `approx(self, other: 'Line3', epsilon: float = APPROX) -> bool`
|
||||
### *method* `approx(self, other: Line3, epsilon: float = APPROX) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否近似相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
- epsilon: 误差
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
|
||||
@ -62,19 +65,27 @@ def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_angle(self, other: 'Line3') -> 'AnyAngle'`
|
||||
### *method* `cal_angle(self, other: Line3) -> AnyAngle`
|
||||
|
||||
|
||||
计算直线和直线之间的夹角。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 夹角弧度
|
||||
|
||||
**引发**:
|
||||
|
||||
- TypeError 不支持的类型
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_angle(self, other: 'Line3') -> 'AnyAngle':
|
||||
@ -91,19 +102,27 @@ def cal_angle(self, other: 'Line3') -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_distance(self, other: 'Line3 | Point3') -> float`
|
||||
### *method* `cal_distance(self, other: Line3 | Point3) -> float`
|
||||
|
||||
|
||||
计算直线和直线或点之间的距离。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 平行直线或点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 距离
|
||||
|
||||
**引发**:
|
||||
|
||||
- TypeError 不支持的类型
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_distance(self, other: 'Line3 | Point3') -> float:
|
||||
@ -133,19 +152,29 @@ def cal_distance(self, other: 'Line3 | Point3') -> float:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_intersection(self, other: 'Line3') -> 'Point3'`
|
||||
### *method* `cal_intersection(self, other: Line3) -> Point3`
|
||||
|
||||
|
||||
计算两条直线的交点。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 交点
|
||||
|
||||
**引发**:
|
||||
|
||||
- ValueError 直线平行
|
||||
|
||||
- ValueError 直线不共面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_intersection(self, other: 'Line3') -> 'Point3':
|
||||
@ -167,19 +196,23 @@ def cal_intersection(self, other: 'Line3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_perpendicular(self, point: 'Point3') -> 'Line3'`
|
||||
### *method* `cal_perpendicular(self, point: Point3) -> Line3`
|
||||
|
||||
|
||||
计算直线经过指定点p的垂线。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 指定点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 垂线
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_perpendicular(self, point: 'Point3') -> 'Line3':
|
||||
@ -194,19 +227,23 @@ def cal_perpendicular(self, point: 'Point3') -> 'Line3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `get_point(self, t: RealNumber) -> 'Point3'`
|
||||
### *method* `get_point(self, t: RealNumber) -> Point3`
|
||||
|
||||
|
||||
获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- t: 参数t
|
||||
|
||||
**返回**:
|
||||
|
||||
- 点
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def get_point(self, t: RealNumber) -> 'Point3':
|
||||
@ -221,19 +258,19 @@ def get_point(self, t: RealNumber) -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]`
|
||||
### *method* `get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]`
|
||||
|
||||
|
||||
获取直线的参数方程。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- x(t), y(t), z(t)
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]:
|
||||
@ -246,21 +283,25 @@ def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc,
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06) -> bool`
|
||||
### *method* `is_approx_parallel(self, other: Line3, epsilon: float = 1e-06) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否近似平行。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
- epsilon: 误差
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似平行
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
|
||||
@ -276,19 +317,23 @@ def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_parallel(self, other: 'Line3') -> bool`
|
||||
### *method* `is_parallel(self, other: Line3) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否平行。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否平行
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_parallel(self, other: 'Line3') -> bool:
|
||||
@ -303,19 +348,23 @@ def is_parallel(self, other: 'Line3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_collinear(self, other: 'Line3') -> bool`
|
||||
### *method* `is_collinear(self, other: Line3) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否共线。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否共线
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_collinear(self, other: 'Line3') -> bool:
|
||||
@ -330,19 +379,23 @@ def is_collinear(self, other: 'Line3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_point_on(self, point: 'Point3') -> bool`
|
||||
### *method* `is_point_on(self, point: Point3) -> bool`
|
||||
|
||||
|
||||
判断点是否在直线上。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否在直线上
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_point_on(self, point: 'Point3') -> bool:
|
||||
@ -357,20 +410,24 @@ def is_point_on(self, point: 'Point3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_coplanar(self, other: 'Line3') -> bool`
|
||||
### *method* `is_coplanar(self, other: Line3) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否共面。
|
||||
充要条件:两直线方向向量的叉乘与两直线上任意一点的向量的点积为0。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否共面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_coplanar(self, other: 'Line3') -> bool:
|
||||
@ -386,7 +443,7 @@ def is_coplanar(self, other: 'Line3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `simplify(self)`
|
||||
### *method* `simplify(self)`
|
||||
|
||||
|
||||
简化直线方程,等价相等。
|
||||
@ -397,7 +454,7 @@ def is_coplanar(self, other: 'Line3') -> bool:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def simplify(self):
|
||||
@ -418,21 +475,25 @@ def simplify(self):
|
||||
</details>
|
||||
|
||||
### `@classmethod`
|
||||
### *def* `from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3'`
|
||||
### *method* `from_two_points(cls, p1: Point3, p2: Point3) -> Line3`
|
||||
|
||||
|
||||
工厂函数 由两点构造直线。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- p1: 点1
|
||||
|
||||
- p2: 点2
|
||||
|
||||
**返回**:
|
||||
|
||||
- 直线
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@classmethod
|
||||
@ -450,19 +511,23 @@ def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__and__(self, other: 'Line3') -> 'Line3 | Point3 | None'`
|
||||
### *method* `__and__(self, other: Line3) -> Line3 | Point3 | None`
|
||||
|
||||
|
||||
计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一条直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 交点
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
|
||||
@ -482,21 +547,21 @@ def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other) -> bool`
|
||||
### *method* `__eq__(self, other) -> bool`
|
||||
|
||||
|
||||
判断两条直线是否等价。
|
||||
|
||||
v1 // v2 ∧ (p1 - p2) // v1
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other) -> bool:
|
||||
@ -514,43 +579,3 @@ def __eq__(self, other) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
"""
|
||||
返回点向式(x-x0)
|
||||
Returns:
|
||||
|
||||
"""
|
||||
s = 'Line3: '
|
||||
if self.direction.x != 0:
|
||||
s += f'(x{sign_format(-self.point.x)})/{self.direction.x}'
|
||||
if self.direction.y != 0:
|
||||
s += f' = (y{sign_format(-self.point.y)})/{self.direction.y}'
|
||||
if self.direction.z != 0:
|
||||
s += f' = (z{sign_format(-self.point.z)})/{self.direction.z}'
|
||||
return s
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__repr__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __repr__(self):
|
||||
return f'Line3({self.point}, {self.direction})'
|
||||
```
|
||||
</details>
|
||||
|
||||
|
@ -1,37 +1,63 @@
|
||||
---
|
||||
title: mbcp.mp_math.mp_math_typing
|
||||
---
|
||||
### ***var*** `RealNumber: TypeAlias = int | float`
|
||||
### ***var*** `RealNumber = int | float`
|
||||
|
||||
### ***var*** `Number: TypeAlias = RealNumber | complex`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `SingleVar = TypeVar('SingleVar', bound=Number)`
|
||||
### ***var*** `Number = RealNumber | complex`
|
||||
|
||||
### ***var*** `ArrayVar = TypeVar('ArrayVar', bound=Iterable[Number])`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `Var: TypeAlias = SingleVar | ArrayVar`
|
||||
### ***var*** `Var = SingleVar | ArrayVar`
|
||||
|
||||
### ***var*** `OneSingleVarFunc: TypeAlias = Callable[[SingleVar], SingleVar]`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `OneArrayFunc: TypeAlias = Callable[[ArrayVar], ArrayVar]`
|
||||
### ***var*** `OneSingleVarFunc = Callable[[SingleVar], SingleVar]`
|
||||
|
||||
### ***var*** `OneVarFunc: TypeAlias = OneSingleVarFunc | OneArrayFunc`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `TwoSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar], SingleVar]`
|
||||
### ***var*** `OneArrayFunc = Callable[[ArrayVar], ArrayVar]`
|
||||
|
||||
### ***var*** `TwoArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar], ArrayVar]`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `TwoVarsFunc: TypeAlias = TwoSingleVarsFunc | TwoArraysFunc`
|
||||
### ***var*** `OneVarFunc = OneSingleVarFunc | OneArrayFunc`
|
||||
|
||||
### ***var*** `ThreeSingleVarsFunc: TypeAlias = Callable[[SingleVar, SingleVar, SingleVar], SingleVar]`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `ThreeArraysFunc: TypeAlias = Callable[[ArrayVar, ArrayVar, ArrayVar], ArrayVar]`
|
||||
### ***var*** `TwoSingleVarsFunc = Callable[[SingleVar, SingleVar], SingleVar]`
|
||||
|
||||
### ***var*** `ThreeVarsFunc: TypeAlias = ThreeSingleVarsFunc | ThreeArraysFunc`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `MultiSingleVarsFunc: TypeAlias = Callable[..., SingleVar]`
|
||||
### ***var*** `TwoArraysFunc = Callable[[ArrayVar, ArrayVar], ArrayVar]`
|
||||
|
||||
### ***var*** `MultiArraysFunc: TypeAlias = Callable[..., ArrayVar]`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `MultiVarsFunc: TypeAlias = MultiSingleVarsFunc | MultiArraysFunc`
|
||||
### ***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`
|
||||
|
||||
|
@ -1,37 +1,36 @@
|
||||
---
|
||||
title: mbcp.mp_math.plane
|
||||
---
|
||||
### ***class*** `Plane3`
|
||||
|
||||
### *def* `__init__(self, a: float, b: float, c: float, d: float)`
|
||||
### **class** `Plane3`
|
||||
### *method* `__init__(self, a: float, b: float, c: float, d: float)`
|
||||
|
||||
|
||||
平面方程:ax + by + cz + d = 0
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- a:
|
||||
- a: x系数
|
||||
|
||||
- b:
|
||||
- b: y系数
|
||||
|
||||
- c:
|
||||
- c: z系数
|
||||
|
||||
- d:
|
||||
- d: 常数项
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, a: float, b: float, c: float, d: float):
|
||||
"""
|
||||
平面方程:ax + by + cz + d = 0
|
||||
Args:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
d:
|
||||
a: x系数
|
||||
b: y系数
|
||||
c: z系数
|
||||
d: 常数项
|
||||
"""
|
||||
self.a = a
|
||||
self.b = b
|
||||
@ -40,31 +39,33 @@ def __init__(self, a: float, b: float, c: float, d: float):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `approx(self, other: 'Plane3') -> bool`
|
||||
### *method* `approx(self, other: Plane3) -> bool`
|
||||
|
||||
|
||||
判断两个平面是否近似相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
- other: 另一个平面
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def approx(self, other: 'Plane3') -> bool:
|
||||
"""
|
||||
判断两个平面是否近似相等。
|
||||
Args:
|
||||
other:
|
||||
|
||||
other: 另一个平面
|
||||
Returns:
|
||||
是否近似相等
|
||||
"""
|
||||
a = 3
|
||||
if self.a != 0:
|
||||
k = other.a / self.a
|
||||
return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
|
||||
@ -79,19 +80,27 @@ def approx(self, other: 'Plane3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle'`
|
||||
### *method* `cal_angle(self, other: Line3 | Plane3) -> AnyAngle`
|
||||
|
||||
|
||||
计算平面与平面之间的夹角。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个平面
|
||||
|
||||
**返回**:
|
||||
|
||||
- 夹角弧度
|
||||
|
||||
**引发**:
|
||||
|
||||
- TypeError 不支持的类型
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
|
||||
@ -113,19 +122,27 @@ def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_distance(self, other: 'Plane3 | Point3') -> float`
|
||||
### *method* `cal_distance(self, other: Plane3 | Point3) -> float`
|
||||
|
||||
|
||||
计算平面与平面或点之间的距离。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个平面或点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 距离
|
||||
|
||||
**引发**:
|
||||
|
||||
- TypeError 不支持的类型
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_distance(self, other: 'Plane3 | Point3') -> float:
|
||||
@ -147,28 +164,32 @@ def cal_distance(self, other: 'Plane3 | Point3') -> float:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_intersection_line3(self, other: 'Plane3') -> 'Line3'`
|
||||
### *method* `cal_intersection_line3(self, other: Plane3) -> Line3`
|
||||
|
||||
|
||||
计算两平面的交线。该方法有问题,待修复。
|
||||
计算两平面的交线。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个平面
|
||||
|
||||
**返回**:
|
||||
|
||||
- 两平面的交线
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
|
||||
"""
|
||||
计算两平面的交线。该方法有问题,待修复。
|
||||
计算两平面的交线。
|
||||
Args:
|
||||
other: 另一个平面
|
||||
Returns:
|
||||
交线
|
||||
两平面的交线
|
||||
Raises:
|
||||
"""
|
||||
if self.normal.is_parallel(other.normal):
|
||||
@ -191,19 +212,27 @@ def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_intersection_point3(self, other: 'Line3') -> 'Point3'`
|
||||
### *method* `cal_intersection_point3(self, other: Line3) -> Point3`
|
||||
|
||||
|
||||
计算平面与直线的交点。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 不与平面平行或在平面上的直线
|
||||
|
||||
**返回**:
|
||||
|
||||
- 交点
|
||||
|
||||
**引发**:
|
||||
|
||||
- ValueError 平面与直线平行或重合
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
|
||||
@ -224,19 +253,23 @@ def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_parallel_plane3(self, point: 'Point3') -> 'Plane3'`
|
||||
### *method* `cal_parallel_plane3(self, point: Point3) -> Plane3`
|
||||
|
||||
|
||||
计算平行于该平面且过指定点的平面。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 指定点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 所求平面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
|
||||
@ -245,25 +278,29 @@ def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
|
||||
Args:
|
||||
point: 指定点
|
||||
Returns:
|
||||
平面
|
||||
所求平面
|
||||
"""
|
||||
return Plane3.from_point_and_normal(point, self.normal)
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_parallel(self, other: 'Plane3') -> bool`
|
||||
### *method* `is_parallel(self, other: Plane3) -> bool`
|
||||
|
||||
|
||||
判断两个平面是否平行。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个平面
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否平行
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_parallel(self, other: 'Plane3') -> bool:
|
||||
@ -279,19 +316,19 @@ def is_parallel(self, other: 'Plane3') -> bool:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `normal(self) -> 'Vector3'`
|
||||
### *method* `normal(self) -> Vector3`
|
||||
|
||||
|
||||
平面的法向量。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 法向量
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -306,21 +343,25 @@ def normal(self) -> 'Vector3':
|
||||
</details>
|
||||
|
||||
### `@classmethod`
|
||||
### *def* `from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3'`
|
||||
### *method* `from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3`
|
||||
|
||||
|
||||
工厂函数 由点和法向量构造平面(点法式构造)。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 平面上的一点
|
||||
|
||||
- normal: 法向量
|
||||
|
||||
**返回**:
|
||||
|
||||
- 平面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@classmethod
|
||||
@ -340,12 +381,12 @@ def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
|
||||
</details>
|
||||
|
||||
### `@classmethod`
|
||||
### *def* `from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3'`
|
||||
### *method* `from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3`
|
||||
|
||||
|
||||
工厂函数 由三点构造平面。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- p1: 点1
|
||||
|
||||
@ -353,10 +394,14 @@ def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
|
||||
|
||||
- p3: 点3
|
||||
|
||||
**返回**:
|
||||
|
||||
- 平面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@classmethod
|
||||
@ -378,21 +423,25 @@ def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3'
|
||||
</details>
|
||||
|
||||
### `@classmethod`
|
||||
### *def* `from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3'`
|
||||
### *method* `from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3`
|
||||
|
||||
|
||||
工厂函数 由两直线构造平面。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- l1: 直线1
|
||||
|
||||
- l2: 直线2
|
||||
|
||||
**返回**:
|
||||
|
||||
- 平面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@classmethod
|
||||
@ -414,21 +463,25 @@ def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
|
||||
</details>
|
||||
|
||||
### `@classmethod`
|
||||
### *def* `from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3'`
|
||||
### *method* `from_point_and_line(cls, point: Point3, line: Line3) -> Plane3`
|
||||
|
||||
|
||||
工厂函数 由点和直线构造平面。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- point: 面上一点
|
||||
|
||||
- line: 面上直线,不包含点
|
||||
|
||||
**返回**:
|
||||
|
||||
- 平面
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@classmethod
|
||||
@ -445,45 +498,12 @@ def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__repr__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __repr__(self):
|
||||
return f'Plane3({self.a}, {self.b}, {self.c}, {self.d})'
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
s = 'Plane3: '
|
||||
if self.a != 0:
|
||||
s += f'{sign(self.a, only_neg=True)}{abs(self.a)}x'
|
||||
if self.b != 0:
|
||||
s += f' {sign(self.b)} {abs(self.b)}y'
|
||||
if self.c != 0:
|
||||
s += f' {sign(self.c)} {abs(self.c)}z'
|
||||
if self.d != 0:
|
||||
s += f' {sign(self.d)} {abs(self.d)}'
|
||||
return s + ' = 0'
|
||||
```
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__and__(self, other: 'Line3') -> 'Point3 | None'`
|
||||
### *method* `__and__(self, other: Line3) -> Point3 | None`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -493,11 +513,11 @@ def __and__(self, other: 'Line3') -> 'Point3 | None':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__and__(self, other: 'Plane3') -> 'Line3 | None'`
|
||||
### *method* `__and__(self, other: Plane3) -> Line3 | None`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -506,19 +526,23 @@ def __and__(self, other: 'Plane3') -> 'Line3 | None':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__and__(self, other)`
|
||||
### *method* `__and__(self, other)`
|
||||
|
||||
|
||||
取两平面的交集(人话:交线)
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
**返回**:
|
||||
|
||||
- 不平行平面的交线,平面平行返回None
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __and__(self, other):
|
||||
@ -542,11 +566,11 @@ def __and__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other) -> bool`
|
||||
### *method* `__eq__(self, other) -> bool`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other) -> bool:
|
||||
@ -554,11 +578,11 @@ def __eq__(self, other) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__rand__(self, other: 'Line3') -> 'Point3'`
|
||||
### *method* `__rand__(self, other: Line3) -> Point3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __rand__(self, other: 'Line3') -> 'Point3':
|
||||
@ -566,23 +590,3 @@ def __rand__(self, other: 'Line3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***var*** `k = other.a / self.a`
|
||||
|
||||
### ***var*** `A = np.array([[self.b, self.c], [other.b, other.c]])`
|
||||
|
||||
### ***var*** `B = np.array([-self.d, -other.d])`
|
||||
|
||||
### ***var*** `v2 = l2.get_point(1) - l1.point`
|
||||
|
||||
### ***var*** `k = other.b / self.b`
|
||||
|
||||
### ***var*** `A = np.array([[self.a, self.c], [other.a, other.c]])`
|
||||
|
||||
### ***var*** `B = np.array([-self.d, -other.d])`
|
||||
|
||||
### ***var*** `k = other.c / self.c`
|
||||
|
||||
### ***var*** `A = np.array([[self.a, self.b], [other.a, other.b]])`
|
||||
|
||||
### ***var*** `B = np.array([-self.d, -other.d])`
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
---
|
||||
title: mbcp.mp_math.point
|
||||
---
|
||||
### ***class*** `Point3`
|
||||
|
||||
### *def* `__init__(self, x: float, y: float, z: float)`
|
||||
### **class** `Point3`
|
||||
### *method* `__init__(self, x: float, y: float, z: float)`
|
||||
|
||||
|
||||
笛卡尔坐标系中的点。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x: x 坐标
|
||||
|
||||
@ -19,7 +18,7 @@ title: mbcp.mp_math.point
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, x: float, y: float, z: float):
|
||||
@ -36,21 +35,25 @@ def __init__(self, x: float, y: float, z: float):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `approx(self, other: 'Point3', epsilon: float = APPROX) -> bool`
|
||||
### *method* `approx(self, other: Point3, epsilon: float = APPROX) -> bool`
|
||||
|
||||
|
||||
判断两个点是否近似相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
- epsilon:
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
|
||||
@ -67,24 +70,12 @@ def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
return f'Point3({self.x}, {self.y}, {self.z})'
|
||||
```
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__add__(self, other: 'Vector3') -> 'Point3'`
|
||||
### *method* `self + other: Vector3 => Point3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -94,11 +85,11 @@ def __add__(self, other: 'Vector3') -> 'Point3':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__add__(self, other: 'Point3') -> 'Point3'`
|
||||
### *method* `self + other: Point3 => Point3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -107,20 +98,20 @@ def __add__(self, other: 'Point3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__add__(self, other)`
|
||||
### *method* `self + other`
|
||||
|
||||
|
||||
P + V -> P
|
||||
P + P -> P
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __add__(self, other):
|
||||
@ -135,19 +126,19 @@ def __add__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other)`
|
||||
### *method* `__eq__(self, other)`
|
||||
|
||||
|
||||
判断两个点是否相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other):
|
||||
@ -161,21 +152,21 @@ def __eq__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__sub__(self, other: 'Point3') -> 'Vector3'`
|
||||
### *method* `self - other: Point3 => Vector3`
|
||||
|
||||
|
||||
P - P -> V
|
||||
|
||||
P - V -> P 已在 :class:`Vector3` 中实现
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __sub__(self, other: 'Point3') -> 'Vector3':
|
||||
|
@ -1,9 +1,8 @@
|
||||
---
|
||||
title: mbcp.mp_math.segment
|
||||
---
|
||||
### ***class*** `Segment3`
|
||||
|
||||
### *def* `__init__(self, p1: 'Point3', p2: 'Point3')`
|
||||
### **class** `Segment3`
|
||||
### *method* `__init__(self, p1: Point3, p2: Point3)`
|
||||
|
||||
|
||||
三维空间中的线段。
|
||||
@ -13,7 +12,7 @@ title: mbcp.mp_math.segment
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, p1: 'Point3', p2: 'Point3'):
|
||||
@ -33,27 +32,3 @@ def __init__(self, p1: 'Point3', p2: 'Point3'):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__repr__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __repr__(self):
|
||||
return f'Segment3({self.p1}, {self.p2})'
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
return f'Segment3({self.p1} -> {self.p2})'
|
||||
```
|
||||
</details>
|
||||
|
||||
|
@ -1,32 +1,36 @@
|
||||
---
|
||||
title: mbcp.mp_math.utils
|
||||
---
|
||||
### *def* `clamp() -> float`
|
||||
### *func* `clamp() -> float`
|
||||
|
||||
|
||||
区间截断函数。
|
||||
区间限定函数
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x:
|
||||
- x: 待限定的值
|
||||
|
||||
- min_:
|
||||
- min_: 最小值
|
||||
|
||||
- max_:
|
||||
- max_: 最大值
|
||||
|
||||
**返回**:
|
||||
|
||||
- 限制后的值
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def clamp(x: float, min_: float, max_: float) -> float:
|
||||
"""
|
||||
区间截断函数。
|
||||
区间限定函数
|
||||
Args:
|
||||
x:
|
||||
min_:
|
||||
max_:
|
||||
x: 待限定的值
|
||||
min_: 最小值
|
||||
max_: 最大值
|
||||
|
||||
Returns:
|
||||
限制后的值
|
||||
@ -35,33 +39,36 @@ def clamp(x: float, min_: float, max_: float) -> float:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `approx(x: float = 0.0, y: float = APPROX) -> bool`
|
||||
### *func* `approx(x: float = 0.0, y: float = APPROX) -> bool`
|
||||
|
||||
|
||||
判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x:
|
||||
- x: 数1
|
||||
|
||||
- y:
|
||||
- y: 数2
|
||||
|
||||
- epsilon:
|
||||
- epsilon: 误差
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
|
||||
"""
|
||||
判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。
|
||||
Args:
|
||||
x:
|
||||
y:
|
||||
epsilon:
|
||||
|
||||
x: 数1
|
||||
y: 数2
|
||||
epsilon: 误差
|
||||
Returns:
|
||||
是否近似相等
|
||||
"""
|
||||
@ -69,21 +76,25 @@ def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `sign(x: float = False) -> str`
|
||||
### *func* `sign(x: float = False) -> str`
|
||||
|
||||
|
||||
获取数的符号。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x: 数
|
||||
|
||||
- only_neg: 是否只返回负数的符号
|
||||
|
||||
**返回**:
|
||||
|
||||
- 符号 + - ""
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def sign(x: float, only_neg: bool=False) -> str:
|
||||
@ -103,7 +114,7 @@ def sign(x: float, only_neg: bool=False) -> str:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `sign_format(x: float = False) -> str`
|
||||
### *func* `sign_format(x: float = False) -> str`
|
||||
|
||||
|
||||
格式化符号数
|
||||
@ -111,16 +122,20 @@ def sign(x: float, only_neg: bool=False) -> str:
|
||||
1 -> +1
|
||||
0 -> ""
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x: 数
|
||||
|
||||
- only_neg: 是否只返回负数的符号
|
||||
|
||||
**返回**:
|
||||
|
||||
- 符号 + - ""
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def sign_format(x: float, only_neg: bool=False) -> str:
|
||||
@ -143,13 +158,12 @@ def sign_format(x: float, only_neg: bool=False) -> str:
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***class*** `Approx`
|
||||
|
||||
### *def* `__init__(self, value: RealNumber)`
|
||||
### **class** `Approx`
|
||||
### *method* `__init__(self, value: RealNumber)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, value: RealNumber):
|
||||
@ -157,11 +171,11 @@ def __init__(self, value: RealNumber):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other)`
|
||||
### *method* `__eq__(self, other)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other):
|
||||
@ -178,11 +192,11 @@ def __eq__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `raise_type_error(self, other)`
|
||||
### *method* `raise_type_error(self, other)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def raise_type_error(self, other):
|
||||
@ -190,11 +204,11 @@ def raise_type_error(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__ne__(self, other)`
|
||||
### *method* `__ne__(self, other)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __ne__(self, other):
|
||||
|
@ -1,14 +1,13 @@
|
||||
---
|
||||
title: mbcp.mp_math.vector
|
||||
---
|
||||
### ***class*** `Vector3`
|
||||
|
||||
### *def* `__init__(self, x: float, y: float, z: float)`
|
||||
### **class** `Vector3`
|
||||
### *method* `__init__(self, x: float, y: float, z: float)`
|
||||
|
||||
|
||||
3维向量
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- x: x轴分量
|
||||
|
||||
@ -19,7 +18,7 @@ title: mbcp.mp_math.vector
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, x: float, y: float, z: float):
|
||||
@ -36,21 +35,25 @@ def __init__(self, x: float, y: float, z: float):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `approx(self, other: 'Vector3', epsilon: float = APPROX) -> bool`
|
||||
### *method* `approx(self, other: Vector3, epsilon: float = APPROX) -> bool`
|
||||
|
||||
|
||||
判断两个向量是否近似相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
- epsilon:
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
|
||||
@ -67,19 +70,23 @@ def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cal_angle(self, other: 'Vector3') -> 'AnyAngle'`
|
||||
### *method* `cal_angle(self, other: Vector3) -> AnyAngle`
|
||||
|
||||
|
||||
计算两个向量之间的夹角。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个向量
|
||||
|
||||
**返回**:
|
||||
|
||||
- 夹角
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
|
||||
@ -94,7 +101,7 @@ def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `cross(self, other: 'Vector3') -> 'Vector3'`
|
||||
### *method* `cross(self, other: Vector3) -> Vector3`
|
||||
|
||||
|
||||
向量积 叉乘:v1 cross v2 -> v3
|
||||
@ -103,10 +110,18 @@ def cal_angle(self, other: 'Vector3') -> 'AnyAngle':
|
||||
其余结果的模为平行四边形的面积。
|
||||
|
||||
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
**返回**:
|
||||
|
||||
- 行列式的结果
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def cross(self, other: 'Vector3') -> 'Vector3':
|
||||
@ -133,21 +148,25 @@ def cross(self, other: 'Vector3') -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX) -> bool`
|
||||
### *method* `is_approx_parallel(self, other: Vector3, epsilon: float = APPROX) -> bool`
|
||||
|
||||
|
||||
判断两个向量是否近似平行。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个向量
|
||||
|
||||
- epsilon: 允许的误差
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否近似平行
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
|
||||
@ -163,19 +182,23 @@ def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `is_parallel(self, other: 'Vector3') -> bool`
|
||||
### *method* `is_parallel(self, other: Vector3) -> bool`
|
||||
|
||||
|
||||
判断两个向量是否平行。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other: 另一个向量
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否平行
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def is_parallel(self, other: 'Vector3') -> bool:
|
||||
@ -190,7 +213,7 @@ def is_parallel(self, other: 'Vector3') -> bool:
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `normalize(self)`
|
||||
### *method* `normalize(self)`
|
||||
|
||||
|
||||
将向量归一化。
|
||||
@ -200,7 +223,7 @@ def is_parallel(self, other: 'Vector3') -> bool:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def normalize(self):
|
||||
@ -217,7 +240,7 @@ def normalize(self):
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `np_array(self) -> 'np.ndarray'`
|
||||
### *method* `np_array(self) -> np.ndarray`
|
||||
|
||||
|
||||
|
||||
@ -225,7 +248,7 @@ def normalize(self):
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -239,19 +262,19 @@ def np_array(self) -> 'np.ndarray':
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `length(self) -> float`
|
||||
### *method* `length(self) -> float`
|
||||
|
||||
|
||||
向量的模。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 模
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -266,19 +289,19 @@ def length(self) -> float:
|
||||
</details>
|
||||
|
||||
### `@property`
|
||||
### *def* `unit(self) -> 'Vector3'`
|
||||
### *method* `unit(self) -> Vector3`
|
||||
|
||||
|
||||
获取该向量的单位向量。
|
||||
|
||||
返回:
|
||||
**返回**:
|
||||
|
||||
- 单位向量
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@property
|
||||
@ -292,11 +315,11 @@ def unit(self) -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__abs__(self)`
|
||||
### *method* `__abs__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __abs__(self):
|
||||
@ -305,11 +328,11 @@ def __abs__(self):
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__add__(self, other: 'Vector3') -> 'Vector3'`
|
||||
### *method* `self + other: Vector3 => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -319,11 +342,11 @@ def __add__(self, other: 'Vector3') -> 'Vector3':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__add__(self, other: 'Point3') -> 'Point3'`
|
||||
### *method* `self + other: Point3 => Point3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -332,21 +355,21 @@ def __add__(self, other: 'Point3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__add__(self, other)`
|
||||
### *method* `self + other`
|
||||
|
||||
|
||||
V + P -> P
|
||||
|
||||
V + V -> V
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __add__(self, other):
|
||||
@ -368,19 +391,23 @@ def __add__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__eq__(self, other)`
|
||||
### *method* `__eq__(self, other)`
|
||||
|
||||
|
||||
判断两个向量是否相等。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
**返回**:
|
||||
|
||||
- 是否相等
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __eq__(self, other):
|
||||
@ -395,7 +422,7 @@ def __eq__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__radd__(self, other: 'Point3') -> 'Point3'`
|
||||
### *method* `self + other: Point3 => Point3`
|
||||
|
||||
|
||||
P + V -> P
|
||||
@ -407,7 +434,7 @@ P + V -> P
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __radd__(self, other: 'Point3') -> 'Point3':
|
||||
@ -423,11 +450,11 @@ def __radd__(self, other: 'Point3') -> 'Point3':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__sub__(self, other: 'Vector3') -> 'Vector3'`
|
||||
### *method* `self - other: Vector3 => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -437,11 +464,11 @@ def __sub__(self, other: 'Vector3') -> 'Vector3':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__sub__(self, other: 'Point3') -> 'Point3'`
|
||||
### *method* `self - other: Point3 => Point3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -450,21 +477,21 @@ def __sub__(self, other: 'Point3') -> 'Point3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__sub__(self, other)`
|
||||
### *method* `self - other`
|
||||
|
||||
|
||||
V - P -> P
|
||||
|
||||
V - V -> V
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __sub__(self, other):
|
||||
@ -485,19 +512,19 @@ def __sub__(self, other):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__rsub__(self, other: 'Point3')`
|
||||
### *method* `self - other: Point3`
|
||||
|
||||
|
||||
P - V -> P
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __rsub__(self, other: 'Point3'):
|
||||
@ -516,11 +543,11 @@ def __rsub__(self, other: 'Point3'):
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__mul__(self, other: 'Vector3') -> 'Vector3'`
|
||||
### *method* `self * other: Vector3 => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -530,11 +557,11 @@ def __mul__(self, other: 'Vector3') -> 'Vector3':
|
||||
</details>
|
||||
|
||||
### `@overload`
|
||||
### *def* `__mul__(self, other: RealNumber) -> 'Vector3'`
|
||||
### *method* `self * other: RealNumber => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@overload
|
||||
@ -543,19 +570,19 @@ def __mul__(self, other: RealNumber) -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__mul__(self, other: 'int | float | Vector3') -> 'Vector3'`
|
||||
### *method* `self * other: int | float | Vector3 => Vector3`
|
||||
|
||||
|
||||
数组运算 非点乘。点乘使用@,叉乘使用cross。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
|
||||
@ -575,11 +602,11 @@ def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__rmul__(self, other: 'RealNumber') -> 'Vector3'`
|
||||
### *method* `self * other: RealNumber => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __rmul__(self, other: 'RealNumber') -> 'Vector3':
|
||||
@ -587,19 +614,19 @@ def __rmul__(self, other: 'RealNumber') -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__matmul__(self, other: 'Vector3') -> 'RealNumber'`
|
||||
### *method* `self @ other: Vector3 => RealNumber`
|
||||
|
||||
|
||||
点乘。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- other:
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __matmul__(self, other: 'Vector3') -> 'RealNumber':
|
||||
@ -613,11 +640,11 @@ def __matmul__(self, other: 'Vector3') -> 'RealNumber':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__truediv__(self, other: RealNumber) -> 'Vector3'`
|
||||
### *method* `self / other: RealNumber => Vector3`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __truediv__(self, other: RealNumber) -> 'Vector3':
|
||||
@ -625,11 +652,11 @@ def __truediv__(self, other: RealNumber) -> 'Vector3':
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__neg__(self)`
|
||||
### *method* `- self`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
def __neg__(self):
|
||||
@ -637,35 +664,27 @@ def __neg__(self):
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__repr__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __repr__(self):
|
||||
return f'Vector3({self.x}, {self.y}, {self.z})'
|
||||
```
|
||||
</details>
|
||||
|
||||
### *def* `__str__(self)`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
|
||||
```python
|
||||
def __str__(self):
|
||||
return f'Vector3({self.x}, {self.y}, {self.z})'
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***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轴单位向量
|
||||
|
||||
|
@ -1,24 +1,27 @@
|
||||
---
|
||||
title: mbcp.presets.model
|
||||
---
|
||||
### ***class*** `GeometricModels`
|
||||
|
||||
### **class** `GeometricModels`
|
||||
### `@staticmethod`
|
||||
### *def* `sphere(radius: float, density: float)`
|
||||
### *method* `sphere(radius: float, density: float)`
|
||||
|
||||
|
||||
生成球体上的点集。
|
||||
|
||||
参数:
|
||||
**参数**:
|
||||
|
||||
- radius:
|
||||
|
||||
- density:
|
||||
|
||||
**返回**:
|
||||
|
||||
- List[Point3]: 球体上的点集。
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源码</summary>
|
||||
<summary> <i>源代码</i> </summary>
|
||||
|
||||
```python
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user