<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout alignment="left" bullet="none" name="Normal"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" size="12"/><Font background="[0,0,0]" bold="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Text" opaque="false" size="12" underline="false"/></Styles><Group><Input><Text-field alignment="centred" layout="Normal" style="Text"><Font bold="true" size="18">Ray and Object Intersections: Truncated Cone</Font></Text-field><Text-field alignment="centred" layout="Normal" style="Text">
by Otto Wilke
otto_wilke@hotmail.com</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">I am vaguely aware that graphics is normally done with vector operations, generic</Text-field><Text-field layout="Normal" style="Text">solids positioned at the origin, and transformation matrices to move rays to and fro.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">I thought it would be interesting to use rectangular coordinates and objects located</Text-field><Text-field layout="Normal" style="Text">anywhere in space and oriented in any direction.</Text-field><Text-field layout="Normal" style="Text"/><Text-field layout="Normal" style="Text">This is one of four files covering the plane, the sphere, the cylinder, and the cone. </Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Let C be a truncated right circular cone.  Let the larger circular end be centered at </Text-field><Text-field layout="Normal" style="Text">P1(x1,y1,z1) and have radius R.  Let the smaller circular end be centered at </Text-field><Text-field layout="Normal" style="Text">P2(x2,y2,z2) and have radius r.  Let P(x,y,z) be some point on the surface of the cone.</Text-field><Text-field layout="Normal" style="Text">Let P3(x3,y3,z3) be a point on line segment P1 P2 such that line segment P P3 is </Text-field><Text-field layout="Normal" style="Text">perpendicular to P1 P2.  Let d1 be distance P1 P2.  Let d2 be distance P P1.</Text-field><Text-field layout="Normal" style="Text">Let d3 be distance P P2.  Let d4 be distance P P3.  Let d5 be distance P1 P3.</Text-field><Text-field layout="Normal" style="Text">Let d6 be distance P2 P3.  By the distance formula.</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">restart;with(plots):
draw1:=plot([[0,0],[1,4],[3,4],[4,0],[0,0],[2,0],[2,4],[3.5,2],
[2,0],[2,2],[3.5,2]],axes=none):
text1:=textplot([[2,-.3,"P1"],[2,4.3,"P2"],[3.6,2,"P"],
[2.6,3.8,"r"],[3,.2,"R"],[1.8,2,"P3"]]):
display({draw1,text1});
d1=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
d2=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
d3=sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text"/></Input></Group><Group><Input><Text-field layout="Normal" style="Text">I think I remember that</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">d4=r+(d6/d1)*(R-r);solve(d4=r+(d6/d1)*(R-r),d6);%^2;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">By the Pythagorean Theorem</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">d4=sqrt(d3^2-d6^2);d4=sqrt(d3^2-((-d4+r)^2*d1^2/(-R+r)^2));</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Solving for d4</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">{solve(d4 = (d3^2-(-d4+r)^2*d1^2/(-R+r)^2)^(1/2),d4)};</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Knowing d4 must be positive, d4 is</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">op(1,%);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">The area of triangle P P1 P2 is half of the product of base and height</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">aArea=1/2*d1*d4;areaSquared=(rhs(%))^2;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">By Heron's formula, the area squared is also</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">areaSquared=(d1+d2+d3)/2*((d1+d2+d3)/2-d1)*((d1+d2+d3)/2-d2)
*((d1+d2+d3)/2-d3);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Setting the squares of the area equal to each other</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">(1/2*d1*d4)^2=(d1+d2+d3)/2*((d1+d2+d3)/2-d1)*((d1+d2+d3)/2-d2)
*((d1+d2+d3)/2-d3);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Inserting the desired value of d4</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">(1/2*d1*(1/2*(2*r*d1^2-2*(d1^2*d3^2*r^2+d1^2*d3^2*R^2-2*d1^2*
d3^2*R*r+6*R^2*d3^2*r^2-R^2*d1^2*r^2+R^4*d3^2-4*R^3*d3^2*r
-4*R*r^3*d3^2+2*R*r^3*d1^2+r^4*d3^2-r^4*d1^2)^(1/2))/
(d1^2+R^2-2*R*r+r^2)))^2=(d1+d2+d3)/2*((d1+d2+d3)/2-d1)*
((d1+d2+d3)/2-d2)*((d1+d2+d3)/2-d3);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">4*%;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Substituting for d1, d2, and d3</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">subs(d1=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2),
d2=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2),
d3=sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2),%);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">The equation immediately above give the coordinates of points on the truncated cone.</Text-field><Text-field layout="Normal" style="Text">Let's graph a specific cone.</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">x1:=4;y1:=2;z1:=-2;R:=2;x2:=0;y2:=6;z2:=2;r:=1;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">d1:=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
d2:=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
d3:=sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">with(plots):</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">plot1:=implicitplot3d(1/4*d1^2*(2*r*d1^2-2*(d1^2*d3^2*r^2+d1^2
*d3^2*R^2-2*d1^2*d3^2*R*r+6*R^2*d3^2*r^2-R^2*d1^2*r^2+R^4*
d3^2-4*R^3*d3^2*r-4*R*r^3*d3^2+2*R*r^3*d1^2+r^4*d3^2-r^4*d1^2)
^(1/2))^2/(d1^2+R^2-2*R*r+r^2)^2 = 2*(d1+d2+d3)*(-1/2*d1+1/2*d2+1/2*d3)*(1/2*d1-1/2*d2+1/2*d3)
*(1/2*d1+1/2*d2-1/2*d3), x=-5..10, y=-5..10, z=-5..10, axes=normal,grid=[40,40,40]):
plot2:=pointplot3d({[x1,y1,z1],[x2,y2,z2] },color=red,
symbol=box,symbolsize=20):
display({plot1,plot2});</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">What we see is a series of cones on the same axis, with some plotted points beyond</Text-field><Text-field layout="Normal" style="Text">the ends of the original truncated cone.  To find the intersection of a ray and the truncated</Text-field><Text-field layout="Normal" style="Text">cone, we need to find only points on the truncated cone.  This is ensured by the following</Text-field><Text-field layout="Normal" style="Text">inequalities.</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">d2&lt;=sqrt(r^2+d1^2);d3&lt;=sqrt(R^2+d1^2);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Let L be a line on point P4(x4,y4,z4) and let L have direction numbers a, b, and c.  The parametric equations for L are</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">x=x4+a*t;y=y4+b*t;z=z4+c*t;</Text-field></Input></Group><Text-field/><Group><Input><Text-field layout="Normal" style="Text">Let's pick P4 as (0,0,0) and a=.5, b=2, c=.5.</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">x4:=0;y4:=0;z4:=0;a:=.5;b:=2;c:=.5;</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">Now that we have equations for points on a line and a cone and two inequalities, we'll ask Maple to solve the simlutaneous equations and inequalities.  </Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input">solve({x=x4+a*t,y=y4+b*t,z=z4+c*t,</Text-field></Input><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">d2&lt;=sqrt(r^2+d1^2),d3&lt;=sqrt(R^2+d1^2),
1/4*d1^2*(2*r*d1^2-2*(d1^2*d3^2*r^2+d1^2*d3^2*R^2-2*d1^2*
d3^2*R*r+6*R^2*d3^2*r^2-R^2*d1^2*r^2+R^4*d3^2-4*R^3*d3^2
*r-4*R*r^3*d3^2+2*R*r^3*d1^2+r^4*d3^2-r^4*d1^2)^(1/2))^2/
(d1^2+R^2-2*R*r+r^2)^2 = 2*(d1+d2+d3)*(-1/2*d1+1/2*d2+1/2*d3)*(1/2*d1-1/2*d2+1/2*d3)
*(1/2*d1+1/2*d2-1/2*d3)},{x,y,z,t});</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">plot3:=arrow(&lt;0,0,0&gt;, &lt;2.5,10,2.5&gt;, 
width=[0.02, relative], head_length=[0.2, relative], color=red):
plot4:=pointplot3d({[1.417815960,5.671263838,1.417815960],
[1.042361032,4.169444126,1.042361032] },
color=blue,symbol=box,symbolsize=20):
display({plot1,plot2,plot3,plot4});</Text-field></Input></Group><Group><Input><Text-field layout="Normal" style="Text">The ray pierces the cone, entering and exiting.  To determine when a ray hits one or both</Text-field><Text-field layout="Normal" style="Text">circular ends, use the same procedure as was used for the cylinder.</Text-field><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Text-field/><Text-field/><Text-field/><Text-field/></Worksheet>