POV-Ray : Newsgroups : povray.general : Equiation needed : Re: Equiation needed Server Time
12 Aug 2024 09:21:50 EDT (-0400)
  Re: Equiation needed  
From: Ilmari Karonen
Date: 8 Mar 1999 14:53:22
Message: <36e42ab2.0@news.povray.org>
Peter Popov wrote in message <3c796fc0.8500773@news.povray.org>...
>Can anyone suggest an equation that gives the distance to a unit
>circle lying in the x-z plane? It should look like an wood pattern
>whose axis is not +z but a circle. Any ideas?


If you have Superpatch, just use this macro (I just wrote this,
haven't tried it yet.)

#macro TorusWood ( Major )
  function { sqrt(x*x+y*y+z*z-Major*(2*sqrt(x*x+z*z)-Major)) }
#end

Put it where you'd normally have the name of the pattern, as in:

pigment {
  TorusWood( 5 )
  color_map {
    [0/3 color Red]
    [1/3 color Green]
    [2/3 color Blue]
    [3/3 color Red]
  }
}

Here are some other pattern macros:

// A torus-shaped density pattern, from which the above was derived.

#macro Toroidal ( Major ) // minor radius always 1
  function { max(0,1-sqrt(x*x+y*y+z*z-Major*(2*sqrt(x*x+z*z)-Major))) }
#end

// Two point-to-point cones around the y-axis, similar to the cylindrical
// pattern except the width of the cylinder at any point is the same as
// the y-coordinate value. (untested)

#macro Conical ( )
  function { max(0,1-sqrt(x*x+z*z)/abs(y)) }
#end

// A variable number of concentric cones, can be used with the radial
// pattern to create longitude-latitude lines on a sphere.

#macro Latitudes ( Frequency )
  #local Pi = pi; // don't ask, some "feature" of Superpatch
  function { Frequency*asin(y/sqrt(x*x+y*y+z*z))/Pi+Frequency/2 }
#end

More coming as soon as I finish my finals and have time for raytracing
again..

--
Ilmari Karonen (ilt### [at] scifi)
http://www.sci.fi/~iltzu/


Post a reply to this message

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