TeXgraph
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment : -39%
Ordinateur portable ASUS Chromebook Vibe CX34 Flip
Voir le deal
399 €

Premiers Pas 3D

Aller en bas

Premiers Pas 3D Empty Premiers Pas 3D

Message  P.Fradin Sam 19 Jan - 21:53

Voici un premier test en 3D avec plusieurs objets, on peut tester ce fichier avec la version 1.93. C'est un petit peu long en calculs, pas d'affolement. Voici quel doit être le résultat:

Premiers Pas 3D 070929122050104671278915

et voici le fichier source (*.teg):

Code:

% TeXgraph version 1.93
% Fenetre Xmin Xmax Ymin Ymax Xscale Yscale
100#-6#6#-6#6#1#1##
% Marges gauche droite haut bas cadre gestion_couleur comptgraph
101#0.5#0.5#0.5#0.5#0#1#8##
% Affectation des Variables theta et phi
18##[theta:=0.8727, phi:=1.4312, OriginalCoord(1)]##
% Déclaration des Macros
16#cone#[ $R:=%3, $vect:=\normalize(%2), $centre:= %1+%2,
$nb:=%4+1, $pas:= 2*pi/(nb-1),
 S:= {liste des sommmets}
 [ %1, $u:=0,
 $v1:=R*\prodvec(vecK,vect), if norm(v1)=0 then $v1:=R*vecI fi,
 $v2:=\prodvec(vect,v1),
 for $k1 from 1 to nb do
  centre+cos(u)*v1+sin(u)*v2, Inc(u,pas)
  od],
 $F:= {liste des faces }
[ for k2 from 2 to nb do k2+1,k2,1,jump od
          ],
MakePoly(S,F)
]##
16#cylindre#[ $R:=%3, $vect:=\normalize(%2), $centre2:=%1+%2,
$nb:=%4+1, $pas:= 2*pi/(nb-1),
 S:= {liste des sommmets}
 [ $u:=0,
 $v1:=R*\prodvec(vecK,vect), if norm(v1)=0 then $v1:=R*vecI fi,
 $v2:=\prodvec(vect,v1),
 for $k1 from 1 to nb do
  %1+cos(u)*v1+sin(u)*v2, Inc(u,pas)
  od, u:=0,
 for $k1 from 1 to nb do
  centre2+cos(u)*v1+sin(u)*v2, Inc(u,pas)
  od],
 $F:= {liste des faces }
[for k2 from 1 to nb-1 do k2,k2+1,k2+1+nb,k2+nb,jump od],
MakePoly(S,F)
]
##
16#section#{ section( plan, liste facettes) }
MapBy( ClipFacet($Z,%1), Z, %2, jump)
##
16#axes3d#[i*Yinf,0,i*Ysup,0,jump, 
Xinf,0,Xsup,0,jump,
0,Zinf,0,Zsup,jump]
##
16#display3D#[ $F:=1/0, $compt:=0, SaveAttr(),
  for $z in Display3D() do
    Inc(compt,1),
    if Re(z)=Re(jump) then
                if Im(z)>0 then FillStyle:=full,  {LineStyle:=noline,} Width:=2, Ligne3D(F,1)
                else FillStyle:=none, Width:=8, LineStyle:=solid, Ligne3D(F,0) fi,
                F:=1/0, compt:=0
    else Insert(F,z)
    fi,
    if compt=2 then Color:=Im(z), FillColor:=Im(z),
    elif compt=4 then FillOpacity:=Im(z),
  fi
 od, RestoreAttr()
]##
16#getplan#{ getplan( [A,u], v, L1, L2) }
[$v:=normalize(%2), $d1:=%3, $d2:=%4,
 $A:=Copy(%1,1,2), $u:=normalize(Copy(%1,3,2)),
 $w:=prodvec(u,v), $B:= A+d1*v/2+d2*w/2,
 B, B-d1*v,B-d1*v-d2*w,B-d2*w,jump]##
% Déclaration des Eléments graphiques
% rectangle2 (Utilisateur)
18##[LineStyle:=-1,FillStyle:=1,FillColor:=11730940,tMin:=-9.4084,tMax:=9.4084]##
14#rectangle2#Drectangle(Xmin+i*Ymin, Xmax+i*Ymin, Xmax+i*Ymax)#-1##
% objet1 (Utilisateur)
18##[Width:=1,AutoReCalc:=0,LineStyle:=0,FillColor:=8366677,tMin:=-5,tMax:=5]##
14#objet1#[$L:=Sphere( Origin, 3, 35, 35),
  $a:=4.5, $z:=-2,
 $P:=[ dot(a,a,z), dot(-a,a,z), dot(-a,-a,z), dot(a,-a,z), dot(a,a,z),jump],
 $C:=cylindre( dot(-2,3,2), 7*dot(2/3,-1,-2/3), 1,35),
  L:=section( [dot(2,1,1),dot(-1,-1,-1)], L),
 Build3D([Rgb(1,0,0)+i,P] , [Rgb(1,0.8,0.48)+i,C],[FillColor+i,L], [Rgb(0,0,0), axes3d()] ),
 display3D(), FillStyle:= none,
 Width:=6,
  LineStyle:=dotted, Axes3D(0,0,0),
 Color:= Rgb(1,0,0), Ligne3D(P,1),
 plan:=[dot(0,0,z), vecK], I:=Intersection(plan, L),
 Width:=8, Color:=blue, DrawAretes(I,0)
]#-1##
P.Fradin
P.Fradin
Admin

Nombre de messages : 1133
Age : 62
Date d'inscription : 19/01/2008

http://texgraph.tuxfamily.org/

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser