Python求风向xy向量

14 篇文章 0 订阅

风向图示

这个图,对应的笛卡尔平面坐标系:原点在圆心,x正方向指向东,y正方向指向北
根据上图,可以知道12.5度的角度位置,箭头的方向是指向圆心的,这样就能确定了箭头在笛卡尔坐标系的指向
比如:入流风向为0,箭头方向指向圆心,就是说箭头是一个向下的;入流风向为90,箭头方向指向圆心,也就是说箭头是向左的

代码

def getAngel_xy(correctAngel):
    x=0
    y=0
    if correctAngel> 0 and correctAngel <90:
        x = -round(math.sin(math.radians(correctAngel)), 10)
        y = -round(math.cos(math.radians(correctAngel)), 10)
    if correctAngel> 90 and correctAngel <180:
        correctAngel = correctAngel-90
        x = -round(math.cos(math.radians(correctAngel)), 10)
        y = round(math.sin(math.radians(correctAngel)), 10)
    if correctAngel > 180 and correctAngel < 270:
        correctAngel = correctAngel-180
        x = round(math.sin(math.radians(correctAngel)), 10)
        y = round(math.cos(math.radians(correctAngel)), 10)
    if correctAngel> 270 and correctAngel <360:
        correctAngel = correctAngel-270
        x = round(math.cos(math.radians(correctAngel)), 10)
        y = -round(math.sin(math.radians(correctAngel)), 10)
    if correctAngel==0 or correctAngel== 360:
        x =0
        y = -1
    if correctAngel==90:
        x = -1
        y = 0
    if correctAngel == 180:
        x = 0
        y = 1
    if correctAngel == 270:
        x = 1
        y = 0
    return x,y

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值