如何从一组点作为地面 XY 基准开始绘制 3D 图形

发布于 2024-12-29 00:49:05 字数 607 浏览 0 评论 0原文

这个问题可能看起来有点奇怪,但就我的目的而言,并不是那么疯狂。 这很容易,但我需要你跟着我。

目标

我的目标是绘制三维图表。

问题

问题是我手中开始构建这个图表的材料。实际上我有一个二维空间中的点的集合(因此是两个实数有序值的元组)。考虑一下将这些点的集合存储到一个数组中,然后考虑将它们绘制在 2D 图上。您只会对这些点有一个很好的稀疏视图。

那么,第二步是这样的:考虑具有这些点的表面,并创建与绘制这些点的平面正交的第三个轴。目的是为每个点分配一个数值标量值(使用接受该对并返回数值的函数)。因此,图表应显示从每个点开始并根据分配函数具有特定值的条形。

我怎样才能在 Mathematica 中实现这一目标?

一个小注释

基本上我在二维空间中的点也通过图表连接。是否可以将条形的顶部连接到基点在二维图中连接在一起的其他条形的顶部?

其他一些注释

我的图表不一定是一个表面,而只是放置在平面上的条形的集合,这些条形位于它们所引用的对应点所在的确切位置。但如果您有一个很好的提示如何绘制条形以外的曲面,我们将很乐意接受。

我希望我说清楚了。我想指出我有 Mathematica 8,所以所有功能都可用。谢谢。

This question might seem a little strange but for my purposes is not that crazy.
Its easy but I need you to follow me.

The aim

My aim is plotting a tridimensional graph.

The problem

The problem is the material I have in my hands to start building this graph. Actually I have a collection of points in the 2D space (thus tuples of two real ordered values). Consider a moment to have these collection of points stored into an array and now consider to plot them on a 2D diagram. You will just have a nice sparse view of these points.

Well, the second step is this: consider the surface with these points and create a third axis orthogonal to the plane where those points are drawn. The aim is assigning to every point a numerical scalar value (using a function that accepts the couple and returns a numerical value). So the graph should show bars starting from every point and having a specific value according to the assignment function.

How can I achieve this in Mathematica?

A little note

Basically my points in the 2d space are also connected by a graph. Is it possible to connect the top of the bars to the top of other bars whose base point are connected together in the 2d graph?

Some other notes

My graph doesn`t have to be a surface but just a collection of bars placed on a plane in the exact place where the correspondent point they refer to is located. But if you have a good hint how to draw a surface other than bars, it will be gladly accepted.

I hope I was clear. I would like to point that I have Mathematica 8 so all functionalities are available. Thank you.

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

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

发布评论

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

评论(1

感悟人生的甜 2025-01-05 00:49:05

这可以使用 Graphics3D 原语来完成。让我们从一些数据开始

(* a list of 2D coordinates *)
points2D = RandomReal[{0, Pi}, {50, 2}];

(* some edges as a list of pairs of vertex indices *)
edges = Union[Flatten[MapIndexed[Sort /@ Thread[{#2[[1]], 
     Nearest[points2D -> Automatic, #, 4]}] &, points2D], 1]];

(* constructing list of 3D coordinates *)
f[{x_, y_}] := 2 + Sin[x y]
points3D = {##, f[{##}]} & @@@ points2D;

然后可以按如下方式构建实际绘图(宽度是条形宽度的一半)

With[{width = .02},
  Graphics3D[{{LightBlue, EdgeForm[None],
    Cuboid[{#1, #2, 0} - width {1, 1, 0}, {##} + width {1, 1, 0}] & @@@ points3D},
   {Orange,
    GraphicsComplex[points3D, Line[edges]]}}, 
  Lighting -> "Neutral", 
  BoxRatios -> {1, 1, .6}]]

Mathematicagraphics

This can be done using Graphics3D primitives. Lets start with some data

(* a list of 2D coordinates *)
points2D = RandomReal[{0, Pi}, {50, 2}];

(* some edges as a list of pairs of vertex indices *)
edges = Union[Flatten[MapIndexed[Sort /@ Thread[{#2[[1]], 
     Nearest[points2D -> Automatic, #, 4]}] &, points2D], 1]];

(* constructing list of 3D coordinates *)
f[{x_, y_}] := 2 + Sin[x y]
points3D = {##, f[{##}]} & @@@ points2D;

The actual plot can then be constructed as follows (width is half the width of the bars)

With[{width = .02},
  Graphics3D[{{LightBlue, EdgeForm[None],
    Cuboid[{#1, #2, 0} - width {1, 1, 0}, {##} + width {1, 1, 0}] & @@@ points3D},
   {Orange,
    GraphicsComplex[points3D, Line[edges]]}}, 
  Lighting -> "Neutral", 
  BoxRatios -> {1, 1, .6}]]

Mathematica graphics

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文