POV-Ray : Newsgroups : povray.general : Formula please : Re: Formula please Server Time
5 Aug 2024 10:22:27 EDT (-0400)
  Re: Formula please  
From: Christopher James Huff
Date: 1 Oct 2002 15:59:05
Message: <chrishuff-171B6F.15562501102002@netplex.aussie.org>
In article <3d99cdad@news.povray.org>,
 "Mick Hazelgrove" <mic### [at] mhazelgrovefsnetcouk> wrote:

> Can anyone give me a formula for an isosurface consisting of a y plane with
> ripples emmanating from a central point with the ripples growing wider apart
> as they get further from the center. I spent some hours on it but its beyond
> my math I'm afraid :-(

Well, distance from the y axis is sqrt(x*x + z*z). Since you want them 
wider apart at a distance, you could use the inverse or inverse square 
of this...that is simple to do, just remove the sqrt() and divide 1 by 
this value. Use sin() or cos() to get waves, and multiply by some value 
to adjust the number of waves. Now you have something like:

#declare Ripple = function (x, y, z, n) {cos(n/(x*x + z*z))}

The n/r or n/(r^2) starts out at infinity at r = 0, and gets closer and 
closer to 0 as r goes towards infinity, passing through 1 when r == n. 
The infinity will cause problems, you could make sure it never gets 
above n by offsetting r by 1:

#declare Ripple = function (x, y, z, n) {cos(n/(x*x + z*z + 1))}

The n value adjusts the number of ripples, you could also lower the 
offset amount to get more ripples. Multiply the result to adjust the 
height of the ripples, and add or subtract from a plane. For multiple 
ripples, call Ripple() multiple times, adding/subtracting values to the 
xyz coordinates to move the centers around.

isosurface {
    function {y - Ripple(x, y, z, 7)*0.2}
    threshold 0
    ...
}

This is all untested code, but it should get you started. Another thing 
you should probably do is make the ripple size decrease with distance, 
you should be able to figure out how to do that from this code.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.