2021国赛A题代码记录

预先要使用的函数库

import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import sys
import re
from mpl_toolkits.mplot3d import Axes3D
import math as m
import random

数据读取

date1 = pd.read_excel("C://AppData//image//guosai//data (1).xlsx",sheet_name='附件1',encoding = 'gbk')#
date2 = pd.read_excel("C://AppData//image//guosai//data (1).xlsx",sheet_name='附件2',encoding = 'gbk')#
date3 = pd.read_excel("C://AppData//image//guosai//data (1).xlsx",sheet_name='附件3',encoding = 'gbk')#

数据预览

date1 = date1.set_index('节点编号')
date1.head()

2021国赛A题代码记录_第1张图片
节点提取(好像没意义)

class SANJ():
    def __init__(self):
        self.name = ""
        self.A = None
        self.B = None
        self.C = None
sanks = []
for i in range(0,len(date3)):
 
    san = SANJ()
    san.A = date3.at[i, '主索节点1']
    san.B = date3.at[i, '主索节点2']
    san.C = date3.at[i, '主索节点3']
    sanks.append(san)

网格可视化

fig=plt.figure(figsize=(18,8))
ax1 = Axes3D(fig)
for i in sanks:
    #date1.at['i.A', 'Q1']
    xx = []
    yy = []
    zz = []
    xx.append(date1.at[i.A, 'X坐标(米)'])
    yy.append(date1.at[i.A,  'Y坐标(米)'])
    zz.append(date1.at[i.A, 'Z坐标(米)'])
    
    xx.append(date1.at[i.B, 'X坐标(米)'])
    yy.append(date1.at[i.B, 'Y坐标(米)'])
    zz.append(date1.at[i.B, 'Z坐标(米)'])
    
    xx.append(date1.at[i.C, 'X坐标(米)'])
    yy.append(date1.at[i.C, 'Y坐标(米)'])
    zz.append(date1.at[i.C, 'Z坐标(米)'])
    
    xx.append(date1.at[i.A, 'X坐标(米)'])
    yy.append(date1.at[i.A, 'Y坐标(米)'])
    zz.append(date1.at[i.A, 'Z坐标(米)'])
    

    ax1.plot3D(xx,yy,zz,'blue')

    
for i in range(0,len(date2)):
    xx = []
    yy = []
    zz = []
    
    xx.append(date2.at[i, '下端点X坐标(米)'])
    xx.append(date2.at[i, '基准态时上端点X坐标(米)'])
    
    yy.append(date2.at[i, '下端点Y坐标(米)'])
    yy.append(date2.at[i, '基准态时上端点Y坐标(米)'])
    
    zz.append(date2.at[i, '下端点Z坐标(米)'])
    zz.append(date2.at[i, '基准态时上端点Z坐标(米)'])
    ax1.plot3D(xx,yy,zz,'red')
plt.show()

2021国赛A题代码记录_第2张图片
牵引装置可视化

fig1=plt.figure(figsize=(50,30))
ax2 = Axes3D(fig1)
#ax1.scatter3D(xd,yd,zd, cmap='Blues')  #绘制散点图
for i in range(0,len(date1)):
    xx = []
    yy = []
    zz = []
  
    xx.append(date1.reset_index().at[i, 'X坐标(米)'])#X坐标(米)
    yy.append(date1.reset_index().at[i, 'Y坐标(米)'])
    zz.append(date1.reset_index().at[i, 'Z坐标(米)'])
    ax2.scatter3D(xx,yy,zz, cmap='Blues')
    
for i in range(0,len(date2)):
    xx = []
    yy = []
    zz = []
    
    xx.append(date2.at[i, '下端点X坐标(米)'])
    xx.append(date2.at[i, '基准态时上端点X坐标(米)'])
    
    yy.append(date2.at[i, '下端点Y坐标(米)'])
    yy.append(date2.at[i, '基准态时上端点Y坐标(米)'])
    
    zz.append(date2.at[i, '下端点Z坐标(米)'])
    zz.append(date2.at[i, '基准态时上端点Z坐标(米)'])
    ax2.plot3D(xx,yy,zz,'red')
plt.show()


数据转化与计算

def cart2sph(x,y,z):
    XsqPlusYsq = x**2 + y**2
    r = m.sqrt(XsqPlusYsq + z**2)               # r
    elev = m.atan2(z,m.sqrt(XsqPlusYsq))     # theta
    az = m.atan2(y,x)                           # phi
    return r, elev, az


def jiaodu(vec1,vec2):#vec1=[x1,y1,z1]     vec2=[x2,y2,z2]
    angle=np.arccos(np.dot(vec1,vec2)/(np.linalg.norm(vec1)*np.linalg.norm(vec2)))
    return angle

datehead = heas1.copy()
uint0 = heas1.copy()
Az = np.pi*(36.795/180)
Elev = np.pi*(78.169/180)
x0 = -m.cos(Elev)*m.cos(Az)
y0 = -m.cos(Elev)*m.sin(Az)
z0 = -m.sin(Elev)
vec1 = [x0,y0,z0]
print(vec1)
for i in range(0,len(date1)):
    uint0.at[0,'节点编号'] = date1.reset_index().at[i, '节点编号']
    
    xx = date1.reset_index().at[i, 'X坐标(米)']
    yy = date1.reset_index().at[i, 'Y坐标(米)']
    zz = date1.reset_index().at[i, 'Z坐标(米)']
    
    uint0.at[0,'X坐标'] = xx
    uint0.at[0,'Y坐标'] = yy
    uint0.at[0,'Z坐标'] = zz
    r, elev, az =  cart2sph(xx,yy,zz)
    uint0.at[0,'景象长度'] = r
    uint0.at[0,'偏角'] = az
    uint0.at[0,'俯仰'] = elev
    vec2 = [xx,yy,zz]
    uint0.at[0,'偏离度数'] = jiaodu(vec1,vec2)
    

   
    
    datehead = datehead.append(uint0,ignore_index=True)


datehead.head()

2021国赛A题代码记录_第3张图片
工作面提取与可视化

fig=plt.figure(figsize=(30,15))
ax1 = Axes3D(fig)
for i in sanks:
    #date1.at['i.A', 'Q1']
    xx = []
    yy = []
    zz = []
    xx.append(date1.at[i.A, 'X坐标(米)'])
    yy.append(date1.at[i.A, 'Y坐标(米)'])
    zz.append(date1.at[i.A, 'Z坐标(米)'])
    
    xx.append(date1.at[i.B, 'X坐标(米)'])
    yy.append(date1.at[i.B, 'Y坐标(米)'])
    zz.append(date1.at[i.B, 'Z坐标(米)'])
    
    xx.append(date1.at[i.C, 'X坐标(米)'])
    yy.append(date1.at[i.C, 'Y坐标(米)'])
    zz.append(date1.at[i.C, 'Z坐标(米)'])
    
    xx.append(date1.at[i.A, 'X坐标(米)'])
    yy.append(date1.at[i.A, 'Y坐标(米)'])
    zz.append(date1.at[i.A, 'Z坐标(米)'])
    
    #ax1.plot3D(xx,yy,zz,'blue')
    #ax1.scatter3D(xx,yy,zz, 'b')
xs = list(datehead[(datehead['偏离度数']<np.pi*(30/180))]['X坐标'])
ys = list(datehead[(datehead['偏离度数']<np.pi*(30/180))]['Y坐标'])
zs = list(datehead[(datehead['偏离度数']<np.pi*(30/180))]['Z坐标'])
#ax1.plot3D(xs,ys,zs,'red')
ax1.scatter3D(xs,ys,zs, 'r') 

plt.show()

2021国赛A题代码记录_第4张图片
一推几何计算的处理公式函数

model1 = pd.read_excel("C://AppData//image//guosai//bans.xlsx")
model1.head()
dateS = pd.read_excel("C://AppData//image//guosai//附件4.xlsx",sheet_name='促动器顶端伸缩量',encoding = 'gbk')
#dateS = dateS.set_index('对应主索节点编号')
def sph2cart(r, phi,theta):
    x = r * m.sin(theta) * m.cos(phi)
    y =  r * m.sin(theta) * m.sin(phi)
    z = r * m.cos(theta)
    return x,y,z
def cart2sph(x,y,z):
    XsqPlusYsq = x**2 + y**2
    r = m.sqrt(XsqPlusYsq + z**2)               # r
    elev = np.pi/2-m.atan2(z,m.sqrt(XsqPlusYsq))     # theta
    az = m.atan2(y,x)                           # phi
    return r, az, elev

def cal_area(p1,p2,p3): 
    a = float(m.sqrt((p2[0]-p3[0])*(p2[0]-p3[0])+(p2[1]-p3[1])*(p2[1]-p3[1]))) 
    b = float(m.sqrt((p1[0]-p3[0])*(p1[0]-p3[0])+(p1[1]-p3[1])*(p1[1]-p3[1]))) 
    c = float(m.sqrt((p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]))) 
    s = (a+b+c)/2 
    S = (s*(s-a)*(s-b)*(s-c))**0.5 
    return S,a,b,c




def dch1(x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3):
    a=(y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)
    b=(z2-z1)*(x3-x1)-(z3-z1)*(x2-x1)
    c=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)
    
    px = (a*b*y1+b*b*x-a*b*y+a*z1*c+c*c*x-a*c*z+a*a*x1)/(a*a+b*b+c*c)
    py = (b*c*z1+c*c*y-b*c*z+b*a*x1+a*a*y-a*b*x+b*b*y1)/(a*a+b*b+c*c)
    pz = ((a*c*x1+a*a*z-a*x*c+b*y1*c+b*b*z-b*c*y+c*c*z1)/(a*a+b*b+c*c))
    
    return px,py,pz,a,b,c,


def dch(x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3):
    a=(y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)
    b=(z2-z1)*(x3-x1)-(z3-z1)*(x2-x1)
    c=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)
    
    px = (a*b*y1+b*b*x-a*b*y+a*z1*c+c*c*x-a*c*z+a*a*x1)/(a*a+b*b+c*c)
    py = (b*c*z1+c*c*y-b*c*z+b*a*x1+a*a*y-a*b*x+b*b*y1)/(a*a+b*b+c*c)
    pz = ((a*c*x1+a*a*z-a*x*c+b*y1*c+b*b*z-b*c*y+c*c*z1)/(a*a+b*b+c*c))
    
    px = px+(px-x)
    py = py+(py-y)
    pz = pz+(pz-z)
    
    return px,py,pz,a,b,c,


def get_point_line_distance(point_x, point_y,point_z,line_a_x,line_a_y,line_a_z,line_b_x ,line_b_y,line_b_z):
    ap_x = point_x-line_a_x
    ap_y = point_y-line_a_y
    ap_z = point_z-line_a_z
    
    ab_x = line_b_x-line_a_x
    ab_y = line_b_y-line_a_y
    ab_z = line_b_z-line_a_z
    lap = np.sqrt(ap_x**2+ap_y**2+ap_z**2)
    lab = np.sqrt(ab_x**2+ab_y**2+ab_z**2)
    dis = np.sin(m.acos((ap_x*ab_x+ap_y*ab_y+ap_z*ab_z)/(lap*lab)))*lap
    
    
    return dis
#dch(1,6,5,1,0,0,0,0,1,0,0,0)



def jiance(x1,y1,z1,x2,y2,z2,a,b,c,d):
    p1 = np.array([x1,y1,z1])#
    p2 = np.array([x2,y2,z2]) 
    plane_normal = np.array([a,b,c]) #a,b,c,d平面方程系数
    n = np.abs((np.vdot(p1,plane_normal)+d)/(np.vdot(p2-p1,plane_normal)))
    p = p1 + n*(p2- p1)#所求交点
    return p


def isPointinPolygon(px,py,pz,ax,ay,az,bx,by,bz,cx,cy,cz): #[[0,0],[1,1],[0,1],[0,0]] [1,0.8]
    ap = np.array([px-ax,py-ay,pz-az])
    ab = np.array([bx-ax,by-ay,bz-az])
    ca = np.array([ax-cx,ay-cy,az-cz])
    cp = np.array([px-cx,py-cy,pz-cz])
    bp = np.array([px-bx,py-by,pz-bz])
    bc = np.array([cx-bx,cy-by,cz-bz])
    c1 = np.cross(ab,ap)
    c2 = np.cross(ca,cp)
    c3 = np.cross(bc,bp)
    temp1 = np.dot(c1,c2)
    temp2 = np.dot(c2,c3)
    temp3 = np.dot(c3,c1)
    #print(c1,c2,c3)
    #print(c2)
    #print(c3)
    #print(temp1,temp2,temp3)
    if temp1>=0 and temp2>=0 and temp3>=0:
        return True
    elif temp1<=0 and temp2<=0 and temp3<=0:
        return True
    else:
        return False

    
def peng(ax,ay,bx,by,cx,cy,k):
    '''
    x0 = (ax+bx+cx)/2+random.randint(-30,30) *k
    y0 = (ay+by+cy)/2+random.randint(-30,30) *k
    ax = x0+(ax-x0)*random.randint(-20,20)
    ay = y0+(ay-y0)*random.randint(-20,20)
    bx = x0+(bx-x0)*random.randint(-20,20)
    by = y0+(by-y0)*random.randint(-20,20)
    cx = x0+(cx-x0)*random.randint(-20,20)
    cy = y0+(cy-y0)*random.randint(-20,20)
    '''
    
    x0 = (ax+bx+cx)/2
    y0 = (ay+by+cy)/2
    ax = x0+(ax-x0)*k
    ay = y0+(ay-y0)*k
    bx = x0+(bx-x0)*k
    by = y0+(by-y0)*k
    cx = x0+(cx-x0)*k
    cy = y0+(cy-y0)*k
    
    
    return ax,ay,bx,by,cx,cy
#isPointinPolygon(-2,0.1,0,   1,0,0,   0,1,0,  0,0,0)  randrange(20,100,5)
#jiance(0,0,0   ,0.1,0.1,0.2   ,1,1,1,-1)
peng(1,1,1,3,8,6,30)
(-115.0, -115.0, -115.0, -55.0, 95.0, 35.0)

这一堆计算是将反射光从三角板反射后投影到吸收面版的投影(可能太细致了),代码有些些凌乱

dateS = pd.read_excel("C://AppData//image//guosai//附件4.xlsx",sheet_name='促动器顶端伸缩量',encoding = 'gbk')
datess = model1.copy()
uint0 = model1.copy()
n = 1
#######
fig=plt.figure(figsize=(180,80))
ax3 = Axes3D(fig)

Az = np.pi*(36.795/180)
Elev = np.pi*(89/180)
RR = 300*0.536*0.001
x0 = -m.cos(Elev)*m.cos(Az)*RR
y0 = -m.cos(Elev)*m.sin(Az)*RR
z0 = -m.sin(Elev)*RR

xn0 = -m.cos(Elev)*m.cos(Az)
yn0 = -m.cos(Elev)*m.sin(Az)
zn0 = -m.sin(Elev)
#print(x0,y0,z0)
#print([xn0,yn0,zn0])
tt = 0
ka = 1
kb = 1/(np.sin(Az))
kc = np.tan(Elev)/np.cos(Az)
kd = -(-x0-kb*y0-kc*z0)
#print(ka,kb,kc,kd)
#########

for i in range(0,len(date3)):
    A = date3.at[i, '主索节点1']
    B = date3.at[i, '主索节点2']
    C = date3.at[i, '主索节点3']
    uint0.at[0,'编号'] = str(A) + str(B) + str(C)
    uint0.at[0,'顶点A'] = A
    uint0.at[0,'顶点B'] = B
    uint0.at[0,'顶点C'] = C
    #
    Ax = date1.at[A, 'X坐标(米)']
    Ay = date1.at[A, 'Y坐标(米)']
    Az = date1.at[A, 'Z坐标(米)']
    
    Bx = date1.at[B, 'X坐标(米)']
    By = date1.at[B, 'Y坐标(米)']
    Bz = date1.at[B, 'Z坐标(米)']
    
    Cx = date1.at[C, 'X坐标(米)']
    Cy = date1.at[C, 'Y坐标(米)']
    Cz = date1.at[C, 'Z坐标(米)']
    
    uint0.at[0,'Ax'] = Ax
    uint0.at[0,'Ay'] = Ay
    uint0.at[0,'Az'] = Az
    
    uint0.at[0,'Bx'] = Bx
    uint0.at[0,'By'] = By
    uint0.at[0,'Bz'] = Bz
    
    uint0.at[0,'Cx'] = Cx
    uint0.at[0,'Cy'] = Cy
    uint0.at[0,'Cz'] = Cz
    
    
    
    #
    Ar, Aa, Ab =  cart2sph(Ax,Ay,Az)
    uint0.at[0,'Ar'] = Ar
    uint0.at[0,'Aa'] = Aa
    uint0.at[0,'Ab'] = Ab
    
    Br, Ba, Bb =  cart2sph(Bx,By,Bz)
    uint0.at[0,'Br'] = Br
    uint0.at[0,'Ba'] = Ba
    uint0.at[0,'Bb'] = Bb
    
    Cr, Ca, Cb =  cart2sph(Cx,Cy,Cz)
    uint0.at[0,'Cr'] = Cr
    uint0.at[0,'Ca'] = Ca
    uint0.at[0,'Cb'] = Cb
    
    
    
    
    ###
    
    AS = 0
    BS = 0
    CS = 0
    
    
    uint0.at[0,'垂线X'] = 0
    if A in list(dateS['对应主索节点编号']):
        if B in list(dateS['对应主索节点编号']):
            if C in list(dateS['对应主索节点编号']):
                uint0.at[0,'垂线X'] = 1
    
        
          
          
    '''
    if A in list(dateS['对应主索节点编号']):
        AS = dateS.set_index('对应主索节点编号').at[A, '伸缩量(米)']
    else:
        AS = 0
    
    if B in list(dateS['对应主索节点编号']):
        BS = dateS.set_index('对应主索节点编号').at[B, '伸缩量(米)']
    else:
        BS = 0
        
    if C in list(dateS['对应主索节点编号']):
        CS = dateS.set_index('对应主索节点编号').at[C, '伸缩量(米)']
    else:
        CS = 0'''
      
     
    
    
    
    
    uint0.at[0,'AS'] = AS
    uint0.at[0,'BS'] = BS
    uint0.at[0,'CS'] = CS
    
    ###
    
    
    
    
    #
    Anr = Ar-AS
    Ana = Aa
    Anb = Ab
    uint0.at[0,'Anr'] = Anr
    uint0.at[0,'Ana'] = Ana
    uint0.at[0,'Anb'] = Anb
    
    Bnr = Br-BS
    Bna = Ba
    Bnb = Bb
    uint0.at[0,'Bnr'] = Bnr
    uint0.at[0,'Bna'] = Bna
    uint0.at[0,'Bnb'] = Bnb
    
    Cnr = Cr-CS
    Cna = Ca
    Cnb = Cb
    uint0.at[0,'Cnr'] = Cnr
    uint0.at[0,'Cna'] = Cna
    uint0.at[0,'Cnb'] = Cnb
    
    
    
    #
    Anx,Any,Anz = sph2cart(Anr,Ana,Anb)
    uint0.at[0,'Anx'] = Anx
    uint0.at[0,'Any'] = Any
    uint0.at[0,'Anz'] = Anz
    
    Bnx,Bny,Bnz = sph2cart(Bnr,Bna,Bnb)
    uint0.at[0,'Bnx'] = Bnx
    uint0.at[0,'Bny'] = Bny
    uint0.at[0,'Bnz'] = Bnz
    
    Cnx,Cny,Cnz = sph2cart(Cnr,Cna,Cnb)
    uint0.at[0,'Cnx'] = Cnx
    uint0.at[0,'Cny'] = Cny
    uint0.at[0,'Cnz'] = Cnz
    #
    
    
    p1 = [Ax,Ay,Az]
    p2 = [Bx,By,Bz]
    p3 = [Cx,Cy,Cz]
    SS,Lab,Lac,Lbc = cal_area(p1,p2,p3)
    uint0.at[0,'板面积'] = SS
    uint0.at[0,'Lab'] = Lab
    uint0.at[0,'Lac'] = Lac
    uint0.at[0,'Lbc'] = Lbc
    
    pn1 = [Anx,Any,Anz]
    pn2 = [Bnx,Bny,Bnz]
    pn3 = [Cnx,Cny,Cnz]
    SnS,Lnab,Lnac,Lnbc = cal_area(pn1,pn2,pn3)
    uint0.at[0,'新版面积'] = SnS
    uint0.at[0,'Lnab'] = Lnab
    uint0.at[0,'Lnac'] = Lnac
    uint0.at[0,'Lnbc'] = Lnbc
    
    #####
    
    '''
    Ajx,Ajy,Ajz,nx,ny,nz = dch(Anx+xn0,Any+yn0,Anz+zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    Bjx,Bjy,Bjz,nx,ny,nz = dch(Bnx+xn0,Bny+yn0,Bnz+zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    Cjx,Cjy,Cjz,nx,ny,nz = dch(Cnx+xn0,Cny+yn0,Cnz+zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    '''
    
    Ajx,Ajy,Ajz,nx,ny,nz = dch(Anx-xn0,Any-yn0,Anz-zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    Bjx,Bjy,Bjz,nx,ny,nz = dch(Bnx-xn0,Bny-yn0,Bnz-zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    Cjx,Cjy,Cjz,nx,ny,nz = dch(Cnx-xn0,Cny-yn0,Cnz-zn0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    
    lost = np.abs((nx*x0+ny*y0+nz*z0)/(np.sqrt(nx**2+ny**2+nz**2)*np.sqrt(x0**2+y0**2+z0**2)))
    uint0.at[0,'密度折损率'] = lost
    
    [AApx,AApy,AApz] = jiance(Anx,Any,Anz ,Ajx,Ajy,Ajz ,ka,kb,kc,kd)
    [BBpx,BBpy,BBpz] = jiance(Bnx,Bny,Bnz ,Bjx,Bjy,Bjz ,ka,kb,kc,kd)
    [CCpx,CCpy,CCpz] = jiance(Cnx,Cny,Cnz ,Cjx,Cjy,Cjz ,ka,kb,kc,kd)
    #uint0.at[0,'垂线X'] = np.array([Ajx,Ajy,Ajz])-np.array([Anx,Any,Anz])
    uint0.at[0,'垂线Y'] = np.array([xn0,yn0,zn0])
    uint0.at[0,'垂线Z'] = np.array([nx,ny,nz])
    #XQx = [AApx,BBpx,CCpx,AApx]
    #YQy = [AApy,BBpy,CCpy,AApy]
    YQz = [0,0,0,0]
    
    #AApx,AApy,BBpx,BBpy,CCpx,CCpy = peng(AApx,AApy,BBpx,BBpy,CCpx,CCpy,3)

    XQx = [AApx,BBpx,CCpx,AApx]
    YQy = [AApy,BBpy,CCpy,AApy]
    if uint0.at[0,'垂线X'] == 1:
        ax3.plot3D(XQx,YQy,YQz,'red')
        ax3.scatter3D(x0,y0,0, 'r')


   
    if isPointinPolygon(x0,y0,0,AApx,AApy,0,BBpx,BBpy,0,CCpx,CCpy,0):
        
        p1 = np.array([Anx,Any,Anz])
        p2 = -(np.array([Ajx,Ajy,Ajz])-np.array([Anx,Any,Anz]))*140+np.array([Anx,Any,Anz])
        #p2 = np.array([AApx,AApy,AApz])
        p3 = np.array([Anx,Any,Anz])
        p4 = -(np.array([xn0,yn0,zn0]))*120+np.array([Anx,Any,Anz])
        #ax3.plot3D([p1[0],p2[0]],[p1[1],p2[1]],[p1[2],p2[2]],'red')
        if tt%60 == 0:
            #ax3.plot3D([p1[0],p2[0]],[p1[1],p2[1]],[p1[2],p2[2]],'red')
            tt = tt+1
            #ax3.plot3D([p3[0],p4[0]],[p3[1],p4[1]],[p3[2],p4[2]],'blue')
        else:
            tt = tt+1
        SgS,Lab,Lac,Lbc = cal_area(p1,p2,p3)
        uint0.at[0,'吸收量'] = (np.pi/4)*lost
        uint0.at[0,'是否接收'] = 'yes'
        
    else:
        uint0.at[0,'吸收量'] = 0
        uint0.at[0,'是否接收'] = 'no'
        
        

    ''' px,py,pz,nx,ny,nz = dch(x0,y0,z0,Anx,Any,Anz,Bnx,Bny,Bnz,Cnx,Cny,Cnz)
    
    dis = get_point_line_distance(px,py,pz,xo,yo,zo,xo+x0,yo+y0,zo+z0)
    uint0.at[0,'垂线X'] = dis
    if dis<=5:
        SgS = ((nx*x0+ny*y0+nz*z0)/(np.sqrt(nx**2+ny**2+nz**2)*np.sqrt(x0**2+y0**2+z0**2)))*SnS
        uint0.at[0,'吸收面积'] = SgS
        
    else:
        uint0.at[0,'吸收面积'] = 0'''

    #####
    datess = datess.append(uint0,ignore_index=True)
    n = n+1   
    if n%500 == 0:
        #plt.show()
        #break
        print(n)
#ax3.scatter3D(xs,ys,zs, 'r')
plt.show()

print("总板面积")
print(datess['板面积'].sum())  
print("总有效板数")
print(datess[((datess['是否接收'] == 'yes'))]['吸收量'].count())

print("工作区有效板数")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['吸收量'].count())
print("工作区板面积")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['板面积'].sum())

print("总收益")
print(datess['吸收量'].sum())
print("工作区收益")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['吸收量'].sum())




'''
print("总板面积")
print(datess['板面积'].sum())
print("总有效板数")
print(datess[((datess['是否接收'] == 'yes'))]['吸收量'].count())

print("工作区有效板数")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['吸收量'].count())
print("工作区板面积")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['板面积'].sum())

print("总收益")
print(datess['吸收量'].sum())
print("工作区收益")
print(datess[((datess['是否接收'] == 'yes')&(datess['垂线X'] == 1))]['吸收量'].sum())

'''

初始反射锅投影接受平面

2021国赛A题代码记录_第5张图片

调整之后的反射面(看着不太好)

2021国赛A题代码记录_第6张图片

通过判断接受面板中心是否在反射三角形里判断是否接受。

结果放在了一个表格里
只需要5个积分
点击下载

你可能感兴趣的:(数学建模,python,开发语言,后端)