从 Mathematica 5 升级到 Mathematica 7

发布于 2024-10-25 12:26:29 字数 3016 浏览 6 评论 0原文

我正在尝试升级目前针对 Mathematica 5 编写的一些方程,以使它们在 Mathematica 7 中工作。

F = Graphics[
  ContourPlot[
   x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
   ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
   Contours -> 20, PlotPoints -> 100]]; 
G = ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2*Pi}, 
  PlotStyle -> {RGBColor[0, 174/255, 239/255]}]; 
H = DeleteCases[F, {x_, y_} /; (x^2 + y^2 > 1), 5]; 
Show[{H, G}, AspectRatio -> Automatic, Frame -> False, Axes -> True, 
   AxesOrigin -> {0, 0}, AxesLabel -> {x, y}, Ticks -> None]

它应该如下所示: 应该看起来像这样,但 id 看起来确实像这样: 看起来像这样

并给出以下错误:

Thread::tdlen: Objects of unequal length in 
  {{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}}+{{},<<21>>,{}} 
  cannot be combined. >>

如果将鼠标悬停在图像上,您会在工具提示中看到以下内容:

The specified setting for the option GraphicsBoxOptions, PlotRange cannot be used.
Coordinate index X is out of range for the enclosing GraphicsComplex

有很多坐标坐标都具有不同的坐标。


我遇到困难的第二个是:

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
    0, 2*Pi}, {v, -Pi/2, Pi/2}}; 
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}}; 
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
U = {P1, P2, P3, P4}; 
XL = {{-1, 1}, {-1, 1}, {-1, 1}}; 
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; 
XS = {"x", "y", "z"}; 
f[a_, b_, c_] := {a, 1.1*b[[2]]*c}; 
g[a_, b_] := {(b*# &) /@ a}; 
T = Text @@@ MapThread[f, {XS, XL, XV}]; 
A = Line @@@ MapThread[g, {XL, XV}]; 
F = (ParametricPlot3D[Evaluate[Evaluate @@ #]][[1]] &) /@ U; 
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, PlotRange -> XL, 
  ViewPoint -> {2.4, 1.3, 2}, 
  DisplayFunction -> 
   Identity}; 
L = {LightSources -> {{{0.1, 0, 1}, RGBColor[0.68, 0.88, 0.96]}}}; 
gr1 = (Show[Graphics3D[#], OPT, L] &) /@ {{EdgeForm[], F}, {Dashing[{0.03, 0.03}], 
    GrayLevel[0.7], A}, {T}}; 
gr2 = DeleteCases[Graphics[Show[Graphics3D[{A, EdgeForm[], F}], OPT, 
        RenderAll -> False]], {__, _Polygon}, 3]; 
Show[{gr1, gr2}, AspectRatio -> Automatic]

这个应该看起来像: 应该看起来像这样,但看起来确实像: does like this

它给出了这些错误:

ParametricPlot3D::write: Tag Plus in x^2+y^2 is Protected. >>
Graphics3D::optx : Unknown option RenderAll
Graphics3D::optx : Unknown option LightSources

如果我然后删除未知选项,这些错误就会消失,但它看起来仍然错误: After moving invalid options

另外,如果将鼠标悬停在 mathematica 中的最后一个图像上,您会收到以下重复的消息工具提示中的时间

Times is not a Graphics3D primitive or directive

I am trying to upgrade some equations that currently are written against Mathematica 5 to get them to work in Mathematica 7.

F = Graphics[
  ContourPlot[
   x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
   ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
   Contours -> 20, PlotPoints -> 100]]; 
G = ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2*Pi}, 
  PlotStyle -> {RGBColor[0, 174/255, 239/255]}]; 
H = DeleteCases[F, {x_, y_} /; (x^2 + y^2 > 1), 5]; 
Show[{H, G}, AspectRatio -> Automatic, Frame -> False, Axes -> True, 
   AxesOrigin -> {0, 0}, AxesLabel -> {x, y}, Ticks -> None]

It should look like this:
Should look like this, but id does look like this: does look like this

and it gives the following error:

Thread::tdlen: Objects of unequal length in 
  {{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}}+{{},<<21>>,{}} 
  cannot be combined. >>

and if you hover over the image you get the following in a tooltip:

The specified setting for the option GraphicsBoxOptions, PlotRange cannot be used.
Coordinate index X is out of range for the enclosing GraphicsComplex

there are a lot of those Coordinate ones all with different coordinates.


And the second one I'm having difficulty with is:

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
    0, 2*Pi}, {v, -Pi/2, Pi/2}}; 
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}}; 
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
U = {P1, P2, P3, P4}; 
XL = {{-1, 1}, {-1, 1}, {-1, 1}}; 
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; 
XS = {"x", "y", "z"}; 
f[a_, b_, c_] := {a, 1.1*b[[2]]*c}; 
g[a_, b_] := {(b*# &) /@ a}; 
T = Text @@@ MapThread[f, {XS, XL, XV}]; 
A = Line @@@ MapThread[g, {XL, XV}]; 
F = (ParametricPlot3D[Evaluate[Evaluate @@ #]][[1]] &) /@ U; 
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, PlotRange -> XL, 
  ViewPoint -> {2.4, 1.3, 2}, 
  DisplayFunction -> 
   Identity}; 
L = {LightSources -> {{{0.1, 0, 1}, RGBColor[0.68, 0.88, 0.96]}}}; 
gr1 = (Show[Graphics3D[#], OPT, L] &) /@ {{EdgeForm[], F}, {Dashing[{0.03, 0.03}], 
    GrayLevel[0.7], A}, {T}}; 
gr2 = DeleteCases[Graphics[Show[Graphics3D[{A, EdgeForm[], F}], OPT, 
        RenderAll -> False]], {__, _Polygon}, 3]; 
Show[{gr1, gr2}, AspectRatio -> Automatic]

This one should look like: Should look like this, but does look like: does look like this

which and it gives these errors:

ParametricPlot3D::write: Tag Plus in x^2+y^2 is Protected. >>
Graphics3D::optx : Unknown option RenderAll
Graphics3D::optx : Unknown option LightSources

If I then remove the Unknown options, those errors disappear but it still looks wrong: After removing invalid options

Also, if you hover over the last image in mathematica you get the following message repeated several times in a tooltip

Times is not a Graphics3D primitive or directive

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沧笙踏歌 2024-11-01 12:26:29

第二个,大圆部分隐藏,轴部分虚线:

r = 1.01/2; d = 1/(100 r);
v1 = Riffle[
   Table[r { Cos[\[Phi]], Sin[\[Phi]], -d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r {  Cos[\[Phi]], Sin[\[Phi]], d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v2 = Riffle[
   Table[-r {  Cos[\[Phi]], -d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[-r { Cos[\[Phi]], d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v3 = Riffle[
   Table[r { -d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r { d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
lx = {{{1, 0, 0}, {2, 0, 0}}}/2;
ly = {{{0, 1, 0}, {0, 2, 0}}}/2;
lz = {{{0, 0, 1}, {0, 0, 2}}}/2;
A2 = Line @@@ {lx, ly, lz, -lx, -ly, -lz};
Graphics3D[
 {
  FaceForm[None, Black], EdgeForm[],
  GraphicsComplex[#, 
     Table[Polygon[Mod[{i, i + 1, i + 3, i + 2}, Length[v], 1]], {i, 
       1, Length[v] - 1, 2}]] & /@ {v1, v2, v3}, {Opacity[0.75], 
   RGBColor[0.68`, 0.88`, 0.96`], Sphere[{0, 0, 0}, 1/2]},
  {Dashing[{0.02, 0.02}], Black, A}, T, A2
  },
 Boxed -> False, 
 Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
    ImageScaled@{0.1, 0, 1}}}, BoxRatios -> {1, 1, 1}, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
 BaseStyle -> FontSize -> 14, ViewPoint -> {2.4`, 1.3`, 2}, 
 ViewVertical -> {0, 0, 1}
 ]

在此处输入图像描述

Second one, great circles partly hidden, axes partly dashed:

r = 1.01/2; d = 1/(100 r);
v1 = Riffle[
   Table[r { Cos[\[Phi]], Sin[\[Phi]], -d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r {  Cos[\[Phi]], Sin[\[Phi]], d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v2 = Riffle[
   Table[-r {  Cos[\[Phi]], -d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[-r { Cos[\[Phi]], d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v3 = Riffle[
   Table[r { -d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r { d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
lx = {{{1, 0, 0}, {2, 0, 0}}}/2;
ly = {{{0, 1, 0}, {0, 2, 0}}}/2;
lz = {{{0, 0, 1}, {0, 0, 2}}}/2;
A2 = Line @@@ {lx, ly, lz, -lx, -ly, -lz};
Graphics3D[
 {
  FaceForm[None, Black], EdgeForm[],
  GraphicsComplex[#, 
     Table[Polygon[Mod[{i, i + 1, i + 3, i + 2}, Length[v], 1]], {i, 
       1, Length[v] - 1, 2}]] & /@ {v1, v2, v3}, {Opacity[0.75], 
   RGBColor[0.68`, 0.88`, 0.96`], Sphere[{0, 0, 0}, 1/2]},
  {Dashing[{0.02, 0.02}], Black, A}, T, A2
  },
 Boxed -> False, 
 Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
    ImageScaled@{0.1, 0, 1}}}, BoxRatios -> {1, 1, 1}, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
 BaseStyle -> FontSize -> 14, ViewPoint -> {2.4`, 1.3`, 2}, 
 ViewVertical -> {0, 0, 1}
 ]

enter image description here

欢烬 2024-11-01 12:26:29

从图片中很难看出您想要第二张图的内容。请尝试一下,告诉我什么是正确的,什么是不足的。

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
     0, 2*Pi}, {v, -Pi/2, Pi/2}};
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}};
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}};
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}};
U = {P1, P2, P3, P4};
XL = {{-1, 1}, {-1, 1}, {-1, 1}};
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
XS = {"x", "y", "z"};
f[a_, b_, c_] := {a, 1.1*b[[2]]*c};
g[a_, b_] := {(b*# &) /@ a};
T = Text @@@ MapThread[f, {XS, XL, XV}];
A = Line @@@ MapThread[g, {XL, XV}];
F = ParametricPlot3D[##, Mesh -> False][[1]] & @@@ U;
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
   PlotRange -> XL, ViewPoint -> {2.4, 1.3, 2}};
L = Lighting -> {{"Directional", 
     RGBColor[0.68, 0.88, 0.96], {{5, 5, 4}, {5, 5, 0}}}};
gr1 = Graphics3D[#, OPT, L] & /@ {{Opacity[0.5], F},
                                  {Dashing[{0.03, 0.03}], GrayLevel[0.7], A},
                                  {T}};
Show[gr1]

这是另一个可能更接近原始版本的版本。这样你就失去了 v7 旋转图形的能力。

gr1 = Rasterize[Graphics3D[#, OPT, L], 
     Background -> None] & /@ {F, {Dashing[{0.03, 0.03}], 
     GrayLevel[0.7], A}, T};
Show[gr1]

It is a little hard to tell from the picture what you want for the second graphic. Please try this and tell me what is right and what is lacking.

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
     0, 2*Pi}, {v, -Pi/2, Pi/2}};
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}};
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}};
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}};
U = {P1, P2, P3, P4};
XL = {{-1, 1}, {-1, 1}, {-1, 1}};
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
XS = {"x", "y", "z"};
f[a_, b_, c_] := {a, 1.1*b[[2]]*c};
g[a_, b_] := {(b*# &) /@ a};
T = Text @@@ MapThread[f, {XS, XL, XV}];
A = Line @@@ MapThread[g, {XL, XV}];
F = ParametricPlot3D[##, Mesh -> False][[1]] & @@@ U;
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
   PlotRange -> XL, ViewPoint -> {2.4, 1.3, 2}};
L = Lighting -> {{"Directional", 
     RGBColor[0.68, 0.88, 0.96], {{5, 5, 4}, {5, 5, 0}}}};
gr1 = Graphics3D[#, OPT, L] & /@ {{Opacity[0.5], F},
                                  {Dashing[{0.03, 0.03}], GrayLevel[0.7], A},
                                  {T}};
Show[gr1]

Here is another take that may be closer to the original. You lose the v7 ability to rotate the graphic with this.

gr1 = Rasterize[Graphics3D[#, OPT, L], 
     Background -> None] & /@ {F, {Dashing[{0.03, 0.03}], 
     GrayLevel[0.7], A}, T};
Show[gr1]
层林尽染 2024-11-01 12:26:29

第一个:

ContourPlot[x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
 ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
 Contours -> 20, RegionFunction -> (#1^2 + #2^2 <= 1 &), 
 BoundaryStyle -> Blue]

[编辑]
第二个,使用 AT 的给定值:

Show[
 ParametricPlot3D[{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*
    Sin[v]}, {u, 0, 2*Pi}, {v, -Pi/2, Pi/2}, 
  MeshFunctions -> {#1 &, #2 &, #3 &}, PlotStyle -> Opacity[0.75], 
  Mesh -> {{0}, {0}, {0}}, MeshStyle -> Black, BoundaryStyle -> Black,
   Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
  PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
  ViewPoint -> {2.4`, 1.3`, 2}, 
  Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
     ImageScaled@{0.1, 0, 1}}}],
 Graphics3D[{{Dashing[{0.03, 0.03}], Black, A}, {T}}]
 ]
  • 我认为轴需要作为单独的内部/外部段来完成。
  • 这个版本中显示了大圆圈;如果需要的话,为了防止这种情况,需要绘制部分曲线而不是网格线。

First one:

ContourPlot[x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
 ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
 Contours -> 20, RegionFunction -> (#1^2 + #2^2 <= 1 &), 
 BoundaryStyle -> Blue]

[Edit]
Second one, using the given values for A and T:

Show[
 ParametricPlot3D[{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*
    Sin[v]}, {u, 0, 2*Pi}, {v, -Pi/2, Pi/2}, 
  MeshFunctions -> {#1 &, #2 &, #3 &}, PlotStyle -> Opacity[0.75], 
  Mesh -> {{0}, {0}, {0}}, MeshStyle -> Black, BoundaryStyle -> Black,
   Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
  PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
  ViewPoint -> {2.4`, 1.3`, 2}, 
  Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
     ImageScaled@{0.1, 0, 1}}}],
 Graphics3D[{{Dashing[{0.03, 0.03}], Black, A}, {T}}]
 ]
  • I think the axes will need to be done as separate interior/exterior segments.
  • The great circles show through in this version; preventing that will require drawn partial curves instead of mesh lines, if that's required.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文