TurnPointOnGamma 函数的数学公式表示

函数描述

TurnPointOnGamma 函数用于在“拍摄/潜水”模式下,围绕空穴中心以角度Γ\Gamma旋转任意点的坐标。

参数说明

  • x0x_0:初始x坐标。
  • y0y_0:初始y坐标。
  • xs0x_{s0}:空穴中心的初始x偏移。
  • ys0y_{s0}:空穴中心的初始y偏移。
  • cos(Γ)\cos(\Gamma):旋转角度的余弦值。
  • sin(Γ)\sin(\Gamma):旋转角度的正弦值。

数学公式

旋转后的坐标(xt,yt)(x_t, y_t)通过以下公式计算:
xt=xs0+x0cos(Γ)+y0sin(Γ) x_t = x_{s0} + x_0 \cdot \cos(\Gamma) + y_0 \cdot \sin(\Gamma)
yt=ys0x0sin(Γ)+y0cos(Γ) y_t = y_{s0} - x_0 \cdot \sin(\Gamma) + y_0 \cdot \cos(\Gamma)

返回值

  • xtx_t:旋转后的x坐标。
  • yty_t:旋转后的y坐标。

Python代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def TurnPointOnGamma(self, x0, y0):
# 把x0,y0转换到xt,yt
"""
在“拍摄/潜水”的空穴中心的伽玛角上旋转任何点坐标。

参数:
x0 (float): 初始x坐标。
y0 (float): 初始y坐标。
COS_G (float): 旋转角度的余弦值。
SIN_G (float): 旋转角度的正弦值。

返回:
xt (float): 旋转后的x坐标。
yt (float): 旋转后的y坐标。
"""
# xs0 (float): 空穴中心的初始x偏移。
xs0 = self.xs0
# ys0 (float): 空穴中心的初始y偏移。
ys0 = self.ys0

COS_G = self.COS_G
SIN_G = self.SIN_G
# 计算旋转后的坐标
xt = xs0 + x0 * COS_G + y0 * SIN_G
yt = ys0 - x0 * SIN_G + y0 * COS_G
# 这里感觉和Fortune略有不同,Fortune的括号里是传入和传出,python不是
return xt, yt