{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "# Chapter 10: Curves"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 379   pb-1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Tangent length =', 58.45305445925609)\n",
      "('Length long of cord=', 114.35142994976763)\n",
      "('Length of curve =', 115.19173063162576)\n",
      "('chainage of commencement =', 1262.046945540744)\n",
      "('chainage of tangency =', 1377.2386761723697)\n",
      "('apex distance =', 6.143663587883047)\n",
      "('versed sine of curve is', 6.009409798203436)\n"
     ]
    }
   ],
   "source": [
    "#ch-10 page 379   pb-1\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "r=275;\n",
    "t=24;\n",
    "l=1320.5;\n",
    "\n",
    "tl=r*math.tan((t/2)*(math.pi/180));\n",
    "print('Tangent length =',tl);\n",
    "llc=2*r*math.sin((t/2)*(math.pi/180));\n",
    "print('Length long of cord=',llc);\n",
    "loc=(math.pi*r*t/180);\n",
    "print('Length of curve =',loc)\n",
    "coc=l-tl;\n",
    "ct=coc+loc;\n",
    "print('chainage of commencement =',coc);\n",
    "print('chainage of tangency =',ct);\n",
    "k=math.cos((t/2)*math.pi/180);\n",
    "ad=r*((1/k)-1);\n",
    "print('apex distance =',ad)\n",
    "k1=math.cos((t/2)*(math.pi/180))\n",
    "vsc=r*(1-k1);\n",
    "print('versed sine of curve is',vsc);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 379,380   pb-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('radius of curve ', 573.0)\n",
      "('Tangent length =', 153.5348872630333)\n",
      "('Length of curve =', 300.02209841782525)\n",
      "('Length long of cord=', 296.60662568748876)\n",
      "('chainage of commencement =', 2606.4651127369666)\n",
      "('chainage of tangency =', 2906.487211154792)\n",
      "('length of each half =', 148.30331284374438)\n",
      "('O30=', 18.738622298863106, 'O60=', 16.374481794326243, 'O90=', 12.412299602376265, 'O120=', 6.81817453294525, 'O148.3=', 0.0)\n"
     ]
    }
   ],
   "source": [
    "#ch-10 page 379,380   pb-2\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "ac=45.5;cb=75.5;\n",
    "#a\n",
    "\n",
    "t=cb-ac;\n",
    "l1=1719;\n",
    "l=2760;\n",
    "\n",
    "#b\n",
    "r=l1/3;\n",
    "print('radius of curve ',r);\n",
    "\n",
    "#c\n",
    "tl=r*math.tan((t/2)*(math.pi/180));\n",
    "print('Tangent length =',tl);\n",
    "#d\n",
    "loc=(math.pi*r*t/180);\n",
    "print('Length of curve =',loc)\n",
    "#e\n",
    "llc=2*r*math.sin((t/2)*(math.pi/180));\n",
    "print('Length long of cord=',llc);\n",
    "\n",
    "#f,g\n",
    "coc=l-tl;\n",
    "ct=coc+loc;\n",
    "print('chainage of commencement =',coc);\n",
    "print('chainage of tangency =',ct);\n",
    "\n",
    "#h\n",
    "\n",
    "half=0.5*llc;\n",
    "print('length of each half =',half);\n",
    "\n",
    "ini=30;\n",
    "\n",
    "k=math.sqrt(r*r-(half*half));\n",
    "o=r-k\n",
    "k1=r-o;\n",
    "O30=(math.sqrt(r*r-(ini*ini)))-k1;\n",
    "O60=(math.sqrt(r*r-(2*ini*2*ini)))-k1;\n",
    "     \n",
    "O90=(math.sqrt(r*r-(3*ini*3*ini)))-k1;\n",
    "O120=(math.sqrt(r*r-(4*ini*4*ini)))-k1;\n",
    "Oh=(math.sqrt(r*r-(half*half)))-k1;\n",
    "\n",
    "print('O30=',O30,'O60=',O60,'O90=',O90,'O120=',O120,'O148.3=',Oh);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ch-10 page 381   pb-3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Tangent length =', 150.2288093231531)\n",
      "('Length of curve =', 278.55454861829503)\n",
      "('chainage of T1=', 360.00119067684693)\n",
      "('chainage of T2=', 638.555739295142)\n",
      "('chainage covered=', 630.0011906768469)\n",
      "('Length of final sub cord=', 8.55454861829503)\n",
      "('first ofset=', 1.5)\n",
      "('second ofset=', 3.0)\n",
      "('tenth ofset=', 0.5496946010193738)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "a=126.8;\n",
    "t=180-a;\n",
    "r=300;\n",
    "#b\n",
    "tl=r*math.tan((t/2)*(math.pi/180));\n",
    "print('Tangent length =',tl);\n",
    "\n",
    "#c\n",
    "loc=(math.pi*r*t/180);\n",
    "print('Length of curve =',loc)\n",
    "\n",
    "#d\n",
    "l=510.23;\n",
    "ct1=l-tl;\n",
    "ct2=ct1+loc;\n",
    "\n",
    "print('chainage of T1=',ct1);\n",
    "print('chainage of T2=',ct2);\n",
    "\n",
    "#f\n",
    "n=9;\n",
    "b=30;\n",
    "cc=ct1+270;\n",
    "lfsc=ct2-cc;\n",
    "print('chainage covered=',cc);\n",
    "print('Length of final sub cord=',lfsc);\n",
    "\n",
    "O1=(b*b)/(2*r);\n",
    "O2=(b*b)/r;\n",
    "\n",
    "O10=(lfsc*(b+lfsc))/(2*r);\n",
    "\n",
    "print('first ofset=',O1);\n",
    "print('second ofset=',O2);\n",
    "print('tenth ofset=',O10);\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 382   pb-4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(165.95962740164575, 158.58327092428829)\n",
      "('Radius R=', 143.72525333242524)\n",
      "('Tangent length BT1=', 82.97981370082289)\n",
      "('Tangent length CT1=', 67.02018629917711)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "ab=30;bc=90;cd=140;\n",
    "l1=250;l2=150;l3=325;\n",
    "\n",
    "abc=210-bc;\n",
    "t1=0.5*abc;\n",
    "bcd=270-cd;\n",
    "t2=0.5*bcd;\n",
    "t3=180-(t1+t2);\n",
    "\n",
    "\n",
    "k=(math.sin(t2*(math.pi/180)))/(math.sin(t3*(math.pi/180)));\n",
    "OB=l2*k;\n",
    "k1=(math.sin(t1*(math.pi/180)))/(math.sin(t3*(math.pi/180)));\n",
    "OC=l2*k1;\n",
    "print(OB,OC);\n",
    "R=OB*(math.sin(t1*(math.pi/180)));\n",
    "print('Radius R=',R);\n",
    "\n",
    "BT1=OB*(math.cos(t1*(math.pi/180)));\n",
    "CT1=OC*(math.cos(t2*(math.pi/180)));\n",
    "\n",
    "print('Tangent length BT1=',BT1);\n",
    "print('Tangent length CT1=',CT1);\n",
    "\n",
    "\n",
    "       \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 383   pb-5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('R1=', 368.61561236693893)\n",
      "('length of arc T1T2=', 209.43951023931953)\n",
      "('length of arc T2T3=', 386.0133666034928)\n",
      "('chainage of T1=', 792.8203230275509)\n",
      "('chainage of T3=', 1388.2731998703632)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "r=400;\n",
    "t1=15;t2=30;t3=60;\n",
    "ct=900;\n",
    "l=320;\n",
    "BT2=r*(math.tan((t1)*math.pi/180));\n",
    "CT2=l-BT2;\n",
    "\n",
    "r1=(CT2)/(math.tan((t2)*math.pi/180));\n",
    "\n",
    "print('R1=',r1);\n",
    "t1t2=(math.pi*r*t2)/(180);\n",
    "\n",
    "t2t3=(math.pi*r1*t3)/(180);\n",
    "\n",
    "print('length of arc T1T2=',t1t2);\n",
    "print('length of arc T2T3=',t2t3);\n",
    "\n",
    "\n",
    "ct1=ct-BT2;\n",
    "ct3=ct1+t1t2+t2t3;\n",
    "\n",
    "print('chainage of T1=',ct1);\n",
    "print('chainage of T3=',ct3);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 384   pb-6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('R2=', 1092.8203230275515)\n",
      "('length of arc T1T2=', 209.43951023931953)\n",
      "('length of arc T2T3=', 572.1993830861634)\n",
      "('chainage of point of reverse curvature =', 1709.4395102393196)\n",
      "('chainage of finishing point T3=', 2281.638893325483)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "r1=400;\n",
    "t1=30;d=200;\n",
    "ct1=1500;\n",
    "k=1-(math.cos(t1*(math.pi/180)))\n",
    "T1G=r1*(k);\n",
    "\n",
    "r2=(d-T1G)/k;\n",
    "print('R2=',r2);\n",
    "\n",
    "t1t2=(math.pi*r1*t1)/180;\n",
    "t2t3=(math.pi*r2*t1)/180;\n",
    "print('length of arc T1T2=',t1t2);\n",
    "print('length of arc T2T3=',t2t3);\n",
    "\n",
    "ct2=ct1+t1t2;\n",
    "ct3=ct2+t2t3;\n",
    "\n",
    "print('chainage of point of reverse curvature =',ct2);\n",
    "print('chainage of finishing point T3=',ct3);\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 385   pb-7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('EF=', 228.7451827250347)\n",
      "('chainage of T1=', 701.0877129159065)\n",
      "('chainage of D=', 1015.2469782748858)\n",
      "('chainage of T2', 1137.4200259144889)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "a1=135;a2=145;\n",
    "t1=180-a1;\n",
    "t2=180-a2;\n",
    "t3=180-(t1+t2);\n",
    "r1=400;r2=200;\n",
    "ct=1000;\n",
    "\n",
    "ED=r1*(math.tan((t1/2)*(math.pi/180)));\n",
    "\n",
    "FD=r2*(math.tan((t2/2)*(math.pi/180)));\n",
    "\n",
    "EF=ED+FD;\n",
    "\n",
    "print('EF=',EF);\n",
    "\n",
    "BE=EF*(math.sin(t2*(math.pi/180)))/(math.sin(t3*(math.pi/180)));\n",
    "\n",
    "BF=EF*(math.sin(t1*(math.pi/180)))/(math.sin(t3*(math.pi/180)))\n",
    "\n",
    "\n",
    "ct1=ct-(BE+ED);\n",
    "\n",
    "cd=ct1+((math.pi*r1*t1)/(180));\n",
    "\n",
    "ct2=cd+((math.pi*r2*t2)/(180));\n",
    "\n",
    "print('chainage of T1=',ct1);\n",
    "print('chainage of D=',cd);\n",
    "print('chainage of T2',ct2);\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 386   pb-8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Radius R=', 272.7765415715475)\n",
      "('angle Theta=', 109.0)\n",
      "('curve length T1D=', 145.2058875651141)\n",
      "('curve length DT2=', 192.814375291381)\n",
      "('chainage of T1=', 1305.430383812096)\n",
      "('chainage of T2=', 1643.4506466685912)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "t1=30.5;\n",
    "t2=40.5;\n",
    "EF=175;\n",
    "cb=1500;\n",
    "\n",
    "k1=math.tan((t1/2)*(math.pi/180));\n",
    "k2=math.tan((t2/2)*(math.pi/180));\n",
    "\n",
    "r=EF/(k1+k2);\n",
    "print('Radius R=',r);\n",
    "\n",
    "et1=r*k1;\n",
    "ft2=r*k2;\n",
    "\n",
    "t3=180-(t1+t2);\n",
    "print('angle Theta=',t3);\n",
    "k3=(math.sin(t2*(math.pi/180)))/(math.sin(t3*(math.pi/180)));\n",
    "k4=(math.sin(t1*(math.pi/180)))/(math.sin(t3*(math.pi/180)));\n",
    "\n",
    "be=EF*k3;\n",
    "bf=EF*k4;\n",
    "\n",
    "t1d=(math.pi*r*t1)/180;\n",
    "dt2=(math.pi*r*t2)/180;\n",
    "\n",
    "print('curve length T1D=',t1d);\n",
    "print('curve length DT2=',dt2);\n",
    "\n",
    "ct1=cb-(be+et1);\n",
    "\n",
    "ct2=ct1+t1d+dt2;\n",
    "print('chainage of T1=',ct1);\n",
    "print('chainage of T2=',ct2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 387   pb-9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('theta 3=', 10.649036741314365)\n",
      "('Radius R=', 829.124128893828)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "t1=80-70;\n",
    "l=50;\n",
    "k=1/(math.cos(20*(math.pi/180)));\n",
    "\n",
    "k1=k*(math.sin(t1*(math.pi/180)));\n",
    "t3=math.asin(k1);\n",
    "t3=t3*(180/(math.pi));\n",
    "print('theta 3=',t3);\n",
    "\n",
    "t3=180-t3;\n",
    "t2=180-(t3+t1);\n",
    "\n",
    "r=l*(math.sin(t1*(math.pi/180)))/(math.sin(0.6*(math.pi/180)));\n",
    "print('Radius R=',r);\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 388   pb-10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('radius of circular curvature=', 402.713280728911)\n",
      "('length of transistion curve =', 90.83333333333334)\n",
      "('spiral angle=', 6.461627773592511)\n",
      "('central angle=', 47.07674445281498)\n",
      "('length of circular curve =', 330.88702808033025)\n",
      "('shift of curve =', 0.8536568115234379)\n",
      "('tangent length =', 278.4161466916694)\n",
      "('chainage of 1st tangent point =', 871.5838533083306)\n",
      "('chainage of 2nd tangent point =', 1384.1375480553274)\n",
      "('chainage of 1st junction point =', 962.417186641664)\n",
      "('chainage of 2nd junction point =', 1293.3042147219942)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "sp=80;\n",
    "v=(sp*1000)/(60*60);\n",
    "cr=(1/8);\n",
    "g=9.81;\n",
    "a=60;\n",
    "\n",
    "#a\n",
    "\n",
    "r=(v*v)/(g*cr);\n",
    "print('radius of circular curvature=',r);\n",
    "\n",
    "#b\n",
    "k=0.3;\n",
    "l=(v*v*v)/(k*r);\n",
    "print('length of transistion curve =',l);\n",
    "\n",
    "sa=l/(2*r);\n",
    "sa=sa*(180/(math.pi));\n",
    "print('spiral angle=',sa);\n",
    "ca=a-(2*sa);\n",
    "print('central angle=',ca);\n",
    "\n",
    "lcc=(math.pi*r*ca)/180;\n",
    "print('length of circular curve =',lcc);\n",
    "\n",
    "s=(l*l)/(24*r);\n",
    "print('shift of curve =',s);\n",
    "ag=a/2;\n",
    "t=(r+s)*(math.tan(ag*(math.pi/180)))+(l/2);\n",
    "print('tangent length =',t);\n",
    "#c\n",
    "cip=1150;\n",
    "c1t=cip-t;\n",
    "c1j=c1t+l;\n",
    "c2j=c1j+lcc;\n",
    "c2t=c2j+l;\n",
    "\n",
    "print('chainage of 1st tangent point =',c1t);\n",
    "print('chainage of 2nd tangent point =',c2t);\n",
    "\n",
    "print('chainage of 1st junction point =',c1j);\n",
    "print('chainage of 2nd junction point =',c2j);\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 389   pb-11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('radius =', 343.8)\n",
      "('tangent length =', 108.39972361659453)\n",
      "('curve length =', 210.01546889247766)\n",
      "('chainage of 1st point =', 1471.6002763834056)\n",
      "('chainage of 2nd point =', 1681.6157452758832)\n",
      "('length of final sub chord =', 8.399723616594429)\n",
      "('chainage covered=', 1660)\n",
      "('length of final sub chord', 21.615745275883228)\n",
      "('deflection angle for initial sub chord =', 43.52844633883164, 'min')\n",
      "('deflection angle for full chord', 2.5910642019719075, 'min')\n",
      "('deflection angle for final sub chord', 1.8669261261094798, 'min')\n",
      "('total deflection angle=', 17.5)\n",
      "('apex distance =', 16.6843132234107)\n",
      "('versed sine of curve =', 15.91211233275958)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "a=145;\n",
    "cpi=1580;\n",
    "de=5;\n",
    "pi=30;\n",
    "lct=0.00555;\n",
    "\n",
    "da=180-a;\n",
    "\n",
    "r=(1719)/5;\n",
    "\n",
    "print('radius =',r);\n",
    "\n",
    "#a\n",
    "\n",
    "tl=r*(math.tan((da/2)*(math.pi/180)));\n",
    "print('tangent length =',tl);\n",
    "\n",
    "#b\n",
    "\n",
    "cl=(math.pi*r*da)/180;\n",
    "print('curve length =',cl);\n",
    "\n",
    "#c\n",
    "\n",
    "c1t=cpi-tl;\n",
    "print('chainage of 1st point =',c1t);\n",
    "\n",
    "#d\n",
    "c2t=c1t+cl;\n",
    "print('chainage of 2nd point =',c2t);\n",
    "\n",
    "#e\n",
    "lisc=1480-c1t;\n",
    "print('length of final sub chord =',lisc);\n",
    "#f\n",
    "n=6;\n",
    "ini=30;\n",
    "cc=1480+(n*30);\n",
    "print('chainage covered=',cc);\n",
    "#g\n",
    "lfsc=c2t-cc;\n",
    "print('length of final sub chord',lfsc);\n",
    "#h\n",
    "dasc=((c2t+100)*lisc)/(r);\n",
    "print('deflection angle for initial sub chord =',dasc,'min');\n",
    "#i\n",
    "dafc=((c2t+100)*pi)/r;\n",
    "print('deflection angle for full chord',dafc/60,'min');\n",
    "#j\n",
    "dafsc=((c2t+100)*lfsc)/r;\n",
    "print('deflection angle for final sub chord',dafsc/60,'min');\n",
    "\n",
    "#k\n",
    "\n",
    "tda=da/2;\n",
    "print('total deflection angle=',tda);\n",
    "\n",
    "\n",
    "#l\n",
    "k=1/(math.cos(tda*(math.pi/180)));\n",
    "ad=r*(k-1);\n",
    "print('apex distance =',ad);\n",
    "\n",
    "vs=r*(1-(math.cos(tda*(math.pi/180))));\n",
    "print('versed sine of curve =',vs);\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 391   pb-1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('length of vertical curve =', 240.0)\n",
      "('chainage of A', 430.0)\n",
      "('chainage of C', 670.0)\n",
      "('Rl of A', 374.9)\n",
      "('Rl of C', 374.66)\n",
      "('Rl of E', 374.78)\n",
      "('Rl of F', 375.14)\n",
      "('tangent correction at the apex =', 0.36000000000001364)\n",
      "('tangent correction at 1st,2nd,3rd,4th,5th,6th, points', 0.01, 0.04, 0.09, 0.16, 0.25, 0.36)\n",
      "RL of the points on grade\n",
      "(375.0, 375.1, 375.20000000000005, 375.30000000000007, 375.4000000000001, 375.5000000000001)\n",
      "RL of the points on curve\n",
      "(374.99, 375.06, 375.11000000000007, 375.14000000000004, 375.1500000000001, 375.1400000000001)\n",
      "Rls of points on the grade right side\n",
      "(375.36, 375.22, 375.08000000000004, 374.94000000000005, 374.80000000000007)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "pi=20;\n",
    "cb=550;\n",
    "rlb=375.5;\n",
    "g1=0.5;\n",
    "g2=-0.7;\n",
    "#a\n",
    "vc=((g1-g2)*20)/0.1;\n",
    "\n",
    "print('length of vertical curve =',vc);\n",
    "\n",
    "#b,c\n",
    "\n",
    "ca=cb-(vc/2);\n",
    "cc=ca+vc;\n",
    "print('chainage of A',ca);\n",
    "print('chainage of C',cc);\n",
    "\n",
    "#d,e,f,g\n",
    "\n",
    "rla=rlb-((g1*0.5*vc)/100);\n",
    "rlc=rlb-((-g2*0.5*vc)/100);\n",
    "rle=0.5*(rla+rlc);\n",
    "rlf=0.5*(rlb+rle);\n",
    "\n",
    "print('Rl of A',rla);\n",
    "print('Rl of C',rlc);\n",
    "print('Rl of E',rle);\n",
    "print('Rl of F',rlf);\n",
    "#h\n",
    "tc=rlb-rlf;\n",
    "print('tangent correction at the apex =',tc);\n",
    "\n",
    "#i\n",
    "tc1=((g1-g2)*(pi*pi))/(400*0.5*vc);\n",
    "tc2=((g1-g2)*(2*pi*2*pi))/(400*0.5*vc);\n",
    "tc3=((g1-g2)*(3*pi*3*pi))/(400*0.5*vc);\n",
    "tc4=((g1-g2)*(4*pi*4*pi))/(400*0.5*vc);\n",
    "tc5=((g1-g2)*(5*pi*5*pi))/(400*0.5*vc);\n",
    "tc6=((g1-g2)*(6*pi*6*pi))/(400*0.5*vc);\n",
    "print('tangent correction at 1st,2nd,3rd,4th,5th,6th, points',tc1,tc2,tc3,tc4,tc5,tc6);\n",
    "\n",
    "#j\n",
    "rp=(g1*pi)/100;\n",
    "\n",
    "rl1=rla+rp;\n",
    "rl2=rl1+rp;\n",
    "rl3=rl2+rp;\n",
    "rl4=rl3+rp;\n",
    "rl5=rl4+rp;\n",
    "rl6=rl5+rp;\n",
    "print('RL of the points on grade');\n",
    "print(rl1,rl2,rl3,rl4,rl5,rl6)\n",
    "\n",
    "#k\n",
    "rlc1=rl1-tc1;\n",
    "rlc2=rl2-(tc2);\n",
    "rlc3=rl3-(tc3);\n",
    "rlc4=rl4-(tc4);\n",
    "rlc5=rl5-(tc5);\n",
    "rlc6=rl6-(tc6);\n",
    "\n",
    "print('RL of the points on curve');\n",
    "print(rlc1,rlc2,rlc3,rlc4,rlc5,rlc6);\n",
    "\n",
    "#l\n",
    "\n",
    "fp=0.14;\n",
    "\n",
    "rlg5=rlb-fp;\n",
    "rlg4=rlg5-fp;\n",
    "rlg3=rlg4-fp;\n",
    "rlg2=rlg3-fp;\n",
    "rlg1=rlg2-fp;\n",
    "\n",
    "print('Rls of points on the grade right side');\n",
    "print(rlg5,rlg4,rlg3,rlg2,rlg1);\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### ch-10 page 393   pb-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('length of vertical curve', 300.0)\n",
      "('RL of A=', 252.0)\n",
      "('RL of C=', 251.25)\n",
      "('RL of E=', 251.625)\n",
      "('RL of F=', 251.0625)\n",
      "RL on the grade on the side AB \n",
      "(251.7, 251.39999999999998, 251.09999999999997, 250.79999999999995)\n",
      "RL on grade on side BC\n",
      "(250.65, 250.8, 250.95000000000002, 251.10000000000002)\n",
      "tangent correction from expression \n",
      "(-0.0225, -0.09, -0.2025, -0.36)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from __future__ import division\n",
    "\n",
    "import math\n",
    "\n",
    "cb=400;\n",
    "rlb=250.5;\n",
    "pi=30;\n",
    "g1=-1.0;\n",
    "g2=0.5;\n",
    "g=0.1;\n",
    "ga=20;\n",
    "#a\n",
    "vc=(g1-g2)/g;\n",
    "vc=-vc*ga;\n",
    "print('length of vertical curve',vc);\n",
    "\n",
    "#b,c\n",
    "ca=cb-(0.5*vc);\n",
    "cc=ca+vc;\n",
    "\n",
    "#d,e,f,g\n",
    "\n",
    "rla=rlb+((0.5*vc)/100);\n",
    "\n",
    "rlc=rlb+((0.5*0.5*vc)/100);\n",
    "\n",
    "rle=0.5*(rla+rlc);\n",
    "\n",
    "rlf=0.5*(rle+rlb);\n",
    "\n",
    "print('RL of A=',rla);\n",
    "print('RL of C=',rlc);\n",
    "print('RL of E=',rle);\n",
    "print('RL of F=',rlf);\n",
    "\n",
    "#h\n",
    "fp=pi/100;\n",
    "\n",
    "rl1=rla-fp;\n",
    "rl2=rl1-fp;\n",
    "rl3=rl2-fp;\n",
    "rl4=rl3-fp;\n",
    "print('RL on the grade on the side AB ');\n",
    "print(rl1,rl2,rl3,rl4);\n",
    "\n",
    "#i\n",
    "\n",
    "rp=(0.5*pi)/100;\n",
    "\n",
    "rls4=rlb+rp\n",
    "rls3=rls4+rp\n",
    "rls2=rls3+rp\n",
    "rls1=rls2+rp\n",
    "\n",
    "print('RL on grade on side BC');\n",
    "print(rls4,rls3,rls2,rls1);\n",
    "\n",
    "#j\n",
    "\n",
    "y1=((g1-g2)*(pi*pi))/(cb*0.5*vc);\n",
    "y2=((g1-g2)*(2*pi*2*pi))/(cb*0.5*vc);\n",
    "y3=((g1-g2)*(3*pi*3*pi))/(cb*0.5*vc);\n",
    "y4=((g1-g2)*(4*pi*4*pi))/(cb*0.5*vc);\n",
    "\n",
    "print('tangent correction from expression ');\n",
    "print(y1,y2,y3,y4);\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}