3D Ellipsoid out of discrete units

2019-08-08 12:49发布

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

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.

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.

1条回答
Animai°情兽
2楼-- · 2019-08-08 13:29

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

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.

查看更多
登录 后发表回答