|
|
In article <38b7154e@news.povray.org>, "Eric Freeman"
<eri### [at] datasynccom> wrote:
> How did you come up with this? Luck? Patience? Or did you say, "hmm...
> the formula for a cactus should be blah blah blah" and just whip it up?
> Even tho I've had a couple semesters of calculus and physics (20 years
> ago)
> I have no clue how to take an idea and make an iso-surface out of it.
No calculus or physics required. If there were, I wouldn't be able to
accomplish anything. I am still in Algebra II.
Well, the cactus is approximately spherical, with an indentation in the
middle and radial ridges.
I started from the equation for a sphere:
function {
sqrt(
sqr(x)
+ sqr(y)
+ sqr(z)
) - 1
}
To indent the top of the cactus and extend the bottom, I modified the y
portion of the equation like this:
+ sqr(y-sqrt(sqr(x/2)+sqr(z/2))*1.5)
This subracts a certain amount from the y value which depends on the
distance from the y axis. The /2 and *1.5 were just to "tune" it to the
right proportions. Subtracting from the y value has the effect of
raising that portion of the surface, since a higher initial value is
required to reach the threshold value. This modification really raises
the sides of the cactus, although a variant of it could be made to
depress the middle.
Then to add the "ridges", I subtracted a value depending on the sine of
a multiple of the angle around the y axis from the total density:
- (sin(atan2(x, z)*18)*0.1)
(note that while this is slightly different from the other version, it
is really just a different way of calling the same function.)
The angle around the y axis can be calculated by atan2(x,z), which
returns the angle in radians. This is ok, since the sin() function takes
radians. I then multiply by 18 to get 18 "cycles" for a full revolution.
Since the sin() function returns values between -1 and 1, I multiplied
it's result by 0.1 to get shallower ridges. This makes the ridges extend
from about 0.1 units "below" the surface of the original sphere-like
shape to about 0.1 units "above" it. Because the function returns both
positive and negative values equally, I could just have easily used
addition to incorporate it into the equation.
I probably did a very poor job of explaining it, but that is how I came
up with this equation. I tend to have more success visualizing the
isosurface as a density function with a "skin" at a certain density
level(the threshold value). I start with a basic shape and progressively
"sculpt" the density pattern by tweaking the function, adding
characteristics to the function, and adding other density functions into
the mix.
--
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/
Post a reply to this message
|
|