离散单元中的 3D 椭球 [英] 3D Ellipsoid out of discrete units

查看:29
本文介绍了离散单元中的 3D 椭球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 3d 空间中从单个块中绘制一个椭圆体.

I'm trying to draw an ellipsoid in 3d space out of individual blocks.

我对 2D 椭圆没有问题,但就 3D 而言,我遇到了一些麻烦.我正在使用 Bresenham 的圆算法来绘制二维椭圆.我想要做的是在 X 半径和 Y 半径上以增加的(从底部开始向上,另一半使用对称性)半径在图层中绘制 2D 椭圆.

I have no problem with 2D ellipses, but as far as 3D goes I'm having some trouble. I'm using Bresenham's circle algorithm to draw 2D ellipses. What I'm trying to do is draw 2D ellipses in layers with an increasing (starting from the bottom going up, using symmetry for the other half) radius on both the X radius and Y radius.

这一切听起来都可行,但是当我去实现它时,我不知道如何改变 x 半径和 y 半径来制作椭圆体的曲线.

It all sounds like it would work, but when I go to implement it, I can't figure out how to alter the x radius and y radius to make the curve of the ellipsoid.

推荐答案

您的 2D 切片应该都具有相同的方向和纵横比.

Your 2D slices should all have the same orientation and aspect ratio.

如果你的椭球是轴对齐的,它们也应该有相同的中心.

If your ellipsoid is axis-aligned, they should also have the same center.

您的切片应按比例缩放:

Your slices should scale proportionally to:

scale = sqrt(1 - ((center-z)/half_vsize)^2)

where:
  z = height of the current slice
  center = height of the largest slice
  half_vsize = half the vertical size of the ellipsoid

如果 (x0, y0) 是最大切片的 x 和 y 宽度,(x, y) = (scale*x0, scale*y0) 是高度 z 处切片的 x 和 y 宽度.

If (x0, y0) is the x- and y-width of the largest slice, (x, y) = (scale*x0, scale*y0) is the x- and y-width of the slice at height z.

这篇关于离散单元中的 3D 椭球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆