Skip to content

Module mbcp.mp_math.angle

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

class Angle

class AnyAngle(Angle)


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

Description: 任意角度。

Arguments:

  • value: 角度或弧度值
  • is_radian: 是否为弧度,默认为否
Source code or View on GitHub
python
def __init__(self, value: float, is_radian: bool=False):
    if is_radian:
        self.radian = value
    else:
        self.radian = value * PI / 180

@property

method complementary(self) -> AnyAngle

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

Return: 余角

Source code or View on GitHub
python
@property
def complementary(self) -> 'AnyAngle':
    return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)

@property

method supplementary(self) -> AnyAngle

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

Return: 补角

Source code or View on GitHub
python
@property
def supplementary(self) -> 'AnyAngle':
    return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)

@property

method degree(self) -> float

Description: 角度。

Return: 弧度

Source code or View on GitHub
python
@property
def degree(self) -> float:
    return self.radian * 180 / PI

@property

method minimum_positive(self) -> AnyAngle

Description: 最小正角。

Return: 最小正角度

Source code or View on GitHub
python
@property
def minimum_positive(self) -> 'AnyAngle':
    return AnyAngle(self.radian % (2 * PI))

@property

method maximum_negative(self) -> AnyAngle

Description: 最大负角。

Return: 最大负角度

Source code or View on GitHub
python
@property
def maximum_negative(self) -> 'AnyAngle':
    return AnyAngle(-self.radian % (2 * PI), is_radian=True)

@property

method sin(self) -> float

Description: 正弦值。

Return: 正弦值

Source code or View on GitHub
python
@property
def sin(self) -> float:
    return math.sin(self.radian)

@property

method cos(self) -> float

Description: 余弦值。

Return: 余弦值

Source code or View on GitHub
python
@property
def cos(self) -> float:
    return math.cos(self.radian)

@property

method tan(self) -> float

Description: 正切值。

Return: 正切值

Source code or View on GitHub
python
@property
def tan(self) -> float:
    return math.tan(self.radian)

@property

method cot(self) -> float

Description: 余切值。

Return: 余切值

Source code or View on GitHub
python
@property
def cot(self) -> float:
    return 1 / math.tan(self.radian)

@property

method sec(self) -> float

Description: 正割值。

Return: 正割值

Source code or View on GitHub
python
@property
def sec(self) -> float:
    return 1 / math.cos(self.radian)

@property

method csc(self) -> float

Description: 余割值。

Return: 余割值

Source code or View on GitHub
python
@property
def csc(self) -> float:
    return 1 / math.sin(self.radian)

method self + other: AnyAngle => AnyAngle

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

method self == other

Source code or View on GitHub
python
def __eq__(self, other):
    return approx(self.radian, other.radian)

method self - other: AnyAngle => AnyAngle

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

method self * other: float => AnyAngle

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

@overload

method self / other: float => AnyAngle

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

@overload

method self / other: AnyAngle => float

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

method self / other

Source code or View on GitHub
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