__author__ = 'zy'
import math
def JIAODU(x1,y1,x2,y2):
jd=math.atan((y2-y1)/(x2-x1))
jd=jd/math.pi*180
if (x2-x1)<0:
jd=jd+180
elif (y2-y1)>=40:
jd=jd
else:
jd=jd+360
return jd
g=open(r'g:\zuobiao.txt')
lines=g.readlines()
g.close()
Xjd=float(lines[2])
Yjd=float(lines[3])
Xzh=float(lines[0])
Yzh=float(lines[1])
Xhz=float(lines[4])
Yhz=float(lines[5])
a=-JIAODU(Xzh,Yzh,Xjd,Yjd)+JIAODU(Xjd,Yjd,Xhz,Yhz)+180
print '请输入缓和曲线长度'
Ls=float(lines[7])
R=float(lines[6])
a=a/180*math.pi
m=Ls/2-pow(Ls,3)/240/pow(R,2)
P=pow(Ls,2)/24/R
B0=Ls/2/R*180/math.pi
Th=m+(R+P)*math.tan(a/2)
Lh=math.pi*R/180*(a-2*B0)+2*Ls
Eh=(R+P)/math.cos(a/2)-R
q=2*Th-Lh
Kjd=Th
Kzh=Kjd-Th
Khy=Kzh+Ls
Kqz=Kzh+Lh/2
Lt=(a-2*B0)*R
Kyh=Khy+Lt
Khz=Kyh+Ls
x=[]
y=[]
X=[]
Y=[]
n=float(raw_input('输入桩位间隔'))
print Khz
azh=JIAODU(Xzh,Yzh,Xjd,Yjd)/180*math.pi
ahz=JIAODU(Xjd,Yjd,Xhz,Yhz)/180*math.pi
def ZHHY(i,j):
Ki=i
Li=Ki-Kzh
x.append(Li-pow(Li,5)/40/pow(R,2)/pow(Ls,2))
y.append(pow(Li,3)/6/R/Ls)
X.append(Xzh+x[j]*math.cos(azh)-y[j]*math.sin(azh))
Y.append(Yzh+x[j]*math.sin(azh)+y[j]*math.cos(azh))
def HYYH(i,j):
Ki=i
Li=Ki-Kzh
PHi=B0+(Li-Ls)/R*180/math.pi
x.append(m+R*math.sin(PHi))
y.append(P+R*(1-math.cos(PHi)))
X.append(Xzh+x[j]*math.cos(azh)-y[j]*math.sin(azh))
Y.append(Yzh+x[j]*math.sin(azh)+y[j]*math.cos(azh))
def YHHZ(i,j):
Ki=i
Li=Khz-Ki
x.append(Li-pow(Li,5)/40/pow(R,2)/pow(Ls,2))
y.append(pow(Li,3)/6/R/Ls)
X.append(Xhz+x[j]*math.cos(ahz)+y[j]*math.sin(ahz))
Y.append(Yhz+x[j]*math.sin(ahz)-y[j]*math.cos(ahz))
i=0
j=0
while i<Khz:
i=i+n
if i<= Khy:
ZHHY(i,j)
elif i<=Kyh:
HYYH(i,j)
else :
YHHZ(i,j)
j=j+1
f = open("F:/1.txt", "w+")
f.write("里程 \t X坐标 \t Y坐标\n")
for i in range(0, len(X)):
i=0
i=i+n
f.write("里程"+i+"\t" + X[i] +"\t"+Y[i]+ "\n")
f.close()