pulley belt length, circle tangents, and conic sections · pulley belt length, circle tangents, and...
TRANSCRIPT
Pulley Belt Length, Circle Tangents, and
Conic Sections
James D Emery
Latest Edit or Addition: 12/28/2012
Contents
1 The Length of a Pulley Belt 2
2 Tangents to Two Circles 2
2.1 The MatLab Version of This Tangent Calculation . . . . . . . 42.2 The MathCad Version of This Tangent Calculation . . . . . . 5
3 The Crossed Tangents 5
3.1 The Matlab Version of This Crossed Tangent Calculation . . . 7
4 The Ice Cream Cone Proof That an Ellipse is a Conic Section 8
5 Determining the Conic Section Ellipse From Circle Tangents 8
6 The Program to Draw the Ice Cream Cone Figure: drawcon-
icsection.ftn 10
7 Creating an Elliptical Cross Section Model Using a Conical
Wine Glass 27
8 Proof that the Ellipse is Algebraically a Conic Section Using
Projective Geometry. 30
9 Appendix A: Derivation of the Equation of the Ellipse From
the Focal Property 31
1
10 References and Bibliography 33
1 The Length of a Pulley Belt
To calculate the length of a pulley belt that wraps around two pulleys weneed to compute the length of pulley common tangents, both the outsidetangents and the tangents that pass between the pulleys in the case of acrossed belt. We also need the angles of contact of the pulleys with the belt.These calculations follow from computing the circle tangents below.
2 Tangents to Two Circles
We shall calculate tangents between two circles C1 and C2, and their lengthsas well as circle contact angles. Refer to Figure 1. A similar figure is givenin the file pulleyf.pdf, which occurs in the MathCad program pulley.mcd,and which was created in the program DesignCad as pulley.dcd).
Let a be the distance between circle centers. Let d1 be the diameter ofcircle C1 and d2 the diameter of circle C2. The corresponding radii are
r1 = d1/2
r2 = d2/2.
We shall assume that r2 ≥ r1 and the center of circle C2 is at the origin,and the center of the circle C1 is on the positive x axis with coordinates(a, 0). If this is not the case transform the center of the larger circle witha translation T , and then with a rotation R to transform the center of thesmaller circle to the positive x axis. So apply the transformation RT . Aftersolving the problem in standard position, transform the solution tangentpoints back to the original position with the transformation T−1R−1.
Letc = r2 − r1
be the difference of the circle radii. Let
b =√
a2 − c2.
Letθ = arctan(c/b).
2
a
bc
rr
2
1α α
θ
Figure 1: Tangent to two circles. The distance between the circle centers isa, c is the difference between the radii, and b is the length of the tangentline segment. The angle θ is given as tan−1(c/b), and α = π/2 − θ. And αdetermines the two tangent points.
3
Then the top tangent point on the larger circle is
x = r2 cos(π/2 − θ),
y = r2 sin(π/2 − θ),
and the top tangent point on the smaller circle is
x = a + r1 cos(π/2 − θ),
y = r1 sin(π/2 − θ).
From the figure we see that the length of the tangent segment is b.For circles not in standard position, map them to standard position with
a translation and a rotation. Then map the end points of the tangents backwith the inverse transformation.
We see that the length of a cord wrapped around both circles is
L = 2b + (π − 2θ)r1 + (π + 2θ)r2.
2.1 The MatLab Version of This Tangent Calculation
The file name is tancirc.m. To edit the program issue the command ”starttancirc.m”. This opens up the matLab editor. To run this m-script in Mat-Lab, change to the directory containing the file if necessary, then type thescript name without the ”m” extension, that is just type tancirc, which loadsin the script and executes the commands in the script.
%tancirc.m tangent to two circles
r2=2.
r1=1.
a=5.
c = r2 - r1
b= sqrt(a^2 - c^2)
theta = atan(c/b)
alpha=pi/2-theta
x2=r2*cos(alpha)
y2=r2*sin(alpha)
x1=a+r1*cos(alpha)
y1=r1*sin(alpha)
4
2.2 The MathCad Version of This Tangent Calculation
The mathcad version of this top tangent calculation is called pulley.mcd
and repeats the numerical calculation as the parameters are changed inter-actively.
3 The Crossed Tangents
Given two circles C1 and C2 with radius r1 and r2. Referring to figure 2,point A is the center of circle C2. B is the crossing point of the crossedtangent with the line connecting the circle centers. C is the center of circleC1. D is the tangent point on circle C2 and E is the tangent point on circleC1. Define
a = AC,
c1 = BC,
c2 = AB,
b1 = BE,
b2 = DB.
Thena = c1 + c2
Triangle ADB is similar to CEB. So
c2
r2
=c1
r1
Consequently
c1 =a
1 + r2/r1
,
andc2 = a − c1.
We haveb1 =
√
c21 − r2
1,
b2 =√
c22 − r2
2.
5
A B
C
D
E
r
r
2
1
αα
Figure 2: Crossed tangents to two circles. Side lengths are a = AC, c1 =BC, c2 = AB, b1 = BE, b2 = DB.
6
Let angle α = DAB, which also equals ECB.
α = arccos(r1/c1)
Assume circle C2 is the not smaller than C1, and both are centered on the xaxis, with C2 left of C1. Let β = π + α, then the tangent points are
x1 = a + r1 cos(β),
y1 = r1 sin(β),
x2 = r2 cos(α),
y2 = r2 sin(α).
For circles not in standard position, map them to standard position witha translation and a rotation. Then map the end points of the tangents backwith the inverse transformation.
We see that the length of a belt wrapped around the two pulleys in afigure eight manner is
(2(b1 + b2) + (r1 + r2)(2π − 2α)
.
3.1 The Matlab Version of This Crossed Tangent Cal-
culation
%crosstancirc.m
%cross tangents to two circles
r2=2.
r1=1.
a=5.
c1=a/(1+r2/r1)
c2=a-c1
b1=sqrt(c1^2-r1^2)
b2=sqrt(c2^2 - r2^2)
alpha=acos(r1/c1)
x2=r2*cos(alpha)
y2=r2*sin(alpha)
beta=pi+alpha
x1=a+r1*cos(beta)
y1=r1*sin(beta)
7
4 The Ice Cream Cone Proof That an Ellipse
is a Conic Section
Two spheres of different radii with centers separated by distance a define anenclosing cone with the cone angle defined by the tangents to cross sectionalcircles. A cross tangent to such circles defines a sectioning plane that istangent to each sphere. The intersection of this plane with the cone is anellipse. The tangent points of the plane with the two spheres are the fociof the ellipse. A good drawing of these spheres, cone, and plane make theproof evident, however making a clear three dimensional drawing is difficult.I will make a really nice computer generated one eventually. This proof thata planar section of a cone using two tangent spheres to the sectioning planeis called ”The Ice Cream Cone Proof.” It was discovered in relatively moderntimes by G. P. Dandelin (1794-1847). I say recently modern times becausethe mathematics of the conic sections was treated by the ancient Greeks,by Appolonius in the 3rd century BC, and by others even earlier. See forexample Tom M. Apostol Calculus Volume 1, 2nd Edition, p498.
5 Determining the Conic Section Ellipse From
Circle Tangents
Consider the two spheres used in the ice cream cone proof. A cross sectionplane through the cone through the center of the ellipse, through the twofocii, gives two circles and circle tangents. The cross tangent points are thefocii of the ellipse. So we calculate these. The distance between these equals2c, where
c2 + b2 = a2
where a and b are the ellipse semi-diameters, and where the equation of theellipse is
x2
a2+
y2
b2= 1.
Recall that the defining property of the ellipse is that the sum of the twodistances from each focus point to the point on the ellipse is equal to 2a.
The outside tangent points to the two circles define a line on the cone. Itsintersection with the cross tangent gives the two points of the intersection ofthe center line of the ellipse and the conical surface. Therefore the distance
8
P
F1
F2
P
F1
F2
S
T
Normal View of Section
Front View of Cone
Figure 3: Proof that a conic section is an ellipse. The normal view ofthe section plane shows the ellipse. Point P is on the cone and the plane.Points T and S are tangent points to the spheres. Points F1 and F2 arecontact points with the spheres and the section plane. Line segments PF1and PS have equal length because they are both tangent to the big sphere.Similarly the lengths PF2 and PT are equal. PF1 + PF2 = PS + PT , andthe latter is the distance between the contact circles on the cone, so constantfor every P , which is the constant sum of distances from a point on the ellipseto the foci. Thus the section curve is an ellipse with foci F1 and F2.
9
between these two intersection points is 2a. So this finishes the calculation ofthe elliptic parameters to define the elliptic cross section. Now the equationof the conic line can be found by taking a cross product of the tangentpoints using projective or homogenous coordinates. The equation of the linethrough the center of the ellipse can be found by taking a cross product ofthe cross-tangent points using projective or homogeneous coordinates again.Finally the intersection point of these two lines giving the points defining acan be found by taking the cross product of the homogenous coordinates ofthe two lines. From this we have the complete geometric model of the coneand ellipse cross section which can be displayed with computer graphics.
6 The Program to Draw the Ice Cream Cone
Figure: drawconicsection.ftn
This program constructs a drawing for the Ice Cream Cone proof using var-ious calculations from projective geometry as presented in the previous sec-tion. The program produces a graphics file with a file extension ”eg”. Thisis converted to postscript with the program eg2ps.c.
Here is a program output:
C:\je\ftn>fl32 drawconicsection.ftn
Microsoft (R) Fortran PowerStation Version 4.00
Copyright (C) Microsoft Corp 1982-1995. All rights reserved.
drawconicsection.ftn
Microsoft (R) 32-Bit Incremental Linker Version 3.00.5270
Copyright (C) Microsoft Corp 1992-1995. All rights reserved.
C:\je\ftn>drawconicsection
Enter a circle center [0. 0.]
Enter its radius [2.0]
center= .00000000 .00000000
radius= 2.000000000000000
Enter another circle center [0. 4.5]
Enter its radius [1.0]
center= .00000000 4.5000000
radius= 1.000000000000000
iflag = 0
tangent segment 1
pt1= -1.949992086087138 4.444444444444446E-001
pt2= -9.749960430435691E-001 4.722222222222222
tangent segment 2
pt1= 1.949992086087138 4.444444444444446E-001
10
pt2= 9.749960430435691E-001 4.722222222222222
Outside tangent angle with axis 12.839588406904180
Cross tangent angle with axis 41.810314895778600
Cone vertex angle 25.679176813808350
Conic section angle 41.810314895778600
cross tangent segment 1
pt1= -1.490711984999860 1.333333333333333
pt2= 7.453559924999299E-001 3.833333333333334
cross tangent segment 2
pt1= 1.490711984999860 1.333333333333333
pt2= -7.453559924999299E-001 3.833333333333334
a4= -2.5000000 2.2360680 -6.7082039
Ellipse parameters
c= 1.6770510
a= 2.1937411
b= 1.4142136
eccentricity c/a= .76447079
a4= -2.5000000 2.2360680 -6.7082039
Graphic output file: p.eg
Do this to convert file to postscript:
pltmerge p.eg q.eg (computes a window)
eg2ps q.eg p.ps
C:\je\ftn>pltmerge p.eg q.eg
C:\je\ftn>eg2ps q.eg p.ps
Here is the program listing:
c Program name: drawconicsection.ftn
c Draw elliptical conicsection
c 10/14/12
c Reference "pulley.tex, pulley.pdf"
implicit real*8(a-h,o-z)
dimension c1(2),c2(2)
dimension x(8),y(8)
dimension p1(3),p2(3),p3(3),p4(3),p5(3),p6(3),p7(3),p8(3)
11
dimension p9(3),p10(3),p11(3),p12(3),p13(3),p14(3),p15(3)
dimension a1(3),a2(3),a3(3),a4(3)
dimension a5(3),a6(3),a7(3),a8(3)
dimension u(2),v(2),center(2),cv(2),e(2),f1(2),f2(2)
dimension ain(10)
dimension ta(2)
c a5 and a6 not used currently
a5(1)=1.
a6(1)=1.
nfile1=1
eps=1.e-3
open(nfile1,file=’p.eg’,status=’unknown’)
one=1.
pi=4.*atan(one)
c2(1)=0.
c2(2)=0.
c1(1)=0.
c1(2)=4.5
write(*,*)’ Enter a circle center [0. 0.] ’
call readr(0,ain,nr)
if(nr .lt. 2)then
c2(1)=0.
c2(2)=0.
else
c2(1)=ain(1)
c2(2)=ain(2)
endif
write(*,*)’ Enter its radius [2.0] ’
call readr(0,ain,nr)
if(nr .lt. 1)then
r2=2.
else
r2=ain(1)
endif
write(*,’(1x,a,2(1x,g15.8))’)’ center= ’,c2(1),c2(2)
write(*,*)’ radius= ’,r2
write(*,*)’ Enter another circle center [0. 4.5] ’
call readr(0,ain,nr)
if(nr .lt. 2)then
c1(1)=0.
c1(2)=4.5
else
c1(1)=ain(1)
c1(2)=ain(2)
endif
write(*,*)’ Enter its radius [1.0] ’
call readr(0,ain,nr)
if(nr .lt. 1)then
r1=1.
else
r1=ain(1)
endif
write(*,’(1x,a,2(1x,g15.8))’)’ center= ’,c1(1),c1(2)
12
write(*,*)’ radius= ’,r1
c r1=1.d0
c r2=2.d0
t1=0.
t2=2.*pi
npts=100
call xdarc(nfile1,c1(1),c1(2),r1,t1,t2,npts)
call xdarc(nfile1,c2(1),c2(2),r2,t1,t2,npts)
call tancircs(c1,r1,c2,r2,x,y,ta,iflag)
write(*,*)’ iflag = ’,iflag
c if(1+1 .eq. 2)stop
if(iflag .eq. 2)then
write(*,*)’ Circles are nested, no tangents’
stop
endif
write(*,*)
write(*,*)’ tangent segment 1’
write(*,*)’ pt1=’,x(1),y(1)
write(*,*)’ pt2=’,x(2),y(2)
call xmove(nfile1, x(1),y(1))
call xdraw(nfile1, x(2),y(2))
write(*,*)
write(*,*)’ tangent segment 2’
write(*,*)’ pt1=’,x(3),y(3)
write(*,*)’ pt2=’,x(4),y(4)
call xmove(nfile1, x(3),y(3))
call xdraw(nfile1, x(4),y(4))
write(*,*)
write(*,*)’ Outside tangent angle with axis ’, ta(1)*180./pi
if( iflag .eq. 1)then
write(*,*)’ Circles intersect, no cross tangents, no drawing.’
stop
endif
write(*,*)’ Cross tangent angle with axis’,ta(2)*180./pi
write(*,*)’ Cone vertex angle ’, 2.*ta(1)*180./pi
write(*,*)’ Conic section angle ’,ta(2)*180./pi
write(*,*)’ cross tangent segment 1’
write(*,*)’ pt1=’,x(5),y(5)
write(*,*)’ pt2=’,x(6),y(6)
call xmove(nfile1, x(5),y(5))
call xdraw(nfile1, x(6),y(6))
write(*,*)
write(*,*)’ cross tangent segment 2’
write(*,*)’ pt1=’,x(7),y(7)
write(*,*)’ pt2=’,x(8),y(8)
c call xmove(nfile1, x(7),y(7))
13
c call xdraw(nfile1, x(8),y(8))
c tangent segment 1
p1(1) = x(1)
p1(2) = y(1)
p1(3) = 1.
p2(1) = x(2)
p2(2) = y(2)
p2(3) = 1.
c compute tangent line 1
call crsspr(p1,p2,a1)
c tangent segment 2
p3(1) = x(3)
p3(2) = y(3)
p3(3) = 1.
p4(1) = x(4)
p4(2) = y(4)
p4(3) = 1.
c draw lines representing sphere and cone contact circles
call xmove(nfile1,p1(1),p1(2))
call xdraw(nfile1,p3(1),p3(2))
call xmove(nfile1,p2(1),p2(2))
call xdraw(nfile1,p4(1),p4(2))
c compute tangent line 2
call crsspr(p3,p4,a2)
c compute vertex point
call crsspr(a1,a2,p5)
c define base line of cone
a3(1)=0
a3(2)=1.
a3(3)=3.
c compute base point 1
call crsspr(a1,a3,p6)
if(abs(p5(3)) .lt. eps*r1)then
write(*,*)’ cone vertex point close to infinity’
stop
else
x1=p5(1)/p5(3)
y1=p5(2)/p5(3)
end if
x2=p6(1)/p6(3)
y2=p6(2)/p6(3)
c draw side one of cone
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
c compute base point 2
call crsspr(a2,a3,p7)
14
x1=p5(1)/p5(3)
y1=p5(2)/p5(3)
x2=p7(1)/p7(3)
y2=p7(2)/p7(3)
c draw side two of cone
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
c draw base of cone
x1=p6(1)/p6(3)
y1=p6(2)/p6(3)
x2=p7(1)/p7(3)
y2=p7(2)/p7(3)
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
c cross tangent points
p8(1)=x(5)
p8(2)=y(5)
p8(3)=1.
p9(1)=x(6)
p9(2)=y(6)
p9(3)=1.
c draw small circles at foci
npts=20
r=.05
call xdarc(nfile1,p8(1),p8(2),r,t1,t2,npts)
call xdarc(nfile1,p9(1),p9(2),r,t1,t2,npts)
c compute ellipse parameter c
c = sqrt((p9(1) - p8(1))**2 + (p9(2) - p8(2))**2)/2.
c compute section line on section plane
call crsspr(p8,p9,a4)
write(*,’(1x,a,3(1x,g15.8))’)’ a4= ’,a4
c compute intersection points of line a4 and cone
call crsspr(a4,a1,p10)
call crsspr(a4,a2,p11)
c draw section line
x1=p10(1)/p10(3)
y1=p10(2)/p10(3)
x2=p11(1)/p11(3)
y2=p11(2)/p11(3)
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
c create unit vectors for oblique view
u(1)=x2-x1
u(2)=y2-y1
center(1)= (x1+x2)/2.
center(2)= (y1+y2)/2.
a=sqrt(u(1)**2 + u(2)**2)
do i=1,2
u(i)=u(i)/a
15
end do
v(1)=-u(2)
v(2)=u(1)
c compute ellipse parameters a and b
a=a/2.
b=sqrt(a**2 -c**2)
write(*,*)
write(*,*)’ Ellipse parameters ’
write(*,’(1x,a,g15.8)’)’ c=’,c
write(*,’(1x,a,g15.8)’)’ a=’,a
write(*,’(1x,a,g15.8)’)’ b=’,b
write(*,’(1x,a,g15.8)’)’ eccentricity c/a=’,c/a
c compute center of oblique view
cv(1)=center(1)+6.*r1*v(1)
cv(2)=center(2)+6.*r1*v(2)
c call xmove(nfile1,center(1),center(2))
c call xdraw(nfile1,cv(1),cv(2))
c compute foci in oblique view
do j=1,2
f1(j)= p8(j)+ 6.*r1*v(j)
f2(j)= p9(j)+ 6.*r1*v(j)
end do
c draw foci in oblique plane
call xdarc(nfile1,f1(1),f1(2),r,t1,t2,npts)
call xdarc(nfile1,f2(1),f2(2),r,t1,t2,npts)
x1=cv(1)-1.5*a*u(1)
y1=cv(2)-1.5*a*u(2)
x2=cv(1)+1.5*a*u(1)
y2=cv(2)+1.5*a*u(2)
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
x1=cv(1)-2.*b*v(1)
y1=cv(2)-2.*b*v(2)
x2=cv(1)+2.*b*v(1)
y2=cv(2)+2.*b*v(2)
call xmove(nfile1,x1,y1)
call xdraw(nfile1,x2,y2)
c Draw the ellipse in an oblique normal view of the plane section
n=100
do i=1,n
t=(i-1)*(2.*pi)/(n-1)
s1=a*cos(t)
s2=b*sin(t)
do j=1,2
e(j)=cv(j)+s1*u(j)+s2*v(j)
end do
if( i .eq. 1)then
call xmove(nfile1,e(1),e(2))
else
call xdraw(nfile1,e(1),e(2))
16
end if
if(i .eq. 70)then
c Construct a point on the ellipse in the oblique plane
p12(1)=e(1)
p12(2)=e(2)
p12(3)=1.
c Draw the point p=p12
call xdarc(nfile1,p12(1),p12(2),r,t1,t2,npts)
endif
end do
c draw lines from point p=p12 on ellipse to focii
call xmove(nfile1,f1(1),f1(2))
call xdraw(nfile1,p12(1),p12(2))
call xdraw(nfile1,f2(1),f2(2))
c create a line a7 from this point p12 on the ellipse in
c the projection direction v, p13 is a point at infinity in direction v.
p13(1)=v(1)
p13(2)=v(2)
p13(3)=0.
call crsspr(p12,p13,a7)
c compute intersection point p14 of a7 with section line a4
write(*,’(1x,a,3(1x,g15.8))’)’ a4= ’,a4
call crsspr(a7,a4,p14)
c draw point p in the front view
x1=p14(1)/p14(3)
y1=p14(2)/p14(3)
call xdarc(nfile1,x1,y1,r,t1,t2,npts)
c compute a line a8 through through the cone vertex point, p5
c and through the point p=p14 in the front view.
call crsspr(p5,p14,a8)
c compute the intersection of the line a8 with the base line of the
c cone a3.
call crsspr(a8,a3,p15)
c Draw line on cone from vertex to cone base.
x1=p5(1)/p5(3)
y1=p5(2)/p5(3)
call xmove(nfile1,x1,y1)
x1=p15(1)/p15(3)
y1=p15(2)/p15(3)
call xdraw(nfile1,x1,y1)
write(*,*)’ Graphic output file: p.eg ’
write(*,*)’ Do this to convert file to postscript: ’
write(*,*)’ pltmerge p.eg q.eg (computes a window)’
write(*,*)’ eg2ps q.eg p.ps ’
end
c
c+ tancircs tangent line segments to a pair of circles
subroutine tancircs(c1,r1,c2,r2,x,y,ta,iflag)
implicit real*8(a-h,o-z)
dimension c1(*),c2(*)
dimension u(2),v(2),w(2),ax(3), tv(3)
17
dimension x(*),y(*),ta(*)
dimension ca(2),cb(2)
c Input:
c c1 Center of circle 1, c1x=c1(1), c1y=c1(2)
c r1 Radius of circle 1
c c2 Center of circle 2, c2x=c2(1), c2y=c2(2)
c r2 Radius of circle 2
c
c Output:
c x Vector of eight x-coordinates of the points defining the
c tangents.
c y Vector of eight y-coordinates of the points defining the
c tangents.
c
c Tangent points of the first outside tangent:
c (x(1),y(1)) (x(2),y(2))
c
c Tangent points of the second outside tangent:
c (x(3),y(3)) (x(4),y(4))
c
c Tangent points of the first inside cross tangent:
c (x(5),y(5)) (x(6),y(6))
c
c Tangent points of the last inside cross tangent:
c (x(7),y(7)) (x(8),y(8))
c
c ta Tangent angles, positive angles between tangents and axis.
c ta(1) is the angle of an outside tangent
c ta(2) is the angle of a cross tangent
c iflag The return flag.
c
c iflag=0, All tangents, both outside and inside
c tangents have been computed.
c
c iflag=1, The two circles intersect. Outside tangents
c have been computed, but no cross tangents
c exis.
c
c iflag=2, The circles coincide, or one lies inside
c the other. The circles are nested, so no
c tangents exist.
c
c Note. For an example using this subroutine, see
one=1.
pi=4.*atan(one)
iflag=0
if(r1 .gt. r2)then
rmax=r1
rmin=r2
ra=r1
rb=r2
ca(1)=c1(1)
ca(2)=c1(2)
cb(1)=c2(1)
cb(2)=c2(2)
else
18
rmax=r2
rmin=r1
ra=r2
rb=r1
ca(1)=c2(1)
ca(2)=c2(2)
cb(1)=c1(1)
cb(2)=c1(2)
endif
c ra >= rb
u(1)=cb(1)-ca(1)
u(2)=cb(2)-ca(2)
a=sqrt(u(1)**2 + u(2)**2)
if( a .le. (rmax+rmin))then
iflag=1
endif
if( (a + rmin) .le. rmax)then
iflag=2
return
endif
do i=1,2
u(i)=u(i)/a
end do
c unit vector u is directed from circle a to circle b
v(1)=-u(2)
v(2)=u(1)
c tangent points to two circles
c = ra - rb
b= sqrt(a**2 - c**2)
theta = atan(c/b)
alpha=pi/2-theta
c first point
xt=ra*cos(alpha)
yt=ra*sin(alpha)
do i=1,2
w(i)=ca(i)+xt*u(i) + yt*v(i)
end do
x(1)=w(1)
y(1)=w(2)
c second point
xt=rb*cos(alpha)
yt=rb*sin(alpha)
do i=1,2
w(i)=cb(i)+xt*u(i) + yt*v(i)
end do
ax(1)=u(1)
ax(2)=u(2)
ax(3)=0.
x(2)=w(1)
y(2)=w(2)
tv(1)=x(2)-x(1)
tv(2)=y(2)-y(1)
19
tv(3)=0.
tvn=0.
c compute vector norm
do j=1,3
tvn=tvn + tv(j)**2
end do
tvn=sqrt(tvn)
c make a unit vector
do j=1,3
tv(j)=tv(j)/tvn
end do
val=abs(dotpr(ax,tv))
ta(1)= acos(val)
c third point
xt=ra*cos(alpha)
yt=-ra*sin(alpha)
do i=1,2
w(i)=ca(i)+xt*u(i) + yt*v(i)
end do
x(3)=w(1)
y(3)=w(2)
c fourth point
xt=rb*cos(alpha)
yt=-rb*sin(alpha)
do i=1,2
w(i)=cb(i)+xt*u(i) + yt*v(i)
end do
x(4)=w(1)
y(4)=w(2)
c
if(iflag .eq. 1)return
c cross tangents to two circles
d1=a/(1+ra/rb)
d2=a-d1
b1=sqrt(d1**2 - rb**2)
b2=sqrt(d2**2 - ra**2)
alpha=acos(rb/d1)
c x2=ra*cos(alpha)
c y2=ra*sin(alpha)
beta=pi+alpha
c x1=a+rb*cos(beta)
c y1=rb*sin(beta)
c fifth point
xt=ra*cos(alpha)
yt=ra*sin(alpha)
do i=1,2
w(i)=ca(i)+xt*u(i) + yt*v(i)
end do
x(5)=w(1)
y(5)=w(2)
c sixth point
20
xt=rb*cos(beta)
yt=rb*sin(beta)
do i=1,2
w(i)=cb(i)+xt*u(i) + yt*v(i)
end do
x(6)=w(1)
y(6)=w(2)
tv(1)=x(6)-x(5)
tv(2)=y(6)-y(5)
tv(3)=0.
tvn=0.
c compute vector norm
do j=1,3
tvn=tvn + tv(j)**2
end do
tvn=sqrt(tvn)
c make a unit vector
do j=1,3
tv(j)=tv(j)/tvn
end do
val=abs(dotpr(ax,tv))
ta(2)= acos(val)
c seventh point
xt=ra*cos(alpha)
yt=-ra*sin(alpha)
do i=1,2
w(i)=ca(i)+xt*u(i) + yt*v(i)
end do
x(7)=w(1)
y(7)=w(2)
c eighth point
xt=rb*cos(beta)
yt=-rb*sin(beta)
do i=1,2
w(i)=cb(i)+xt*u(i) + yt*v(i)
end do
x(8)=w(1)
y(8)=w(2)
return
end
c+ xdarc arc into external plot file
subroutine xdarc(nfile,xc,yc,r,a1,a2,npts)
implicit real*8(a-h,o-z)
c nfile-unit number for output file
c xc,yc-arc center
c r-arc radius
c a1,a2-start and end angles
c npts-number of points in arc
character s*25,t*80
c write(*,*)’ xdarc’
t=’a’
n=2
21
call str(xc,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(yc,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(r,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(a1,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(a2,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
an=npts
call str(an,s)
l=lenstr(s)
t(n:80)=s
write(nfile,’(a)’)t(1:(n+l-1))
return
end
c+ lenstr nonblank length of string
function lenstr(s)
c length of the substring of s obtained by deleting all
c trailing blanks from s. thus the length of a string
c containing only blanks will be 0.
character s*(*)
lenstr=0
n=len(s)
do 10 i=n,1,-1
if(s(i:i) .ne. ’ ’)then
lenstr=i
return
endif
10 continue
return
end
c+ str floating point number to string
subroutine str(x,s)
implicit real*8(a-h,o-z)
character s*25,c*25,b*25,e*25
zero=0.
if(x.eq.zero)then
s=’0’
return
endif
write(c,’(g11.4)’)x
read(c,’(a25)’)b
22
l=lenstr(b)
do 10 i=1,l
n1=i
if(b(i:i).ne.’ ’)go to 20
10 continue
20 continue
if(b(n1:n1).eq.’0’)n1=n1+1
b=b(n1:l)
l=l+1-n1
k=index(b,’E’)
if(k.gt.0)e=b(k:l)
if(k.gt.0)then
s=b(1:(k-1))
k1=index(b,’E+0’)
if(k1.gt.0)then
e=’E’//b((k1+3):l)
else
k1=index(b,’E+’)
if(k1.gt.0)e=’E’//b((k1+2):l)
endif
k1=index(b,’E-0’)
if(k1.gt.0)e=’E-’//b((k1+3):l)
l=k-1
else
s=b
endif
j=index(s,’.’)
n2=l
if(j.ne.0)then
do 30 i=1,l
n2=l+1-i
if(s(n2:n2).ne.’0’)go to 40
30 continue
endif
40 continue
s=s(1:n2)
if(s(n2:n2).eq.’.’)then
s=s(1:(n2-1))
n2=n2-1
endif
if(k.gt.0)s=s(1:n2)//e
return
end
c+ xdrws put line segment in gi file
subroutine xdrws(nfile,a)
implicit real*8(a-h,o-z)
logical tk,fx
common tk,fx
dimension a(4)
x=a(1)
y=a(2)
call xmove(nfile,x,y)
x=a(3)
y=a(4)
call xdraw(nfile,x,y)
return
end
23
c+ xdraw draw parameters to external plot file
subroutine xdraw(nfile,x,y)
implicit real*8(a-h,o-z)
character s*25,t*80
t=’d’
n=2
call str(x,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(y,s)
l=lenstr(s)
t(n:80)=s
write(nfile,’(a)’)t(1:(n+l-1))
return
end
c
c+ xmove move parameters to external plot file
subroutine xmove(nfile,x,y)
implicit real*8(a-h,o-z)
character s*25,t*80
t=’m’
n=2
call str(x,s)
l=lenstr(s)
t(n:80)=s
n=n+l+1
call str(y,s)
l=lenstr(s)
t(n:80)=s
write(nfile,’(a)’)t(1:(n+l-1))
return
end
c
c+ crsspr vector cross product.
subroutine crsspr(a,b,c)
implicit real*8(a-h,o-z)
c c=product of a and b
dimension a(3),b(3),c(3)
c(1)=a(2)*b(3)-a(3)*b(2)
c(2)=a(3)*b(1)-a(1)*b(3)
c(3)=a(1)*b(2)-a(2)*b(1)
return
end
c+ valsub converts string to floating point number (r*8)
subroutine valsub(s,v,ier)
implicit real*8(a-h,o-z)
c examples of valid strings are: 12.13 34 45e4 4.78e-6 4E2
c the string is checked for valid characters,
c but the string can still be invalid.
c s-string
c v-returned value
c ier- 0 normal
c 1 if invalid character found, v returned 0
c
logical p
24
character s*(*),c*50,t*50,ch*15
character z*1
data ch/’1234567890+-.eE’/
v=0.
ier=1
l=lenstr(s)
if(l.eq.0)return
p=.true.
do 10 i=1,l
z=s(i:i)
if((z.eq.’D’).or.(z.eq.’d’))then
s(i:i)=’e’
endif
p=p.and.(index(ch,s(i:i)).ne.0)
10 continue
if(.not.p)return
n=index(s,’.’)
if(n.eq.0)then
n=index(s,’e’)
if(n.eq.0)n=index(s,’E’)
if(n.eq.0)n=index(s,’d’)
if(n.eq.0)n=index(s,’D’)
if(n.eq.0)then
s=s(1:l)//’.’
else
t=s(n:l)
s=s(1:(n-1))//’.’//t
endif
l=l+1
endif
write(c,’(a30)’)s(1:l)
read(c,’(g30.23)’)v
ier=0
return
end
c+ readr read a row of numbers and return in double precision array
subroutine readr(nf, a, nr)
implicit real*8(a-h,o-z)
c Input:
c nf unit number of file to read
c nf=0 is the standard input file (keyboard)
c Output:
c a array containing double precision numbers found
c nr number of values in returned array,
c or 0 for empty or blank line,
c or -1 for end of file on unit nf.
c Numbers are separated by spaces.
c Examples of valid numbers are:
c 12.13 34 45e4 4.78e-6 4e2,5.6D-23,10000.d015
c requires subroutine valsub and function lenstr
c a semicolon and all characters following are ignored.
c This can be used for comments.
c modified 6/16/97 added semicolon feature
dimension a(*)
character*200 b
character*200 c
character*1 d
25
c=’ ’
if(nf.eq.0)then
read(*,’(a)’,end=99)b
else
read(nf,’(a)’,end=99)b
endif
nr=0
lsemi=index(b,’;’)
if(lsemi .gt. 0)then
if(lsemi .gt. 1)then
b=b(1:(lsemi-1))
else
return
endif
endif
l=lenstr(b)
if(l.ge.200)then
write(*,*)’ error in readr subroutine ’
write(*,*)’ record is too long ’
endif
do 1 i=1,l
d=b(i:i)
if (d.ne.’ ’) then
k=lenstr(c)
if (k.gt.0)then
c=c(1:k)//d
else
c=d
endif
endif
if( (d.eq.’ ’).or.(i.eq.l)) then
if (c.ne.’ ’) then
nr=nr+1
call valsub(c,a(nr),ier)
c=’ ’
endif
endif
1 continue
return
99 nr=-1
return
end
c+ dotpr scalar product of 3-space vectors
function dotpr(a,b)
implicit real*8(a-h,o-z)
c 2/5/97
dimension a(*),b(*)
s=0.
do i=1,3
s=s+a(i)*b(i)
enddo
dotpr=s
return
end
26
7 Creating an Elliptical Cross Section Model
Using a Conical Wine Glass
We placed golf ball and a larger wooden ball in a wineglass, measured thediameters of the two balls with a digital caliper in centimeters and measuredthe distance between the two sphere surfaces in the glass by sighting throughthe glass and through the adjusted caliper. Then we calculared the distancebetween centers of the spheres and input this information into the programcalled drawconicsection.ftn to compute the properties of the elliptical crosssection. We wrote a program called drawcm.c that will eventually readpoints of a figure given in cm, and convert to postscript units to producea postscript file, which when printed with Ghostview will have the propercentimeter dimensions. The program currently has an elliptical test figureembeded in it, which then generates an ellipse dimensioned in centimeterswhen printed, and drawing axes, and locating the the two focal points. Theresulting ellipse was cut from the printed paper, a thin piece of cardboardfrom a cerial box was attached with a glue stick and trimmed. Then placedin the wine glass, and the balls did contact the ellipse at its focal points.Unfortunately the glass was accidentally knocked off a table later, before aphoto could be taken.
//drawcm.c Create postscript file. Draw figures so they are printed in centimeter units.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int psline(double p1[],double p2[]);
FILE *out1;
//main(int argc,char **argv){
main(){
int n,i;
double x1;
double x2;
double y1;
double y2;
double scale;
double a,b,c;
double pi;
double t;
double p1[2];
double p2[2];
//double ph;
//double pw;
//char ss[30];
char pr;
27
//char title[200];
out1=fopen("p.ps","w");
pr=’%’;
fprintf(out1,"%c!PS\n",pr);
fprintf(out1,"%c%cCreator: Emery drawcm.c\n",pr,pr);
fprintf(out1,"%c%cEndComments\n",pr,pr);
fprintf(out1,"1 setlinewidth\n");
fprintf(out1,"newpath\n");
fprintf(out1,"/Times-Roman findfont\n");
fprintf(out1,"25 scalefont setfont\n");
//c all distances converted to postscript units (72 to inch)
//printf("Enter book width in centemeters \n");
//gets(ss);
//w=atof(ss);
//w=w*72/2.54;
//printf("Enter text \n");
//gets(title);
//c pw is the page width
//pw=8.5*72;
//c pw is the page height
//ph=11*72;
// Draw a test 18 by 24 rectangle defined in centimeters
x1=2.;
y1=2.;
x2=20.;
y2=26.;
// convert to postscript units from centimeters
scale=(1./2.54)*72;
x1=x1*scale;
y1=y1*scale;
x2=x2*scale;
y2=y2*scale;
p1[0]= x1;
p1[1]= y1;
p2[0]= x2;
p2[1]= y1;
psline(p1,p2);
p1[0]= x2;
p1[1]= y1;
p2[0]= x2;
p2[1]= y2;
psline(p1,p2);
p1[0]= x2;
p1[1]= y2;
p2[0]= x1;
p2[1]= y2;
psline(p1,p2);
28
p1[0]= x1;
p1[1]= y2;
p2[0]= x1;
p2[1]= y1;
psline(p1,p2);
// draw a test ellipse
a=3.11;
b=2.55;
c=1.78;
n=100;
pi=3.14159265358979;
for(i=0;i<n;i++){
t=i*pi*2.0/(n-1);
p2[0]=scale*(a*cos(t) + 11);
p2[1]=scale*(b*sin(t) + 15);
if(i > 0)psline(p1,p2);
p1[0]=p2[0];
p1[1]=p2[1];
}
p1[0]=scale*(11 + a);
p1[1]=scale*(15);
p2[0]=scale*(11 - a);
p2[1]=scale*(15);
psline(p1,p2);
p1[0]=scale*(11);
p1[1]=scale*(15+b);
p2[0]=scale*(11);
p2[1]=scale*(15-b);
psline(p1,p2);
p1[0]=scale*(11+c);
p1[1]=scale*(15+b/10.);
p2[0]=scale*(11+c);
p2[1]=scale*(15-b/10.);
psline(p1,p2);
p1[0]=scale*(11-c);
p1[1]=scale*(15+b/10.);
p2[0]=scale*(11-c);
p2[1]=scale*(15-b/10.);
psline(p1,p2);
fprintf(out1,"stroke\n");
fprintf(out1,"showpage\n");
printf("wrote p.ps\n");
return 0;
}
//c+ psline postscript line
int psline(double p1[],double p2[]){
fprintf(out1,"%12.5g %12.5g moveto\n",p1[0],p1[1]);
fprintf(out1,"%12.5g %12.5g lineto\n",p2[0],p2[1]);
return(0);
}
29
//c+ pscirc postscript circle
int pscirc(double p[],double r,int n){
int i;
double t;
double x;
double y;
if(n <= 1){
return 0 ;
}
for(i=1;i<=n ;i++){
t=(i-1)*2.*3.1415926/(n-1);
x = p[0] + r*cos(t);
y = p[1] + r*sin(t);
if(i == 1){
fprintf(out1,"%12.5g %12.5g moveto\n",x,y);
}
else{
fprintf(out1,"%12.5g %12.5g lineto\n",x,y);
}
}
return(0);
}
//c+ pstext postscript text
int pstext(double p[],char *s, double ang){
int n;
double zero;
//External Functions:
fprintf(out1,"%12.5g %12.5g moveto\n",p[0],p[1]);
zero=0.;
if(ang != zero){
fprintf(out1,"%12.5g %12.5g translate\n",p[0],p[1]);
fprintf(out1,"%12.5g rotate\n",ang);
fprintf(out1,"(%s) show\n",s);
fprintf(out1,"%12.5g rotate\n",-ang);
fprintf(out1,"%12.5g %12.5g translate\n",-p[0],-p[1]);
}
else{
fprintf(out1,"(%s) show\n",s);
}
return(0);
}
8 Proof that the Ellipse is Algebraically a
Conic Section Using Projective Geometry.
Consider a circle in two dimensional projective geometry. The projectivepoints are lines in three dimensions, where the affine representation is theintersection of the cone of lines with say an affine plane z = 1. So the conehas equation
30
x2 + y2 = r2z,
where the circle in the z = 1 plane is
x2 + y2 = r2
Rotating the cone with a rotation say about the x axis through an angle θ,the cone is transformed into a conic sections by the plane z = 1. It is easyto show that this section is algebraically an ellipse, when θ is less than thecone vertex angle. For details see the section Projective Space and the Conic
Sections in Conics, Quadrics, and Projective Space, by James Emery.
9 Appendix A: Derivation of the Equation of
the Ellipse From the Focal Property
An ellipse is the locus of points (x, y), such that the sum of the distancesto two fixed points is a constant. Let the distance between the fixed pointsbe 2c. These points are called the focal points of the ellipse. Suppose thesepoints have coordinates (−c, 0) and (c, 0), with c > 0. Let point (x, y) bea point on the ellipse. Let d1 be the distance from (x, y) to the first focalpoint, and d2 the distance from (x, y) to the second focal point. Then
d1 =√
(x − c)2 + y2,
andd2 =
√
(x + c)2 + y2.
Consider the special case of a point on the ellipse, where the point is on thex-axis, with coordinates (a, 0), where a > c > 0. The sum of distances to thefocal points is 2a here, because
d1 + d2 = (a − c) + ((a − c) + 2c) = 2a.
So a point is on the ellipse if and only if
d1 + d2 = 2a.
31
Now suppose point (0, b) is on the ellipse, where b > 0. Then
d1 + d2 =√
c2 + b2 +√
c2 + b2 = 2√
c2 + b2 = 2a.
Soc2 + b2 = a2.
The numbers a and b are called the semi-axes of the ellipse.Proposition. The canonical equation of the ellipse is
x2
a2+
y2
b2= 1.
Proof. Squaringd1 = 2a − d2,
we find
(x − c)2 + y2 = 4a2 − 4a√
(x + c)2 + y2 + (x + c)2 + y2.
Then(x − c)2 = 4a2 − 4a
√
(x + c)2 + y2 + (x + c)2,
so−4xc = 4a2 − 4a
√
(x + c)2 + y2.
Soxc + a2 = a
√
(x + c)2 + y2.
Squaring and dividing by a2, we find
x2c2 + 2xca2 + a4
a2= (x + c)2 + y2,
x2c2
a2+ 2xc + a2 = (x + c)2 + y2.
x2c2
a2+ 2xc + a2 = x2 + 2xc + c2 + y2
Thenx2c2
a2+ a2 = x2 + c2 + y2
x2(a2 − b2)
a2+ a2 = x2 + (a2 − b2) + y2
32
x2(a2 − b2)
a2= x2 + −b2 + y2
x2 −x2b2
a2= x2 + −b2 + y2
x2b2
a2= b2 − y2.
Dividing by b2, we havex2
a2= 1 −
y2
b2.
Then we have the desired equation
x2
a2+
y2
b2= 1.
10 References and Bibliography
[1] Apostol Tom M., Calculus, Volume 1, 2nd Edition, Blaisdell, 1967.
[2] Emery James D, Projective Space,
http://www.stem2.org/je/projectivespace.pdf
[3] Emery James D, Conics,
http://www.stem2.org/je/conics.pdf.
[4] Emery James D, Conics, Quadrics, and Projective Space
http://www.stem2.org/je/quadric.pdf.
[5] Heath T. L., Editor and Translator, Apollonius of Perga: Treatise on
Conic Sections, New York, Barnes and Noble Inc, 1961, originally publishedby Cambridge University Press in 1898. (Linda Hall Library, QA31 .A43,Linda Hall also has several versions of this work in Latin from the 16th and17th century)
33