' - - File: VI_Gen1.txt
'      Took about 30 seconds on my notebook.
' Given two curves that intersect at a point (t1 = 1 in this example). Construct their tangent
'      and their normal lines. Then find the angle of intersection between both the normals
'      and the tangent lines in degrees. Sum both these angles.

pi = 3.14159  :  t1 = 1      ' Point of interection for the two curves.
Rx{t} = t  :  Ry{t} = t^0.5  :  Rz{t} = 0  :  R<t> = <Rx,Ry,Rz>           ' First curve. 
Bx{t} = t  :  By{t} = t^3      :  Bz{t} = 0  :  B<t> = <Bx,By,Bz>            ' Second curve.

' = = = = = = = = = Details to Find the Tangent  Lines in Previous Worksheet = = = = = = = = =
Rn<t> = vEval[R,t1]  :  Dr<t> = vDiff[R] 
Bn<t> = vEval[B,t1]   :  Db<t> = vDiff[B] 
  
Tr<t> = vDiv[Dr,sMag[Dr]]    :  Tn<t> = vEval[Tr,t1]   :  Lr<t> = vAdd[vMpy[Tn,#],Rn]
Tb<t> = vDiv[Db,sMag[Db]] : Tm<t> = vEval[Tb,t1]  :  Lb<t>= vAdd[vMpy[Tm,#],Rn]
' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

' - - - - - - - - - - - - - - - -  - - - For vector R, find its Normal LIne - - - - - - - - - - - - - - - - - - - - - - - - -
Nr<t> = vNorm[R]
Nn<t> = vEval[Nr,t1]
Pr<t> = vAdd[vMpy[Nn,#],Rn]

' - - - - - - - - - - - - - - - - - Repeat for vector B to find its Normal Line - - - - - - - - - - - - - - - - - - - -
Nb<t> = vNorm[B]
Nm<t> = vEval[Nb,t1]
Pb<t> = vAdd[vMpy[Nm,#],Bn]

' - - - - - - -  - - - - - - - Find the angle between intersecting Normal lines - - - - - - - - - - - - - - - - -
Fn{t} = sDiv[sDot[Nr,Nb],sMpy[sMag[Nr],sMag[Nb] ] ]      ' (Nr.Nb) / (|Nr|*|Nb|)
An{t} = ACos[Fn{t}] * 180 / pi

' - - - - - - - - - - - - - - Find the angle between intersecting Tangent lines - - - - - - - - - - - - - - - -
Ft{t} = sDiv[sDot[Tr,Tb],sMpy[sMag[Tr],sMag[Tb] ] ]         ' (Tr.Tb) / (|Tr|*|Tb|)
At{t} = ACos[Ft{t}] * 180 / pi
S{t} = An{t} + At{t}
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
an = An{t1}  :  at = At{t1} :  s3 = an + at    ' Set up as constants for display on graph.
' - - - - - - - - - - - - - - - - - - - - - - - - - Plot all Functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
t0 = 0  :  tf = 1.5  :  n = 50
Plot[R, B, Lr, Lb, Pr, Pb, {t, t0, tf, n }]
<t = t1>        ' Set  parameter value to t1 so functions do not display a zero in output.

'@Intersecting Normals = @an degrees!
'@Intersecting Tangents = @at. degrees!
'@Sum of angles = @s3, degrees!

' Review Page 9 of document for above display method.!
' CAUTION: If the axes are scaled differently, the displayed Normals & Tangents will not !
'     appear at 90 degrees. !


