Clothoid Curves

ceaser

Active Member
Licensed User
I wonder if somebody can help me please. I know it has nothing to do with Basic4ppc, but I need help.

A circular curve has normally before and after the curve a transition curve. This is to gradually apply the centrifugal force and also to apply the superelevation.

I have the formulae to calculate the coordinates given the stake value and offset from the centreline. But what I want to do is calculate the stake value and offset given the coordinates on the clothoid section.

I had it working on the older Workabout (Opl), but I have forgotten what I did there. I also looked on the internet, but I cannot find anything there.

Thanks
Michael
 

ceaser

Active Member
Licensed User
Problem Solved!!:sign0060:

Public Sub YXZToSV(Y4,X4) '***********************************************
Dim e,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,Seite
Dim CB1,CB2,L,Cy,Cx

e=999999999 :e1=0 :jj=0
SV=0 :OF=0

If Data.numbalign=0 Then
'no solution found
Msgbox("There Are No Alignment Points","No Alignment Points",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
End If

For j=1 To Data.numbalign-1
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
e2=CD :e3=CB
'CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Y4,X4,1)
'e4=CB-e3
i=((Y4-Data.WK2(1,j+3500))*(Data.WK2(2,j+3501)-Data.WK2(2,j+3500)))-((Data.WK2(1,j+3501)-Data.WK2(1,j+3500))*(X4-Data.WK2(2,j+3500)))
If i =>0 Then Seite= -1 Else Seite= 1
e5=e3+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK096(Data.WK2(1,j+3500),Data.WK2(2,j+3500),e3,Y4,X4,e5,0,0,0,5)
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Y,X,1)
e9=CD
CK006(Y,X,Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
If Abs(CD+e9-e2)<0.1 Then
CK006(Y4,X4,Y,X,1)
If CD<e Then
e=CD :e1=j :e8=Seite
e6=Y :e7=X
End If
End If
Next j
If e1=0 OR e>9999 Then
'no solution found
Msgbox("Cannot Find A Solution","No Solution",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
Else
If Data.WK2(3,e1+3501)="0.000" AND Data.WK2(5,e1+3501)="0.000" AND Data.WK2(3,e1+3501)="0.000" Then
'point is on a straight
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),e6,e7,1)
SV=CD+Data.WK2(6,e1+3500)
OF=(e*(0-e8))'+StakeOffset
Else If Data.WK2(3,e1+3501)<>"0.000" Then'AND Data.WK2(5,e1+3501)=2 Then
'is on a circular curve
CK006(Data.WK2(1,e1+3499),Data.WK2(2,e1+3499),Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
If Int(Data.WK2(3,e1+3501))<=0 Then e11=-1 Else e11=1
CB=CB+(90*e11)
If CB>360 Then CB=CB-360
If CB<0 Then CB=360+CB
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),CB,Abs(Data.WK2(3,e1+3501)),2)
CK006(Y2,X2,Y4,X4,1)
e9=CB
If Data.WK2(3,e1+3501)<0 Then
OF=CD-Abs(Data.WK2(3,e1+3501))
Else
OF=Abs(Data.WK2(3,e1+3501))-CD
End If
CK006(Y2,X2,Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
e10=e9-CB
If e10<-180 Then e10=360+e10
If e10>180 Then e10=360-e10
e10=Abs(e10)
SV=Data.WK2(6,e1+3500)+((Main.Rad*e10)*Abs(Data.WK2(3,e1+3501)))
Else If Data.WK2(4,e1+3501)<>"0.000" AND Data.WK2(5,e1+3501)=1 Then
'first transition
CK006(Data.WK2(1,e1+3499),Data.WK2(2,e1+3499),Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
CB1=CB
i=((Y4-Data.WK2(1,e1+3499))*(Data.WK2(2,e1+3500)-Data.WK2(2,e1+3499)))-((Data.WK2(1,e1+3500)-Data.WK2(1,e1+3499))*(X4-Data.WK2(2,e1+3499)))
If i=>0 Then Seite=-1 Else Seite=1
e5=CB1+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),Y4,X4,1)
e4=CD
CK096(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),CB1,Y4,X4,e5,0,0,0,5)
CK006(Y,X,Y4,X4,1) :e6=CD
e7=Sqrt(e4^2-CD^2)
L=e7+1/(40*Data.WK2(3,e1+3502)^2) :Cy=L
Cx=((L^3)/(6*Data.WK2(3,e1+3502)*Data.WK2(4,e1+3501)))*(1-((l^4)/(56*Data.WK2(3,e1+3502)^2*Data.WK2(4,e1+3501)^2))+((l^8)/(7040*Data.WK2(3,e1+3502)^4*Data.WK2(4,e1+3501)^4)))
OF=(e6+(Cx*Seite))*(0-Seite)
SV=Data.WK2(6,e1+3500)+L
Else If Int(Abs(Data.WK2(3,e1+3501)))=0 AND Data.WK2(4,e1+3501)>0 AND Data.WK2(5,e1+3501)=3 Then
'second transition
CK006(Data.WK2(1,e1+3502),Data.WK2(2,e1+3502),Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),1)
CB1=CB
i=((Y4-Data.WK2(1,e1+3500))*(Data.WK2(2,e1+3501)-Data.WK2(2,e1+3500)))-((Data.WK2(1,e1+3501)-Data.WK2(1,e1+3500))*(X4-Data.WK2(2,e1+3500)))
If i=>0 Then Seite=-1 Else Seite=1
e5=CB1+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK006(Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),Y4,X4,1)
e4=CD
CK096(Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),CB1,Y4,X4,e5,0,0,0,5)
CK006(Y,X,Y4,X4,1) :e6=CD
e7=Sqrt(e4^2-CD^2)
L=e7+1/(40*Data.WK2(3,e1+3500)^2) :Cy=L
Cx=((L^3)/(6*Data.WK2(3,e1+3500)*Data.WK2(4,e1+3501)))*(1-((l^4)/(56*Data.WK2(3,e1+3500)^2*Data.WK2(4,e1+3501)^2))+((l^8)/(7040*Data.WK2(3,e1+3500)^4*Data.WK2(4,e1+3501)^4)))
OF=(e6+(Cx*Seite))*(0-Seite)
SV=Data.WK2(6,e1+3501)-L
End If
End If
End Sub

Public Sub CalcYXZ(SV2,Offset)
Dim e,e1,e2,e3,e11,CD1,CB1,Tr,L,BB,B1,B2,Delta,Cy,Cx
Dim Def1,Angle,HorDir,Constant,dis1,dis2,dis3

jj=0
If Data.numbalign=0 Then
'no solution found
Msgbox("There Are No Alignment Points","No Alignment Points",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
End If

For j=1 To Data.numbalign-1
If Int(SV2*1000)/1000>=Data.WK2(6,j+3500) AND Int(SV2*1000)/1000<=Data.WK2(6,j+3501) Then
If Int(Abs(Data.WK2(3,j+3501)))=0 AND Int(Abs(Data.WK2(4,j+3501)))=0 Then
'point is on a straight
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),CB,Abs(SV2-Data.WK2(6,j+3500)),2)
If Offset<=0 Then
CB=CB-90
Else
CB=CB+90
End If
If CB<=0 Then CB=360+CB
If CB>360 Then CB=CB-360
CK006(Y2,X2,CB,Abs(Offset),2)
'Y2,X2
Return
Else If Int(Abs(Data.WK2(3,j+3501)))<>0 Then
'point is on a circular curve
If Int(Data.WK2(3,j+3501))<=0 Then e11=-1 Else e11=1
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CD1=CD :CB1=CB
Delta=(ACos((Data.WK2(3,j+3501)^2+Data.WK2(3,j+3501)^2-CD1^2)/(Data.WK2(3,j+3501)*Data.WK2(3,j+3501)*2)))*Main.Deg
Tr=CB1-(e11*Delta/2)
Tr=Tr+(e11*90)
If Tr>360 Then Tr=Tr-360
If Tr<0 Then Tr=360+Tr
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Tr,Abs(Data.WK2(3,j+3501)),2)
Cy=Engine.Y2 :Cx=Engine.X2
Tr=Tr+180
If Tr>360 Then Tr=Tr-360
If Tr<0 Then Tr=360+Tr
L=Abs((Delta*Main.Rad)*Data.WK2(3,j+3501))
Tr1=((SV2-Data.WK2(6,j+3500))/L)*Delta
Tr=Tr+(e11*Tr1)
'calc the distance away from the center
e2=Abs(Data.WK2(3,j+3501))-(Offset*e11)
CK006(Cy,Cx,Tr,e2,2)
Return
Else If Int(Abs(Data.WK2(3,j+3501)))=0 AND Data.WK2(4,j+3501)>0 AND Data.WK2(5,j+3501)=1 Then'AND Int(SV2*1000)/1000>=Data.WK2(6,j+3500) AND Int(SV2*1000)/1000<=Data.WK2(6,j+3501) Then
'first transition
If Data.WK2(3,j+3502)>=0 Then S1=1 Else S1=-1
If Offset<=0 Then e11=-1 Else e11=1
L=SV2-Data.WK2(6,j+3500)
CK006(Data.WK2(1,j+3499),Data.WK2(2,j+3499),Data.WK2(1,j+3500),Data.WK2(2,j+3500),1)
CB1=CB+(90*e11)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),CB1,Abs(Offset),2)
Cy=L*(1-((l^4)/(40*Data.WK2(3,j+3502)^2*Data.WK2(4,j+3501)^2))+((l^8)/(3456*Data.WK2(3,j+3502)^4*Data.WK2(4,j+3501)^4)))
Cx=((L^3)/(6*Data.WK2(3,j+3502)*Data.WK2(4,j+3501)))*(1-((l^4)/(56*Data.WK2(3,j+3502)^2*Data.WK2(4,j+3501)^2))+((l^8)/(7040*Data.WK2(3,j+3502)^4*Data.WK2(4,j+3501)^4)))
CK006(Y2,X2,CB,Cy,2)
CB1=CB+(90*S1)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Y2,X2,CB1,Abs(Cx),2)
Else If Int(Abs(Data.WK2(3,j+3501)))=0 AND Data.WK2(4,j+3501)>0 AND Data.WK2(5,j+3501)=3 Then
'second transition
If Data.WK2(3,j+3500)>=0 Then S1=-1 Else S1=1
If Offset<=0 Then e11=1 Else e11=-1
L=Data.WK2(6,j+3501)-SV2
CK006(Data.WK2(1,j+3502),Data.WK2(2,j+3502),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CB1=CB+(90*e11)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Data.WK2(1,j+3501),Data.WK2(2,j+3501),CB1,Abs(Offset),2)
Cy=L*(1-((l^4)/(40*Data.WK2(3,j+3500)^2*Data.WK2(4,j+3501)^2))+((l^8)/(3456*Data.WK2(3,j+3500)^4*Data.WK2(4,j+3501)^4)))
Cx=(L^3)/(6*Data.WK2(3,j+3500)*Data.WK2(4,j+3501))*(1-((l^4)/(56*Data.WK2(3,j+3500)^2*Data.WK2(4,j+3501)^2))+((l^8)/(7040*Data.WK2(3,j+3500)^4*Data.WK2(4,j+3501)^4)))
CK006(Y2,X2,CB,Cy,2)
CB1=CB+(90*S1)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Y2,X2,CB1,Abs(Cx),2)
End If
End If
Next j

End Sub
 

Zenerdiode

Active Member
Licensed User
:SHOCKED:

Blimey!

Although I've been following the stuff you Klaus and Andrew do and its simply amazing. :)
 

ceaser

Active Member
Licensed User
Hi Zenerdiode

Watch out for the new CAD program coming soon. I thank Klaus and Agraham in advance for their help.
 

Cableguy

Expert
Licensed User
Longtime User
Problem Solved!!:sign0060:

Public Sub YXZToSV(Y4,X4) '***********************************************
Dim e,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,Seite
Dim CB1,CB2,L,Cy,Cx

e=999999999 :e1=0 :jj=0
SV=0 :OF=0

If Data.numbalign=0 Then
'no solution found
Msgbox("There Are No Alignment Points","No Alignment Points",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
End If

For j=1 To Data.numbalign-1
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
e2=CD :e3=CB
'CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Y4,X4,1)
'e4=CB-e3
i=((Y4-Data.WK2(1,j+3500))*(Data.WK2(2,j+3501)-Data.WK2(2,j+3500)))-((Data.WK2(1,j+3501)-Data.WK2(1,j+3500))*(X4-Data.WK2(2,j+3500)))
If i =>0 Then Seite= -1 Else Seite= 1
e5=e3+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK096(Data.WK2(1,j+3500),Data.WK2(2,j+3500),e3,Y4,X4,e5,0,0,0,5)
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Y,X,1)
e9=CD
CK006(Y,X,Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
If Abs(CD+e9-e2)<0.1 Then
CK006(Y4,X4,Y,X,1)
If CD<e Then
e=CD :e1=j :e8=Seite
e6=Y :e7=X
End If
End If
Next j
If e1=0 OR e>9999 Then
'no solution found
Msgbox("Cannot Find A Solution","No Solution",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
Else
If Data.WK2(3,e1+3501)="0.000" AND Data.WK2(5,e1+3501)="0.000" AND Data.WK2(3,e1+3501)="0.000" Then
'point is on a straight
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),e6,e7,1)
SV=CD+Data.WK2(6,e1+3500)
OF=(e*(0-e8))'+StakeOffset
Else If Data.WK2(3,e1+3501)<>"0.000" Then'AND Data.WK2(5,e1+3501)=2 Then
'is on a circular curve
CK006(Data.WK2(1,e1+3499),Data.WK2(2,e1+3499),Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
If Int(Data.WK2(3,e1+3501))<=0 Then e11=-1 Else e11=1
CB=CB+(90*e11)
If CB>360 Then CB=CB-360
If CB<0 Then CB=360+CB
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),CB,Abs(Data.WK2(3,e1+3501)),2)
CK006(Y2,X2,Y4,X4,1)
e9=CB
If Data.WK2(3,e1+3501)<0 Then
OF=CD-Abs(Data.WK2(3,e1+3501))
Else
OF=Abs(Data.WK2(3,e1+3501))-CD
End If
CK006(Y2,X2,Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
e10=e9-CB
If e10<-180 Then e10=360+e10
If e10>180 Then e10=360-e10
e10=Abs(e10)
SV=Data.WK2(6,e1+3500)+((Main.Rad*e10)*Abs(Data.WK2(3,e1+3501)))
Else If Data.WK2(4,e1+3501)<>"0.000" AND Data.WK2(5,e1+3501)=1 Then
'first transition
CK006(Data.WK2(1,e1+3499),Data.WK2(2,e1+3499),Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),1)
CB1=CB
i=((Y4-Data.WK2(1,e1+3499))*(Data.WK2(2,e1+3500)-Data.WK2(2,e1+3499)))-((Data.WK2(1,e1+3500)-Data.WK2(1,e1+3499))*(X4-Data.WK2(2,e1+3499)))
If i=>0 Then Seite=-1 Else Seite=1
e5=CB1+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK006(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),Y4,X4,1)
e4=CD
CK096(Data.WK2(1,e1+3500),Data.WK2(2,e1+3500),CB1,Y4,X4,e5,0,0,0,5)
CK006(Y,X,Y4,X4,1) :e6=CD
e7=Sqrt(e4^2-CD^2)
L=e7+1/(40*Data.WK2(3,e1+3502)^2) :Cy=L
Cx=((L^3)/(6*Data.WK2(3,e1+3502)*Data.WK2(4,e1+3501)))*(1-((l^4)/(56*Data.WK2(3,e1+3502)^2*Data.WK2(4,e1+3501)^2))+((l^8)/(7040*Data.WK2(3,e1+3502)^4*Data.WK2(4,e1+3501)^4)))
OF=(e6+(Cx*Seite))*(0-Seite)
SV=Data.WK2(6,e1+3500)+L
Else If Int(Abs(Data.WK2(3,e1+3501)))=0 AND Data.WK2(4,e1+3501)>0 AND Data.WK2(5,e1+3501)=3 Then
'second transition
CK006(Data.WK2(1,e1+3502),Data.WK2(2,e1+3502),Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),1)
CB1=CB
i=((Y4-Data.WK2(1,e1+3500))*(Data.WK2(2,e1+3501)-Data.WK2(2,e1+3500)))-((Data.WK2(1,e1+3501)-Data.WK2(1,e1+3500))*(X4-Data.WK2(2,e1+3500)))
If i=>0 Then Seite=-1 Else Seite=1
e5=CB1+(Seite*90)
If e5>360 Then e5=e5-360
If e5<0 Then e5=360+e5
CK006(Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),Y4,X4,1)
e4=CD
CK096(Data.WK2(1,e1+3501),Data.WK2(2,e1+3501),CB1,Y4,X4,e5,0,0,0,5)
CK006(Y,X,Y4,X4,1) :e6=CD
e7=Sqrt(e4^2-CD^2)
L=e7+1/(40*Data.WK2(3,e1+3500)^2) :Cy=L
Cx=((L^3)/(6*Data.WK2(3,e1+3500)*Data.WK2(4,e1+3501)))*(1-((l^4)/(56*Data.WK2(3,e1+3500)^2*Data.WK2(4,e1+3501)^2))+((l^8)/(7040*Data.WK2(3,e1+3500)^4*Data.WK2(4,e1+3501)^4)))
OF=(e6+(Cx*Seite))*(0-Seite)
SV=Data.WK2(6,e1+3501)-L
End If
End If
End Sub

Public Sub CalcYXZ(SV2,Offset)
Dim e,e1,e2,e3,e11,CD1,CB1,Tr,L,BB,B1,B2,Delta,Cy,Cx
Dim Def1,Angle,HorDir,Constant,dis1,dis2,dis3

jj=0
If Data.numbalign=0 Then
'no solution found
Msgbox("There Are No Alignment Points","No Alignment Points",cMsgboxOK,cMsgboxExclamation)
jj=-999999
Return
End If

For j=1 To Data.numbalign-1
If Int(SV2*1000)/1000>=Data.WK2(6,j+3500) AND Int(SV2*1000)/1000<=Data.WK2(6,j+3501) Then
If Int(Abs(Data.WK2(3,j+3501)))=0 AND Int(Abs(Data.WK2(4,j+3501)))=0 Then
'point is on a straight
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),CB,Abs(SV2-Data.WK2(6,j+3500)),2)
If Offset<=0 Then
CB=CB-90
Else
CB=CB+90
End If
If CB<=0 Then CB=360+CB
If CB>360 Then CB=CB-360
CK006(Y2,X2,CB,Abs(Offset),2)
'Y2,X2
Return
Else If Int(Abs(Data.WK2(3,j+3501)))<>0 Then
'point is on a circular curve
If Int(Data.WK2(3,j+3501))<=0 Then e11=-1 Else e11=1
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CD1=CD :CB1=CB
Delta=(ACos((Data.WK2(3,j+3501)^2+Data.WK2(3,j+3501)^2-CD1^2)/(Data.WK2(3,j+3501)*Data.WK2(3,j+3501)*2)))*Main.Deg
Tr=CB1-(e11*Delta/2)
Tr=Tr+(e11*90)
If Tr>360 Then Tr=Tr-360
If Tr<0 Then Tr=360+Tr
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),Tr,Abs(Data.WK2(3,j+3501)),2)
Cy=Engine.Y2 :Cx=Engine.X2
Tr=Tr+180
If Tr>360 Then Tr=Tr-360
If Tr<0 Then Tr=360+Tr
L=Abs((Delta*Main.Rad)*Data.WK2(3,j+3501))
Tr1=((SV2-Data.WK2(6,j+3500))/L)*Delta
Tr=Tr+(e11*Tr1)
'calc the distance away from the center
e2=Abs(Data.WK2(3,j+3501))-(Offset*e11)
CK006(Cy,Cx,Tr,e2,2)
Return
Else If Int(Abs(Data.WK2(3,j+3501)))=0 AND Data.WK2(4,j+3501)>0 AND Data.WK2(5,j+3501)=1 Then'AND Int(SV2*1000)/1000>=Data.WK2(6,j+3500) AND Int(SV2*1000)/1000<=Data.WK2(6,j+3501) Then
'first transition
If Data.WK2(3,j+3502)>=0 Then S1=1 Else S1=-1
If Offset<=0 Then e11=-1 Else e11=1
L=SV2-Data.WK2(6,j+3500)
CK006(Data.WK2(1,j+3499),Data.WK2(2,j+3499),Data.WK2(1,j+3500),Data.WK2(2,j+3500),1)
CB1=CB+(90*e11)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Data.WK2(1,j+3500),Data.WK2(2,j+3500),CB1,Abs(Offset),2)
Cy=L*(1-((l^4)/(40*Data.WK2(3,j+3502)^2*Data.WK2(4,j+3501)^2))+((l^8)/(3456*Data.WK2(3,j+3502)^4*Data.WK2(4,j+3501)^4)))
Cx=((L^3)/(6*Data.WK2(3,j+3502)*Data.WK2(4,j+3501)))*(1-((l^4)/(56*Data.WK2(3,j+3502)^2*Data.WK2(4,j+3501)^2))+((l^8)/(7040*Data.WK2(3,j+3502)^4*Data.WK2(4,j+3501)^4)))
CK006(Y2,X2,CB,Cy,2)
CB1=CB+(90*S1)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Y2,X2,CB1,Abs(Cx),2)
Else If Int(Abs(Data.WK2(3,j+3501)))=0 AND Data.WK2(4,j+3501)>0 AND Data.WK2(5,j+3501)=3 Then
'second transition
If Data.WK2(3,j+3500)>=0 Then S1=-1 Else S1=1
If Offset<=0 Then e11=1 Else e11=-1
L=Data.WK2(6,j+3501)-SV2
CK006(Data.WK2(1,j+3502),Data.WK2(2,j+3502),Data.WK2(1,j+3501),Data.WK2(2,j+3501),1)
CB1=CB+(90*e11)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Data.WK2(1,j+3501),Data.WK2(2,j+3501),CB1,Abs(Offset),2)
Cy=L*(1-((l^4)/(40*Data.WK2(3,j+3500)^2*Data.WK2(4,j+3501)^2))+((l^8)/(3456*Data.WK2(3,j+3500)^4*Data.WK2(4,j+3501)^4)))
Cx=(L^3)/(6*Data.WK2(3,j+3500)*Data.WK2(4,j+3501))*(1-((l^4)/(56*Data.WK2(3,j+3500)^2*Data.WK2(4,j+3501)^2))+((l^8)/(7040*Data.WK2(3,j+3500)^4*Data.WK2(4,j+3501)^4)))
CK006(Y2,X2,CB,Cy,2)
CB1=CB+(90*S1)
If CB1<0 Then CB1=360+CB1
If CB1>360 Then CB1=CB1-360
CK006(Y2,X2,CB1,Abs(Cx),2)
End If
End If
Next j

End Sub

O quê? I mean, WHAT?
You lost me at Public Sub YXZToSV(Y4,X4) ::sign0161:sign0060::BangHead:
 

ceaser

Active Member
Licensed User
A horizontal alignment (used on roads, railways, etc) consists of straights defined by coordinates at all the intersection points (called PI's - point of intersection). Each PI has attached to it a circular curve, a clothoid curve in and a clothoid curve out - so each PI has a Y & X coordinate, a radius, transition in and transition out. We use the transition in to gently apply the superelevation and the centrifugal force before the vehicle enters the circular curve. The reverse is done on the transition out before the vehicle enters the straight portion of the road again.

What my 2 subs do is in the one I calculate the coordinates depending the stake value (chainage) and the offset. In the other one I calculate the stake value and offset from the centerline given the coordinates. The second one is quite handy in that I can hold my prism anywhere on the project, read the horizontal angle, vertical angle and slope distance to the prism and the program will tell me exactly at what stake value and offset I am. Then in another routine I calculate the design height using the vertical alignment (cubic parabolic curves) and in this way I can control the elevation of a project.

Hope that clears things up:sign0089:

Regards
Michael
 
Last edited:
Top