I don't know what the equations are for an elliptical solid in 3
dimensions, but I believe that in 2 dimensions, the equations are a
pair or parametric quadratics involving x^2 and y^2, such that they
devolve into x^2 + y^2 = c when the foci are congruent (the same point
in 2-dimensional space - i.e. the equation for a circle, where the
constant 'c' is the radius squared)
If you can find out what these equations are, then you should be able
to substitute in an additional 'z' axis variable instead of 'x' or 'y'
- now you'll have an elliptical (oval) cross-section in a plane
perpendicular to the x-y (cartesian) plane.
You can then use this equation to vary the size of the ellipse on the
other (perpendicular) axis.
This is similar to making a volumetric integral in calculus... though
it's been a while since I messed with that stuff. :)
Start by imagining how you would make a trimesh for a sphere. Start
by placing two points (3D vectors) at the 'north' and 'south' poles
(which, for the purposes of this discussion, I'll assume lie on the +/-
x-axis)
Now, starting at x+r (+r units on the x-axis, where r is the radius),
step leftward to x-r, obtaining the desired radius of the cross-section
as r = sin(x). Also, assume the y-axis points into the page, and the
z-axis points vertically.
What you now have, is a wire-frame cross-section of a sphere, where
each cross-section lies in the y-z plane, with radius of sin(x), which
means the radius will increase until x=0, then decrease to 0 again at x
= -r.
Now look at the circle with your eyes looking down the x-axis from
the positive side. You'll see a series of concentric circles (at least,
if you were actually drawing them.) But, what we'll do, is just plot
some of the points on the circle.
Now each circle has the equation y^2 + z^2 = r^2. We can plot those
points by obtaining the y,z components from trig, by stepping the angle
through some small increment, and obtaining y = cos(angle), and
z=sin(angle).
The trick is that, for small r (the original 'r' we got as sin(x),
mind you...) the angular step size is large (maybe pi/4 or 90 degrees),
but as r increases, the angular step size goes down. Let's say we start
with a step size of phi=pi/4, but we double the denominator of that
fraction for every step in the x-axis coordinate.
But even more importantly, the phase - theta - is changed also, so we
really have
y = cos(angle + theta), and z = sin(angle + theta). Now the points
won't line up (be collinear along the x-z plane) - this'll make it
easier to make a trimesh. We'll also increment theta as the radius
changes.
As we generate these points, we store 'em somewhere. Let's say theta
= 1/2 of phi for each time through the x-axis loop; and thus, each
recalculation of phi.
Now the big trick is using these points to generate the trimesh!
With this in mind, the process should be able to be expanded to an
elliptical solid, too.
On Sep 30, 2005, at 7:59 AM, Martin Dillon wrote:
I'm using the new trimesh class to create and manipulate trimeshes on
the fly. One of the types of models I'm generating has a body with an
oval cross section. I plan to allow my users to have the ability to
adjust the degree of 'flatness' of the models oval cross section using
a slider.
Can anyone point me to an algorithm that would allow me to determine
the correct positions to place vertices so that they define an oval
with arbitrary width/height ratio?
Thanks,
Martin
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
wsquires at satx dot rr dot com dot nospam <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|