📝 优化文档显示

This commit is contained in:
2024-08-29 19:00:01 +08:00
committed by snowykami
parent d027d4b862
commit c08a0c7fda
38 changed files with 490 additions and 273 deletions

View File

@@ -1,11 +1,5 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/6 下午12:54
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py
@Software: PyCharm
本模块塞了一些预设的粒子生成器
"""
from .mp_math import *

View File

@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/6 下午12:57
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py.py
@Software: PyCharm
本包定义了一些常用的导入,可直接从`mbcp.mp_math`导入使用
导入的类有:
- `AnyAngle`:任意角
- `CurveEquation`:曲线方程
- `Line3`:三维直线
- `Plane3`:三维平面
- `Point3`:三维点
- `Segment3`:三维线段
- `Vector3`:三维向量
"""
from .angle import AnyAngle
from .const import *

View File

@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/26 上午6:29
@Author : snowykami
@Email : snowykami@outlook.com
@File : angle.py
@Software: PyCharm
本模块定义了角度相关的类
"""
import math
from typing import overload

View File

@@ -1,21 +1,19 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/25 下午9:45
@Author : snowykami
@Email : snowykami@outlook.com
@File : const.py
@Software: PyCharm
本模块定义了一些常用的常量
"""
import math
PI = math.pi
"""常量 π"""
E = math.e
"""自然对数的底 exp(1)"""
GOLDEN_RATIO = (1 + math.sqrt(5)) / 2
"""黄金分割比"""
GAMMA = 0.57721566490153286060651209008240243104215933593992
"""欧拉常数"""
EPSILON = 0.0001
"""ε"""
"""精度误差"""
APPROX = 0.001
"""约等于误差"""
"""约等于判定误差"""

View File

@@ -1,17 +1,11 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/9 上午11:32
@Author : snowykami
@Email : snowykami@outlook.com
@File : equation.py
@Software: PyCharm
本模块定义了方程相关的类和函数以及一些常用的数学函数
"""
from mbcp.mp_math.mp_math_typing import OneVarFunc, Var, MultiVarsFunc, Number
from mbcp.mp_math.point import Point3
from mbcp.mp_math.const import EPSILON
from .mp_math_typing import OneVarFunc, Var, MultiVarsFunc, Number
from .point import Point3
from .const import EPSILON
class CurveEquation:
@@ -34,7 +28,7 @@ class CurveEquation:
*t:
参数
Returns:
目标点
"""
if len(t) == 1:
return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
@@ -73,7 +67,14 @@ def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...],
return partial_derivative_func
elif isinstance(var, tuple):
def high_order_partial_derivative_func(*args: Var) -> Var:
"""@litedoc-hide"""
"""
@litedoc-hide
求高阶偏导函数
Args:
*args: 参数
Returns:
高阶偏导数值
"""
result_func = func
for v in var:
result_func = get_partial_derivative_func(result_func, v, epsilon)

27
mbcp/mp_math/function.py Normal file
View File

@@ -0,0 +1,27 @@
"""
AAA
"""
from .mp_math_typing import ThreeSingleVarsFunc
from .point import Point3
from .vector import Vector3
from .const import EPSILON
def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSILON) -> Vector3:
r"""
计算三元函数在某点的梯度向量。
> [!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)

View File

@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/6 下午12:57
@Author : snowykami
@Email : snowykami@outlook.com
@File : other.py
@Software: PyCharm
本模块定义了三维空间中的直线类
"""
import math
from typing import TYPE_CHECKING

View File

@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/9 上午11:35
@Author : snowykami
@Email : snowykami@outlook.com
@File : mp_math_typing.py
@Software: PyCharm
本模块用于内部类型提示
"""
from typing import Callable, Iterable, TypeAlias, TypeVar

View File

@@ -1,17 +1,16 @@
# -*- coding: utf-8 -*-
"""
平面模块
本模块定义了三维空间中的平面类
"""
import math
from typing import TYPE_CHECKING, overload
import numpy as np
from .const import APPROX
from .vector import Vector3, zero_vector3
from .line import Line3
from .point import Point3
from .utils import approx, sign
from .vector import Vector3, zero_vector3
if TYPE_CHECKING:
from .angle import AnyAngle

View File

@@ -1,3 +1,7 @@
"""
本模块定义了三维空间中点的类。
"""
from typing import TYPE_CHECKING, overload
from .const import APPROX

View File

@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/7 上午12:42
@Author : snowykami
@Email : snowykami@outlook.com
@File : segment.py
@Software: PyCharm
本模块定义了三维空间中的线段类
"""
from typing import TYPE_CHECKING

View File

@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/12 下午9:16
@Author : snowykami
@Email : snowykami@outlook.com
@File : utils.py
@Software: PyCharm
本模块定义了一些常用的工具函数
"""
from typing import overload, TYPE_CHECKING

View File

@@ -1,17 +1,18 @@
"""
本模块定义了3维向量的类Vector3以及一些常用的向量。
"""
import math
from typing import overload, TYPE_CHECKING
from typing import overload
import numpy as np
from .angle import AnyAngle
from .const import APPROX
from .mp_math_typing import RealNumber
from .point import Point3
from .angle import AnyAngle
from .utils import approx
# if TYPE_CHECKING:
#
class Vector3:
def __init__(self, x: float, y: float, z: float):

View File

@@ -1,10 +1,4 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/12 下午8:54
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py.py
@Software: PyCharm
本模块定义了粒子生成相关的工具
"""