• 欢迎访问GanAHE的小创元世纪,技术交流与资源分享,欢迎加入GanAHE的小创元世纪🤪 微信公众号:星辰换日
  • 电影、教程、软件等分享资源请在本站或微信公众号合作平台:【星辰换日】获取。
  • 首页展示个人参与或独立开发的产品,更多功能在建中......🙆🏼天王盖地虎
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏本站吧🥺
  • 注册采用有效的邮箱,有助于及时收到评论回复、最新资源以及活动通知哟~✔🥳
  • 目前在逐渐打通微信小程序与网站之前的间隔~💻🏢

测量点位误差与误差椭圆求解

Python GanAHE 5个月前 (12-07) 41次浏览 已收录 0个评论 扫描二维码
文章目录[隐藏]

一、背景

点位误差椭圆是一种描述待定点位置在各个方向上误差分布规律的椭圆。

暂无

二、代码

#!/usr/bin/python3
#-*- codng: utf-8 -*-

import numpy as np

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse

def getErrorEllipsePara(listQxx,drawFigure = None,sigmaZero=None,angle=None):
    Qxx = np.mat(listQxx)
    if Qxx.shape[0] == Qxx.shape[1] and Qxx.shape[0] == 2:
        tan_toubleFia = 2*Qxx[0,1]/(Qxx[0,0]-Qxx[1,1])
        fia = np.arctan(tan_toubleFia)/2
        #fias = np.rad2deg(np.arctan2(2*Qxx[0,1],Qxx[0,0]-Qxx[1,1]))
        print("-fia:{} rad | -fia:{}° | -fiaaddninety:{}°".format(fia,np.rad2deg(fia),np.rad2deg(fia)+90))

        fiaE,fiaF = filter_fiaEF(Qxx,fia)

        if sigmaZero is not None:
            fiaE = np.deg2rad(fiaE)
            fiaF = np.deg2rad(fiaF)
            Q_ff = lambda sitha:(Qxx[0,0]*np.cos(sitha)*np.cos(sitha)+Qxx[1,1]*np.sin(sitha)*np.sin(sitha)+Qxx[0,1]*np.sin(2*sitha))
            sigmaE = np.sqrt(sigmaZero*sigmaZero*Q_ff(fiaE))
            sigmaF = np.sqrt(sigmaZero*sigmaZero*Q_ff(fiaF))

            print("-fiaE:{} 度,-E:{};\n -fiaF:{} 度,-F:{}".format(np.rad2deg(fiaE),sigmaE,np.rad2deg(fiaF),sigmaF))

            # Draw
            if drawFigure is not None:
                drawEllipse(sigmaE,sigmaF,np.rad2deg(fiaE))
                print("- 绘图完成")
            # anlyse
            if angle is not None:
                fia_angle = np.deg2rad(angle)
                newQff = Q_ff(fia_angle)
                print("\n-angle Qff sigma:",np.rad2deg(fia_angle),newQff,sigmaZero*np.sqrt(newQff))
                print("\n*: ",np.sqrt(sigmaE*np.cos(newQff)*np.cos(newQff)+sigmaF*np.sin(newQff)*np.sin(newQff)))
    else:
        print("Error para")

def filter_fiaEF(Qxx,fia):
        fiaE = 0
        fiaF = 0
        if Qxx[0,1] == 0: # 在轴上
            if Qxx[0,0] > Qxx[1,1]:
                fiaE = 0
                fiaF = 90
                print("-fiaE:{} or {},最大位差在x轴上 | -fiaF:{} or {}".format(0,180,90,270))
            else:
                fiaE = 90
                fiaF = 0
                print("-fiaE:{} or {},最大位差在y轴".format(90,270))
        elif Qxx[0,1] > 0:
            # if Qxx[0,1]*np.tan(np.deg2rad(fia))>0:
            print("极大值fiaE位于一、三象限")
            if (fia > 0 and fia < 90) or (fia < 270 and fia > 180):
                fiaE = fia
                fiaF = fia + 90
            # 存疑
            else:
                fiaE = fia + 90
                fiaF = fia

            # else:
            #     if (fia > 0 and fia < 90) or (fia < 270 and fia > 180):
            #         fiaE = fia + 90
            #         fiaF = fia 
            #     else:
            #         fiaE = fia
            #         fiaF = fia + 90
            #     print("极大值位于二、四象限")
        else:
            # if Qxx[0,1]*np.tan(np.deg2rad(fia)) > 0:
            if (fia > 0 and fia < 90) or (fia < 270 and fia > 180):
                fiaE = fia + 90
                fiaF = fia 
            else:
                fiaE = fia
                fiaF = fia + 90
            print("fiaE极大值2、4象限")
            # else:
            #     if (fia > 0 and fia < 90) or (fia < 270 and fia > 180):
            #         fiaE = fia + 90
            #         fiaF = fia
            #     else:
            #         fiaE = fia
            #         fiaF = fia + 90
            #     print("极大值二四象限")
        return fiaE,fiaF

def drawEllipse(E,F,fiaE,x=None,y=None):
    print("-"*20)
    fig = plt.figure(0)
    ax = fig.add_subplot(111, aspect='equal')
    if x is None:
        x = 0
    if y is None:
        y = 0
    e = Ellipse(xy = (x,y), width = E, height = F, angle=fiaE,facecolor= 'green', alpha=0.3)
    ax.add_patch(e)

    ax.plot(x, y, 'ro')
    plt.axis('scaled')
    plt.axis('equal')
    ax.grid(True)
    strInfo = "E:"+str(E)[0:5]+" -F:"+str(F)[0:5]+" -fiaE:"+str(fiaE)[0:6]+"degree"
    plt.title("ErrorEllipse"+strInfo)
    plt.savefig("./ErrorEllipse.png")
    plt.show()

if __name__=="__main__":
    Q = [[5,-1.2],
        [-1.2,4]]
    sigma = 0.81
    getErrorEllipsePara(Q,sigmaZero=sigma,angle=50,drawFigure=True)
    # drawEllipse()

iPad下运行:
[1]

[2]

[3]
file

[4]amazing
file

结束


GanAHE 的小创元世纪, 版权所有丨如未注明 , 均为原创丨本网站采用@BY-NC-SA协议进行授权
转载请注明原文链接:测量点位误差与误差椭圆求解
喜欢 (1)
[WeChat]
分享 (0)
关于作者:
网站的建设与维护者、DGZC的守护者
0 0 评分
都看完了,打个分儿叭~
通知
提醒
0 评论
内部反馈
显示所有评论
0
有什么想法吗,快来留下你的评论吧!x
()
x