Révolutions et Mathematica

Discutez d'informatique ici !
PrépaQuébec
Membre Relatif
Messages: 253
Enregistré le: 26 Juin 2007, 14:57

Révolutions et Mathematica

par PrépaQuébec » 14 Aoû 2008, 15:26

Bonjour,

je me demande comment faire des révolutions autour d'un axe donné avec le logiciel Mathematica.
Par exemple, mettons que je veuille effectuer la révolution autour de l'axe des x du graphe de f(x)=2x+1, sur [0,2], comment devrais-je m'y prendre pour avoir une représentation graphique de cette révolution avec Mathematica?

Merci d'avance pour votre aide,

Stef



Chouquet
Membre Naturel
Messages: 12
Enregistré le: 13 Aoû 2008, 19:15

par Chouquet » 14 Aoû 2008, 15:30

la commande manipulate[Plot[...

Chouquet
Membre Naturel
Messages: 12
Enregistré le: 13 Aoû 2008, 19:15

par Chouquet » 14 Aoû 2008, 15:31

PrépaQuébec a écrit:Bonjour,

je me demande comment faire des révolutions autour d'un axe donné avec le logiciel Mathematica.
Par exemple, mettons que je veuille effectuer la révolution autour de l'axe des x du graphe de f(x)=2x+1, sur [0,2], comment devrais-je m'y prendre pour avoir une représentation graphique de cette révolution avec Mathematica?

Merci d'avance pour votre aide,

Stef



cmd : Manipulate[Plot[2x+1,{x,0,2}]]

PrépaQuébec
Membre Relatif
Messages: 253
Enregistré le: 26 Juin 2007, 14:57

par PrépaQuébec » 14 Aoû 2008, 15:51

Non, marche pas.

This Manipulate has no local variables. That action requires a \
Manipulate with local variables.

Stef

PrépaQuébec
Membre Relatif
Messages: 253
Enregistré le: 26 Juin 2007, 14:57

par PrépaQuébec » 14 Aoû 2008, 16:39

Regarde ça Chouquet:

Manipulate[Pane[

Switch[fcns,
reg1,
f[x_] := 2 Sin[x] + 4;
g[x_] := x/4,
reg2,
f[x_] := x^2/8 + 1;
g[x_] := -x/4 + 1
];

yrotate = -1;

xmin = Pi/8;
xmax = 2 Pi;

ymax = 8;
ymin = -ymax;

$$viewangle = theview; (* 1: Front, 2: Back *)
viewlist = Part[{{0.5, 0.5, 1.5}, {0.5, 0.5, -1.5}}, $$viewangle];

activestyle = {PlotPoints -> 16, MaxRecursion -> 0, Mesh -> False};

inactivestyle = {PlotPoints -> 25, MaxRecursion -> 1, Mesh -> False,
PlotStyle ->
If[MemberQ[plotopts, translucent], Opacity[0.5], Opacity[1]]};


outsidesurface[thetamax_, opts___] :=
ParametricPlot3D[{u, (f[u] - yrotate) Cos[v] +
yrotate, (f[u] - yrotate) Sin[v]}, {u, xmin, xmax}, {v, 0,
thetamax}, opts];

insidesurface[thetamax_, opts___] :=
ParametricPlot3D[{u, (g[u] - yrotate) Cos[v] +
yrotate, (g[u] - yrotate) Sin[v]}, {u, xmin, xmax}, {v, 0,
thetamax}, opts];

a = xmin; b = xmax;
endmin[thetamax_, opts___] :=
If[Min[f[a] - yrotate, g[a] - yrotate] ==
Max[f[a] - yrotate, g[a] - yrotate], {},

ParametricPlot3D[{a, r Cos[t] + yrotate, r Sin[t]}, {r,
Min[f[a] - yrotate, g[a] - yrotate],
Max[f[a] - yrotate, g[a] - yrotate]}, {t, 0,
thetamax}, opts]];
endmax[thetamax_, opts___] :=
If[Min[f[b] - yrotate, g[b] - yrotate] ==
Max[f[b] - yrotate, g[b] - yrotate], {},

ParametricPlot3D[{b, r Cos[t] + yrotate, r Sin[t]}, {r,
Min[f[b] - yrotate, g[b] - yrotate],
Max[f[b] - yrotate, g[b] - yrotate]}, {t, 0,
thetamax}, opts]];

startregion[opts___] :=
ParametricPlot3D[{x, ((g[x] - f[x]) t + f[x]), 0}, {x, xmin,
xmax}, {t, 0, 1}, opts];

(* Rotating Region *)
rotatingregion[thetamax_, opts___] := Module[{},
startlist = {x, ((g[x] - f[x]) t + f[x]) - yrotate, 0};
rotmatrix = {{1, 0, 0}, {0, Cos[thetamax], -Sin[thetamax]}, {0,
Sin[thetamax], Cos[thetamax]}};
plotlist = rotmatrix.startlist;

region =
ParametricPlot3D[{plotlist[[1]], plotlist[[2]] + yrotate,
plotlist[[3]]}, {x, xmin, xmax}, {t, 0, 1}, opts]
];

ThreeAxes =
ParametricPlot3D[{{xmax*t + xmin/2 (1 - t), 0, 0}, {0,
ymax/2*t + ymin/2 (1 - t), 0}, {0, 0,
ymax/2*t + ymin/2 (1 - t)}}, {t, 0, 1}, PlotStyle -> Black];

revaxis =
ParametricPlot3D[{t, yrotate, 0}, {t, xmin, xmax},
PlotStyle -> Red];


regionplot = Show[
Plot[{f[x], g[x]}, {x, a, b}, PlotStyle -> Black, Filling -> True,
FillingStyle -> Lighter[Purple, 0.5]],
Graphics[{Red, Line[{{a, yrotate}, {b, yrotate}}]}],
AspectRatio -> Automatic, ImageSize -> 150,
AxesLabel -> {Text@Style["x", 16, Italic],
Text@Style["y", 16, Italic]}, PlotRange -> {-6, 6}];


Grid[{{
Deploy[
Column[{Text@Style["region to rotate around", "Label", 14],
Text@Style[Row[{"the line ", Style[y, Italic], " = -1"}],
"Label", 14],
regionplot
}]],

Show[
If[th ==
0, {}, {outsidesurface[th,
ControlActive[activestyle, inactivestyle]],
insidesurface[th, ControlActive[activestyle, inactivestyle]],
endmin[th, ControlActive[activestyle, inactivestyle]],
endmax[th, ControlActive[activestyle, inactivestyle]]}],
startregion[ControlActive[activestyle, inactivestyle]],
rotatingregion[th, ControlActive[activestyle, inactivestyle]],
If[MemberQ[plotopts, showaxes], {ThreeAxes, revaxis}, {}],
Axes -> MemberQ[plotopts, showaxes],
PlotRange -> {{-1, xmax}, {ymin, ymax}, {ymin, ymax}},
Boxed -> False, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
ViewVertical -> {0, 1, 0}, ViewPoint -> viewlist,
AxesLabel -> {Text@Style["x", 16, Italic],
Text@Style["y", 16, Italic], Text@Style["z", 16, Italic]},
ImageSize -> 258]
}}], ImageSize -> {450, 400}],

{{fcns, reg1, ""}, {reg1 -> "region 1", reg2 -> "region 2"},
ControlPlacement -> Top},
{{plotopts, {translucent, showaxes}, Spacer[295]}, {translucent,
showaxes -> "show axes"}, ControlPlacement -> Bottom,
ControlType -> CheckboxBar},
"",
{{theview, 1, ""}, {1 -> "front", 2 -> "back"},
ControlPlacement -> Right, Appearance -> "Vertical"},
"",
Style[" \[Theta]", 14],
{{th, 0, ""}, 2 Pi, 0, ControlType -> VerticalSlider,
ControlPlacement -> Right},
ControlPlacement -> Right,

TrackedSymbols :> {th, plotopts, theview, fcns},
AutorunSequencing -> {3, 4}]

:++:

Stef

Chouquet
Membre Naturel
Messages: 12
Enregistré le: 13 Aoû 2008, 19:15

par Chouquet » 14 Aoû 2008, 17:04

Mdrrr Loool

PrépaQuébec
Membre Relatif
Messages: 253
Enregistré le: 26 Juin 2007, 14:57

par PrépaQuébec » 14 Aoû 2008, 17:12

Tu l'as essayé?

Sinon une petite question, comment fait-on la flèche, par exemple dans Filling (flèche) Bottom?

Stef

 

Retourner vers ϟ Informatique

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 3 invités

Tu pars déja ?



Fais toi aider gratuitement sur Maths-forum !

Créé un compte en 1 minute et pose ta question dans le forum ;-)
Inscription gratuite

Identification

Pas encore inscrit ?

Ou identifiez-vous :

Inscription gratuite