可视化水平面
我正在尝试使用这种方法开发水平面可视化工具(不知道这是否是标准方法或者是否有更好的方法):
- 1. Take any function
f(x,y,z)=k
(where k is constant), and bounds for x, y, and z. Also take in two grid parameters stepX and stepZ.- 2. to reduce to a level curve problem, iterate from zMin to zMax with stepZ intervals. So
f(x,y,z)=k => f(x,y,fixedZ)=k
- 3. Do the same procedure with stepX, reducing the problem to
f(fixedX, y, fixedZ)=k
- 4. Solve
f(fixedX, y, fixedZ) - k = 0
for all values of y which will satisfy that equation (using some kind of a root finding algorithm).- 5. For all points generated, plot those as a level curve (the inner loop generates level curves at a given z, then for different z values there are just stacks of level curves)
- 6 (optional). Generate a mesh from these level curves/points which belong to the level set.
我遇到的问题是步骤 4。我之前无法知道-手有多少个可能的 y 值将满足该方程(更具体地说,y 有多少个唯一且真实的值)。
另外,我试图使程序尽可能通用,因此我试图不将原始函数 f(x,y,z)=k 限制为任何约束,例如平滑度或多项式除了 k 之外,其他参数都必须根据水平表面的要求保持恒定。
是否有一种算法(不使用 CAS/符号求解)可以识别函数的根,即使它有多个根?我知道二分法很难解决这个问题,因为该区域可能没有符号变化,但是割线/牛顿法效果如何?割线/牛顿法可以用于哪组函数,它是否可以检测并找到两个给定范围内的所有唯一实根?或者是否有更好的方法来生成/可视化水平面?
I'm trying to develop a level surface visualizer using this method (don't know if this is the standard method or if there's something better):
- 1. Take any function
f(x,y,z)=k
(where k is constant), and bounds for x, y, and z. Also take in two grid parameters stepX and stepZ.- 2. to reduce to a level curve problem, iterate from zMin to zMax with stepZ intervals. So
f(x,y,z)=k => f(x,y,fixedZ)=k
- 3. Do the same procedure with stepX, reducing the problem to
f(fixedX, y, fixedZ)=k
- 4. Solve
f(fixedX, y, fixedZ) - k = 0
for all values of y which will satisfy that equation (using some kind of a root finding algorithm).- 5. For all points generated, plot those as a level curve (the inner loop generates level curves at a given z, then for different z values there are just stacks of level curves)
- 6 (optional). Generate a mesh from these level curves/points which belong to the level set.
The problem I'm running into is with step 4. I have no way of knowing before-hand how many possible values of y will satisfy that equation (more specifically, how many unique and real values of y).
Also, I'm trying to keep the program as general as possible so I'm trying to not limit the original function f(x,y,z)=k
to any constraints such as smoothness or polynomial other than k must be constant as required for a level surface.
Is there an algorithm (without using a CAS/symbolic solving) which can identify the root(s) of a function even if it has multiple roots? I know that bisection methods have a hard time with this because of the possibility of no sign changes over the region, but how does the secant/newtons method fare? What set of functions can the secant/newtons method be used on, and can it detect and find all unique real roots within two given bounds? Or is there a better method for generating/visualizing level surfaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想我已经找到了解决问题的方法。我做了更多研究,发现水平面与等值面同义。所以从理论上讲,像行进立方体方法这样的方法应该有效。
I think I've found the solution to my problem. I did a little bit more research and discovered that level surface is synonymous with isosurface. So in theory something like a marching cubes method should work.
如果您需要 Marching Cubes 算法的示例,请查看
http ://stemkoski.github.com/Three.js/Marching-Cubes.html
(使用 JavaScript/Three.js 进行图形)。
有关该理论的更多详细信息,您应该查看
http://paulbourke.net/geometry/polygonise/ 上的文章
In case you're in need of an example of the Marching Cubes algorithm, check out
http://stemkoski.github.com/Three.js/Marching-Cubes.html
(uses JavaScript/Three.js for the graphics).
For more details on the theory, you should check out the article at
http://paulbourke.net/geometry/polygonise/
一种简单的方法,
2D:以灰度图绘制 (x,y),其中 color = Floor(q*f(x,y)),其中 q 是某个任意因子。
3D:plot (x,y, Floor(q*f(x,y))
等效函数的高度将有效地表示在同一水平面上。
如果要获得水平曲线,您可以使用 2D 方法和边缘检测/区域分类以获得同一水平上的点(x,y)。
A simple way,
2D: plot (x,y) with color = floor(q*f(x,y)) in grayscale where q is some arbitrary factor.
3D: plot (x,y, floor(q*f(x,y))
Effectively heights of the function that are equivalent will be representing on the same level surface.
If you to get the level curves you can use the 2D method and edge detection/region categorization to get the points (x,y) on the same level.