| 1 |
% revolutionparaboloid.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2014 |
| 4 |
|
| 5 |
%outputformat := "png"; |
| 6 |
%outputformatoptions := "format=rgb antialias=best"; |
| 7 |
%hppp := 0.5; |
| 8 |
%vppp := 0.5; |
| 9 |
|
| 10 |
input featpost3Dplus2D; |
| 11 |
|
| 12 |
%prologues := 1; |
| 13 |
|
| 14 |
f := 0.7*(3,3,-5); |
| 15 |
|
| 16 |
beginfig(1); |
| 17 |
numeric u, r; |
| 18 |
color b, t; |
| 19 |
u = 2mm; |
| 20 |
b = (-1.0,0.0,0.0); |
| 21 |
t = (-0.4,0.3,0.9); |
| 22 |
r = 0.6; |
| 23 |
drawoptions(withpen pencircle scaled u); |
| 24 |
revolparab( b, t, r ); |
| 25 |
endfig; |
| 26 |
|
| 27 |
def parab( expr xis ) = (0.25*(xis**2)) enddef; |
| 28 |
def oloid( expr xis ) = (1-(xis/2)**2) enddef; |
| 29 |
def deriv( expr xis ) = (0.5*xis) enddef; |
| 30 |
|
| 31 |
beginfig(2); |
| 32 |
pair pzero, pone; |
| 33 |
pzero = (-0.5,-5.5); |
| 34 |
numeric u, delta, n, ste, minx, maxx, itex, tanx, marg, slope, sa, aux; |
| 35 |
n = 50; |
| 36 |
marg = 1; |
| 37 |
u = 5mm; |
| 38 |
delta = sqrt((xpart pzero)**2-4*(ypart pzero)); |
| 39 |
minx = (xpart pzero)-delta-marg; |
| 40 |
tanx = (xpart pzero)+delta; |
| 41 |
maxx = -minx; |
| 42 |
ste = (maxx-minx)/(n+1); |
| 43 |
z0 = (minx,parab(minx)); |
| 44 |
z1 = ((xpart pzero)-delta,parab((xpart pzero)-delta)); |
| 45 |
z2 = (tanx,parab(tanx)); |
| 46 |
z3 = 0.5[z1,z2]; |
| 47 |
draw z0 for itex=minx+ste step ste until maxx: |
| 48 |
--(itex,parab(itex)) endfor withcolor blue; |
| 49 |
draw pzero--z1--z2--cycle; |
| 50 |
draw pzero--z3; |
| 51 |
sa = -angle(z1-z2); |
| 52 |
slope = sind(sa)/cosd(sa); |
| 53 |
aux = 2*(-slope+(slope++1)); |
| 54 |
z4 = (aux,parab(aux)); |
| 55 |
z6 = z4+whatever*dir(angle(1,deriv(aux))); |
| 56 |
aux := 2*(-slope-(slope++1)); |
| 57 |
z5 = (aux,parab(aux)); |
| 58 |
z6 = z5+whatever*dir(angle(1,deriv(aux))); |
| 59 |
draw z6--z4--z5--cycle withcolor red; |
| 60 |
%draw up withcolor blue; |
| 61 |
picture scalpic; |
| 62 |
scalpic = currentpicture; |
| 63 |
currentpicture := nullpicture; |
| 64 |
draw scalpic scaled u withpen pencircle scaled 0; |
| 65 |
endfig; |
| 66 |
|
| 67 |
beginfig(3); |
| 68 |
% ParallelProj := true; |
| 69 |
f := (7, 6, 5); |
| 70 |
% f := (2, 1, 8); |
| 71 |
% f := (7,6,8); |
| 72 |
% f := (0.05,0,9.5); |
| 73 |
% f := (0,9,0); |
| 74 |
numeric ray, coneray, angrotparab, angrotfoc, steprotfoc, itex, xzer, yzer; |
| 75 |
numeric tmpxzero, tmpdelta, tmpxtplu, tmpxtmin, stepx; |
| 76 |
color focus, tmpxaxis, auxca, auxcb, auxcc, auxcd; |
| 77 |
pen penone; |
| 78 |
pair auxa, auxb; |
| 79 |
penone = pencircle scaled 3mm; |
| 80 |
xzer = 1; |
| 81 |
yzer = -0.5; |
| 82 |
stepx = 0.05; |
| 83 |
ray = 3; |
| 84 |
revolparab(blue*parab(ray),black,ray); |
| 85 |
coneray = 4; |
| 86 |
steprotfoc = 15; |
| 87 |
focus = (xzer,0,yzer); |
| 88 |
for angrotfoc=0 step steprotfoc until 360-steprotfoc: |
| 89 |
angrotparab := 0.5*angrotfoc; |
| 90 |
tmpxzero := xzer*cosd(angrotparab); |
| 91 |
tmpxaxis := (cosd(angrotparab),sind(angrotparab),0); |
| 92 |
z0 = (minx,parab(minx)); |
| 93 |
draw rp(-ray*tmpxaxis+blue*parab(-ray)) |
| 94 |
for itex=-ray+stepx step stepx until ray: |
| 95 |
--rp(itex*tmpxaxis+blue*parab(itex)) endfor withcolor blue; |
| 96 |
tmpdelta := sqrt(tmpxzero**2-4*yzer); |
| 97 |
tmpxtplu := tmpxzero+tmpdelta; |
| 98 |
tmpxtmin := tmpxzero-tmpdelta; |
| 99 |
auxca := tmpxtplu*tmpxaxis+blue*parab(tmpxtplu); |
| 100 |
auxcb := tmpxtmin*tmpxaxis+blue*parab(tmpxtmin); |
| 101 |
auxa := rp(auxca); |
| 102 |
auxb := rp(auxcb); |
| 103 |
auxcc := auxca-focus; |
| 104 |
auxcd := auxcb-focus; |
| 105 |
draw auxa withpen penone; |
| 106 |
draw auxb withpen penone; |
| 107 |
endfor; |
| 108 |
draw rp(focus) withpen penone withcolor green; |
| 109 |
produce_auto_scale; |
| 110 |
endfig; |
| 111 |
|
| 112 |
beginfig(4); |
| 113 |
numeric major, minor, focdi, rotaroun, steparoun, ra; |
| 114 |
color majorc, minorc, focdic, garbac, vertec; |
| 115 |
major = 4; |
| 116 |
minor = 2.5; |
| 117 |
f := (-5,0.5,0.4); |
| 118 |
steparoun = 20; |
| 119 |
ra = 0.35; |
| 120 |
focdi = major +-+ minor; |
| 121 |
majorc = major*red; |
| 122 |
minorc = minor*green; |
| 123 |
focdic = -focdi*red; |
| 124 |
for rotaroun=0.5*steparoun step steparoun until 180-0.5*steparoun: |
| 125 |
garbac := planarrotation(majorc,minorc,rotaroun); |
| 126 |
vertec :=0.5[garbac,focdic]; |
| 127 |
revolparab( garbac, vertec, ra ); |
| 128 |
revolparab( (X(garbac),-Y(garbac),0), (X(vertec),-Y(vertec),0), ra ); |
| 129 |
endfor; |
| 130 |
endfig; |
| 131 |
|
| 132 |
beginfig(5); |
| 133 |
f := (9,6,3); |
| 134 |
numeric u, slo, delt, higx, lowx, cenx, rai, focz; |
| 135 |
color cen, foc, low, base; |
| 136 |
path ell, cir, both; |
| 137 |
u = 2mm; |
| 138 |
slo = 0.35; |
| 139 |
delt = slo ++ 1; |
| 140 |
lowx = 2*(slo-delt); |
| 141 |
higx = 2*(slo+delt); |
| 142 |
rai = 2*delt; |
| 143 |
drawoptions(withpen pencircle scaled u withcolor blue); |
| 144 |
revolparab( (0,0,-3), blue, 4 ); |
| 145 |
drawoptions(withpen pencircle scaled u); |
| 146 |
z4 = (lowx,oloid(lowx)); |
| 147 |
z6 = z4+whatever*dir(angle(1,-deriv(lowx))); |
| 148 |
z5 = (higx,oloid(higx)); |
| 149 |
z6 = z5+whatever*dir(angle(1,-deriv(higx))); |
| 150 |
focz = ypart z6; |
| 151 |
cen = (2*slo,0,ypart 0.5[z4,z5]); |
| 152 |
foc = (2*slo,0,focz); |
| 153 |
low = (lowx,0,ypart z4); |
| 154 |
ell = ellipticpath( cen, low-cen, rai*green ); |
| 155 |
cir = fullcircle scaled u; |
| 156 |
both = twocyclestogether( ell, cir shifted rp(foc) ); |
| 157 |
draw both; |
| 158 |
draw ell; |
| 159 |
draw rp(2*cen-low)--rp(low)--rp(foc)--cycle; |
| 160 |
%draw rp(cen+rai*green)--rp(cen-rai*green); |
| 161 |
fill cir shifted rp(black); |
| 162 |
base = (2*slo,0,-3); |
| 163 |
draw rigorouscircle( base, blue, rai ); |
| 164 |
draw rp(base)--rp(foc) dashed withdots withcolor red; |
| 165 |
endfig; |
| 166 |
|
| 167 |
end. |