How do I render an ellipsoid?

BlitzPlus Forums/BlitzPlus Programming/How do I render an ellipsoid?

Kalisme(Posted 2008) [#1]
I've been thinking about working with ellipsoids, the ideas been in my head for a while, but unfortunatlely I was busy with other things.

Does anyone have any suggestions on rendering fast ellipsoids (pixel-by-pixel)? I'd like to be able to rotate them, but if I guess I can figure that part out... I've read a few tutorials on the fast rendering of rasterized circles, but I've had a hastle distorting the two differant scalers... A bit of a pain really... Anywho, I'll be thankful for any help given.

I'm hoping to render them as 2d objects, then faking the 3rd axis by shading and using the Z-Buffer. I guess Ecstatica enspired me.


Timjo(Posted 2008) [#2]
There are various ways to do this, but here's mine. I'm sure there are others out there who can provide a more sophisticated method.


Const density#=1.0
x_centre=100
y_centre=100
x_diameter=100
y_diameter=100

For a#=0 To 359 Step density#
x=x_diameter*Sin(a#)+x_centre
y=y_diameter*Cos(a#)+y_centre
Plot x,y
Next


density# is the density of the dots that make up the oval - the lower the value the closer the dots.

x_centre and y_centre are the centre points of the oval

change x_diameter and y_diameter to vary the shape of the oval (both the same = a circle)

Obviously, there are faster ways of rendering the pixels than the 'plot' command (writepixelfast), but it's just demonstrating how to change the two axes of the ellipse.

Not sure if this is what you're after, but hope it helps.


andy_mc(Posted 2008) [#3]
instead of using plot, try drawing a line from one point to the next, this should give a better result.

Const density#=1.0
x_centre=100
y_centre=100
x_diameter=100
y_diameter=100

For a#=0 To 359 Step density#
x1=x_diameter*Sin(a#)+x_centre
y1=y_diameter*Cos(a#)+y_centre
x2=x_diameter*Sin(a#+density)+x_centre
y2=y_diameter*Cos(a#+density)+y_centre
line x1,y1,x2,y2
Next