绘制 3D 图形时,如何定义其显示的角度?

发布于 2024-08-15 09:00:26 字数 54 浏览 2 评论 0原文

我知道我可以在绘图完成后用鼠标将其旋转到所需的角度。现在,我想知道如何通过代码执行相同的操作。

I know I can after the plot is done, to rotate it with my mouse to the desired angle. Now, I'd like to know how to do the same through code.

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

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

发布评论

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

评论(2

我们只是彼此的过ke 2024-08-22 09:00:26

3D 视图最方便地通过参数 ViewPointViewVertical 定义(还有其他选项:ViewCenterViewVectorViewAngle,但通常将它们保留为 Automatic 就足够了)。

因此,您可以执行以下操作:

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, ViewPoint -> {3, 2, 1}]

要获得 ViewPoint 的良好值,等等。我将函数 Get3DView 定义为 然后

Get3DView[gfx_] := 
  Options[Unevaluated[gfx], {ViewCenter, ViewVector, ViewVertical, ViewPoint}]

您只需将图形复制到 Get3DView 中获得您的选项:

plotpar = Get3DView[<your graphics pasted here>]

在此之后,您可以将您的 plotpar 作为新绘图命令的选项(注意评估):

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, Evaluate@plotpar]

The 3D view is most conveniently defined through the parameters ViewPoint and ViewVertical (There are additional options: ViewCenter, ViewVector, and ViewAngle, but it usually suffices to leave them on Automatic).

So you can do for example

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, ViewPoint -> {3, 2, 1}]

To get good values for ViewPoint, etc. I define a function Get3DView as

Get3DView[gfx_] := 
  Options[Unevaluated[gfx], {ViewCenter, ViewVector, ViewVertical, ViewPoint}]

Then you just copy your graphics into Get3DView to get your options:

plotpar = Get3DView[<your graphics pasted here>]

After this you can put your plotpar as options for new plot commands (note the Evaluate):

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, Evaluate@plotpar]
绝情姑娘 2024-08-22 09:00:26

再看一遍,你的标题涉及 3d 旋转。为此,您可以使用 ViewPoint。应用程序选项卡下的示例似乎就是您正在寻找的内容。

您可以使用 ImageRotate 函数。

ImageRotate@Plot[x, {x, 0, 10}] (*rotate 90 degrees counterclockwise*)
ImageRotate[Plot[x, {x, 0, 10}], phi]  (*rotate phi degrees counterclockwise*)

On second look your title involves 3d rotation. For that you can use ViewPoint. The example under the applications tab seems to be what you are looking for.

You can use the ImageRotate function.

ImageRotate@Plot[x, {x, 0, 10}] (*rotate 90 degrees counterclockwise*)
ImageRotate[Plot[x, {x, 0, 10}], phi]  (*rotate phi degrees counterclockwise*)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文