vrml.
html
VRML
Virtual Reality Modeling Language
Ejemplos de Gráficas en formato VRML
> caracol:=plot3d((1.3)^x*sin(y),x=-1..2*Pi,y=0..Pi,coords=spherical,style=patch,lightmodel=light4,
style=patchnogrid):
> with(plottools):
> vrml(caracol,`[Link]`,smooth_shading=true):
> with(plots):
Warning, the previous binding of the name arrow has been removed and it now has an assigned
value
> display(caracol);
> concha:=tubeplot([((t-5*Pi)*(sin(t)))/(3),((t-5*Pi)*(cos(t)))/(3),(t-5*Pi)*0.9,t=0..5*Pi],radius=(t-5*Pi)*0.2,
tubepoints=25):
> with(plottools):
> vrml(concha,`[Link]`,smooth_shading=true):
> with(plots):
Warning, the previous binding of the name arrow has been removed and it now has an assigned
value
> display(concha);
> c1:= [cos(x)-2*cos(0.4*y),sin(x)-2*sin(0.4*y),y]:
c2:= [cos(x)+2*cos(0.4*y),sin(x)+2*sin(0.4*y),y]:
c3:= [cos(x)+2*sin(0.4*y),sin(x)-2*cos(0.4*y),y]:
c4:= [cos(x)-2*sin(0.4*y),sin(x)+2*cos(0.4*y),y]:
pic:=plot3d({c1,c2,c3,c4},x=0..2*Pi,y=0..10,grid=[25,15],style=patch,
lightmodel=light4):
vrml( pic, `[Link]`, transparency=0.5 );
> display(pic);
[Link] (1 of 8)16/04/2010 10:33:43 a.m.
[Link]
Curvas en el espacio
En el siguiente ejemplo generaremos un archivo VRML para la curva
> b1:=spacecurve(<cos(4*t),t,sin(4*t)>,t=0..2*Pi,axes=normal,thickness=14,numpoints=2000):
> b2:=display(b1,scaling=constrained,orientation=[-10,75]):
> vrml( b2, `[Link]`, transparency=0.5 );
> display(b2);
En el siguiente ejemplo generaremos un archivo VRML para la curva
> b3:=spacecurve(<sin(3*t)*cos(t),sin(3*t)*sin(t),t>,t=-5..5,axes=normal,thickness=4,numpoints=2000):
> b4:=display(b3,scaling=constrained,orientation=[-10,75]):
> vrml( b4, `[Link]`, transparency=0.5 );
> display(b4);
En el siguiente ejemplo generaremos un archivo VRML para la curva
> b5:=spacecurve(<cos(t),sin(t),sin(5*t)>,t=-5..5,axes=normal,thickness=4,numpoints=2000):
> b6:=display(b5,scaling=constrained,orientation=[-10,75]):
> vrml( b6, `[Link]`, transparency=0.5 );
> display(b6);
Curvas Intersección de superficies
En el siguiente ejemplo generaremos un archivo VRML para la intersección de las superficies y
mostrando su curva intersección
> a1:=sqrt(x^2+y^2):
> a2:=-sqrt(x^2+y^2):
[Link] (2 of 8)16/04/2010 10:33:43 a.m.
[Link]
> a3:=y+3:
> Y:=solve(a1=a3,y);
> intsect:=subs(y=Y,a1);
> a4:=spacecurve([x,Y,intsect],x=-5..5,color=blue,thickness=25):
> p1:=plot3d(a1,x=-5..5,y=-5..5,axes=normal,color=red,numpoints=2000,view=[-5..5,-5..5,-5..5],style=patch):
> p4:=plot3d(a2,x=-5..5,y=-5..5,axes=normal,color=red,numpoints=2000,view=[-5..5,-5..5,-5..5],style=patch):
> p2:=plot3d(a3,x=-5..5,y=-5..5,axes=normal,color=yellow,numpoints=2000,view=[-5..5,-5..5,-5..5],style=patch):
> p3:=spacecurve([x,Y,intsect],x=-5..5,color=blue,thickness=25,numpoints=2000):
> a5:=display(p1,p2,p3,p4,scaling=constrained,orientation=[-10,75]):
> vrml( a5, `[Link]`, transparency=0.5 );
> display(a5);
En el siguiente ejemplo generaremos un archivo VRML para la intersección de las superficies y
mostrando su curva intersección
> c:=x^2+y^2-4:
> p:=x^2;
> Y:=solve(c=p,y);
> intsect:=subs(y=Y[1],c); #curva intersección
[Link] (3 of 8)16/04/2010 10:33:43 a.m.
[Link]
> intsect1:=subs(y=Y[2],c); #curva intersección
> p1:=plot3d(c,x=-5..5,y=-5..5,axes=normal,color=red,numpoints=2000,view=[-5..5,-5..5,-5..5],style=patchnogrid):
> p2:=plot3d(p,x=-5..5,y=-5..5,axes=normal,color=yellow,numpoints=2000,view=[-5..5,-5..5,-5..5],
style=patchnogrid):
> p3:=spacecurve({[x,Y[1],intsect],[x,Y[2],intsect1]},x=-3..3,color=blue,thickness=25):
> p4:=display(p1,p2,p3,scaling=constrained,orientation=[-10,75]):
> vrml( p4, `[Link]`, transparency=0.5 );
> display(p4);
Triedro de Frenet
En el siguiente ejemplo generaremos un archivo VRML para la función vectorial y sus
vectores tangente, normal y binormal
> restart: with(plots): with(linalg):with(plottools):
Warning, the name changecoords has been redefined
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the assigned name arrow now has a global binding
> r:=[cos(t),sin(t),t]; tmax:=4*Pi:
> v:=diff(r,t):
> a:=diff(v,t):
[Link] (4 of 8)16/04/2010 10:33:43 a.m.
[Link]
> T:=simplify(v/simplify(dotprod(v,v, 'orthogonal'))):TL:=evalm(simplify(subs(t=t0,r)+(1-t/tmax)*subs(t=t0,T))):
> N1:=map(diff,evalm(T),t): N:=evalm(N1/simplify(dotprod(N1,N1,'orthogonal')^(1/2))):NL:=evalm(simplify(subs
(t=t0,r)+(1-t/tmax)*subs(t=t0,[N[1],N[2],N[3]]))):
> B:=simplify(evalm(crossprod(T,N))):BL:=evalm(simplify(subs(t=t0,r)+(1-t/tmax)*subs(t=t0,[B[1],B[2],B[3]]))):
> t0:=8:
C1:=spacecurve(r,t=0..tmax,color=black,thickness=5,scaling=constrained):
C2:=spacecurve(TL,t=0..tmax,thickness=25,color=red):
C3:=spacecurve(NL,t=0..tmax,thickness=25,color=blue):
C4:=spacecurve(BL,t=0..tmax,color=red,thickness=25,axes=none):
C5:=display({C1,C2,C3,C4}):
> vrml( C5, `[Link]`, transparency=0.5 );
> display(C5);
Dominio de funciones de ->
Trabajaremos la función , para representar gráficamente su dominio en un archivo VRML
> f:=(x,y)->sqrt(1-x+y):
> dom:=display(plot3d([x,y,0],x=-10..10,y=x-1..10,color=red,style=patchnogrid),plot3d(f(x,y),x=-10..10,y=x-1..10,
style=patchnogrid,axes=normal,grid=[30,30],orientation=[15,70])):
> vrml( dom, `[Link]`, transparency=0.5 );
> display(dom);
Límites de funciones de ->
En el siguiente ejemplo generaremos un archivo VRML para la funcion y si límite en (0,0)
> restart: with(plots): with(linalg):with(plottools):
Warning, the name changecoords has been redefined
[Link] (5 of 8)16/04/2010 10:33:43 a.m.
[Link]
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the assigned name arrow now has a global binding
> c6:=(x*y^2)/(x^2+y^4):
> c66:=spacecurve(<t,t,t^3/(t^2+t^4)>,t=-5..5,thickness=25,color=blue):
> c67:=spacecurve(<t,2*t,4*t^3/(t^2+16*t^4)>,t=-5..5,thickness=25,color=red):
> c68:=spacecurve(<t,t^2,t^5/(t^2+t^8)>,t=-5..5,thickness=25,color=green):
> c7:=plot3d(c6,x=-2..2,y=-5..5,style=patchnogrid):
> c8:=display(c7,c66,c67,c68):
> vrml( c8, `[Link]` );
> display(c8);
En el siguiente ejemplo generaremos un archivo VRML para la funcion y si límite en
(0,0)
> d6:=x*sin(1/y)+y*sin(1/x):
> d66:=spacecurve(<t,t,t*sin(1/t)+t*sin(1/t)>,t=-5..5,thickness=25,color=blue):
> d67:=spacecurve(<t,2*t,t*sin(1/(2*t))+(2*t)*sin(1/t)>,t=-5..5,thickness=25,color=red):
> d68:=spacecurve(<t,t^2,t*sin(1/t^2)+t^2*sin(1/t)>,t=-5..5,thickness=25,color=green):
> d7:=plot3d(d6,x=-2..2,y=-5..5,style=patchnogrid):
> d8:=display(d7,d66,d67,d68):
> vrml( d8, `[Link]`, transparency=0.5 );
> display(d8);
En el siguiente ejemplo generaremos un archivo VRML para la funcion y si límite en (0,0)
[Link] (6 of 8)16/04/2010 10:33:43 a.m.
[Link]
> e6:=x^2*y^2/(x^2*y^2+(x-y)^2):
> e66:=spacecurve(<t,t,t^2*t^2/(t^2*t^2+(t-t)^2)>,t=-5..5,axes=normal,thickness=25,color=blue):
> e67:=spacecurve(<t,0,t^2*t^2/(t^2*t^2+(x-t)^2)>,t=-5..5,axes=normal,thickness=25,color=red):
> e68:=spacecurve(<t,t^2,t^2*(t^2)^2/(t^2*(t^2)^2+(t-(t)^2)^2)>,t=-5..5,axes=normal,thickness=25,color=green):
> e7:=plot3d(d6,x=-2..2,y=-5..5,style=patchnogrid,axes=normal):
> e8:=display(d7,d66,d67,d68):
> vrml( e8, `[Link]` );
> display(e8);
Sorpresa
El siguiente VRML es una sorpresa
> with(plottools): with(plots):
Warning, the previous binding of the name arrow has been removed and it now has an assigned
value
> mouth:=cone([-2,-4,-2.8],1,color=red):
> leye:=sphere([-1,-4.65,-3.8],1/2,color=yellow):
> reye :=sphere([-3,-4.65,-3.8],1/2,color=yellow):
> hat:=cutout(hemisphere([-2,-3,-4.5],2),1.90):
> head:=sphere([-2,-3,-3.2],2.2,color=coral,grid=[30,50]):
> inose:=cone([-2,2.9,-5.7],.8,color=orange):
> nose:=rotate(inose,Pi/2,0,0):
> irear:=sphere([-3.80,-3.2,-5.1],.75,color=orange):
> ilear:=sphere([-0.20,-3.2,-5.1],.75,color=orange):
> rear:=translate(irear,0,0,Pi/2):
[Link] (7 of 8)16/04/2010 10:33:43 a.m.
[Link]
> lear:=translate(ilear,0,0,Pi/2):
> lpupil:=sphere([-1,-5.05,-3.8],1/5,color=blue):
> rpupil:=sphere([-3,-5.05,-3.8],1/5,color=blue):
> gs:=display([hat,head,leye,reye,mouth,nose,rear,lear,lpupil,rpupil],orientation=[51,-102],style=patchnogrid):
> vrml( gs, `[Link]` );
> display(gs);
>
[Link] (8 of 8)16/04/2010 10:33:43 a.m.