|
![](/i/fill.gif) |
Jeff Lee <shi### [at] gate net> wrote:
Hi Jeff!
> I'd like to try adding a feature to POV-Ray, to let me use splines to
> arbitrarily scale objects in a non-linear fashion.
Actually this is something I tried to implement quite a long time ago,
but failed. I assume now know the basics of how a raytracer works, ie
sending of a "ray" from the cammera throught the viewplane and check
which object it hits (and bouncing,etc...). The difficult part of what
you are suggesting is to determine when such a ray hits the spline
scaled object. For a sphere or another primitive it's is fairly easy
(in advance) write a simple function that determines when and if a ray
hits the object, but with a spline scale the object can be so distorted
so that it's quite difficult to determine the intersection of the ray.
Remeber that not all polynomials of degree 4 or more *can* be solved
analytically. But!
We can probably find the intersection nummerically. The simples way to
do it would be to use the isosurface patch which can draw any shape you
like as long as you can described it as a function.
The following example shows how to distort the object described by F1
(a sphere with radius 1) along a simple spline (with only one segment)
in the xy-plane. Example:
#declare F1 = function { sqr(x)+sqr(y)+sqr(z) - 1 }
#declare SPLINE = function { x*x + x - 1 }
#declare RESULT = function { F1(x,y+SPLINE(x,y,z),z) }
isosurface {
function RESULT
bounded_by { box{ <-2,-2,-2> <2,2,2> } }
max_gradient 10.0
method 2
pigment { color rgb <1,1,0> }
finish {
phong 0.5
}
}
The only problem with this approach is that it's slow, you can't distort
any object you like (you must describe it as a function) and it would be
cumbersome to have intricate spline objects. To simplify things you
probably could make a smart includefile which creates an isosurface
for every segment in the spline etc... or maybe the macro facility in
the isosurface patch could come in handy.
/ Mathias Broxvall
PS. I am not a naitive english speaker, therfore my "mathematical terms"
could be quite wrong... I have just tried to translate them from swedish
.DS
Post a reply to this message
|
![](/i/fill.gif) |