import{_ as s,c as i,o as a,a2 as n}from"./chunks/framework.BV61Qrc0.js";const F=JSON.parse('{"title":"mbcp.mp_math.angle","description":"","frontmatter":{"title":"mbcp.mp_math.angle"},"headers":[],"relativePath":"api/mp_math/angle.md","filePath":"api/mp_math/angle.md"}'),e={name:"api/mp_math/angle.md"},l=n(`
Angle AnyAngle __init__(self, value: float, is_radian: bool = False) 任意角度。
参数:
value: 角度或弧度值
is_radian: 是否为弧度,默认为否
def __init__(self, value: float, is_radian: bool=False):
"""
任意角度。
Args:
value: 角度或弧度值
is_radian: 是否为弧度,默认为否
"""
if is_radian:
self.radian = value
else:
self.radian = value * PI / 180@property complementary(self) -> 'AnyAngle' 余角:两角的和为90°。
返回:
@property
def complementary(self) -> 'AnyAngle':
"""
余角:两角的和为90°。
Returns:
余角
"""
return AnyAngle(PI / 2 - self.minimum_positive.radian, is_radian=True)@property supplementary(self) -> 'AnyAngle' 补角:两角的和为180°。
返回:
@property
def supplementary(self) -> 'AnyAngle':
"""
补角:两角的和为180°。
Returns:
补角
"""
return AnyAngle(PI - self.minimum_positive.radian, is_radian=True)@property degree(self) -> float 角度。
返回:
@property
def degree(self) -> float:
"""
角度。
Returns:
弧度
"""
return self.radian * 180 / PI@property minimum_positive(self) -> 'AnyAngle' 最小正角。
返回:
@property
def minimum_positive(self) -> 'AnyAngle':
"""
最小正角。
Returns:
最小正角度
"""
return AnyAngle(self.radian % (2 * PI))@property maximum_negative(self) -> 'AnyAngle' 最大负角。
返回:
@property
def maximum_negative(self) -> 'AnyAngle':
"""
最大负角。
Returns:
最大负角度
"""
return AnyAngle(-self.radian % (2 * PI), is_radian=True)@property sin(self) -> float 正弦值。
返回:
@property
def sin(self) -> float:
"""
正弦值。
Returns:
正弦值
"""
return math.sin(self.radian)@property cos(self) -> float 余弦值。
返回:
@property
def cos(self) -> float:
"""
余弦值。
Returns:
余弦值
"""
return math.cos(self.radian)@property tan(self) -> float 正切值。
返回:
@property
def tan(self) -> float:
"""
正切值。
Returns:
正切值
"""
return math.tan(self.radian)@property cot(self) -> float 余切值。
返回:
@property
def cot(self) -> float:
"""
余切值。
Returns:
余切值
"""
return 1 / math.tan(self.radian)@property sec(self) -> float 正割值。
返回:
@property
def sec(self) -> float:
"""
正割值。
Returns:
正割值
"""
return 1 / math.cos(self.radian)@property csc(self) -> float 余割值。
返回:
@property
def csc(self) -> float:
"""
余割值。
Returns:
余割值
"""
return 1 / math.sin(self.radian)__add__(self, other: 'AnyAngle') -> 'AnyAngle' def __add__(self, other: 'AnyAngle') -> 'AnyAngle':
return AnyAngle(self.radian + other.radian, is_radian=True)__eq__(self, other) def __eq__(self, other):
return approx(self.radian, other.radian)__sub__(self, other: 'AnyAngle') -> 'AnyAngle' def __sub__(self, other: 'AnyAngle') -> 'AnyAngle':
return AnyAngle(self.radian - other.radian, is_radian=True)__mul__(self, other: float) -> 'AnyAngle' def __mul__(self, other: float) -> 'AnyAngle':
return AnyAngle(self.radian * other, is_radian=True)__repr__(self) def __repr__(self):
return f'AnyAngle({self.radian}, is_radian=True)'__str__(self) def __str__(self):
return f'AnyAngle({self.degree}° or {self.radian} rad)'@overload __truediv__(self, other: float) -> 'AnyAngle' @overload
def __truediv__(self, other: float) -> 'AnyAngle':
...@overload __truediv__(self, other: 'AnyAngle') -> float @overload
def __truediv__(self, other: 'AnyAngle') -> float:
...__truediv__(self, other) def __truediv__(self, other):
if isinstance(other, AnyAngle):
return self.radian / other.radian
return AnyAngle(self.radian / other, is_radian=True)