POV-Ray : Newsgroups : povray.advanced-users : subtle behavior of Spline_Trans() macro in transforms.inc : subtle behavior of Spline_Trans() macro in transforms.inc Server Time
3 Jul 2024 04:53:03 EDT (-0400)
  subtle behavior of Spline_Trans() macro in transforms.inc  
From: Kenneth
Date: 19 Apr 2009 16:10:00
Message: <web.49eb83fad1b3bb5cf50167bc0@news.povray.org>
I've lately been using the Spline_Trans() macro in transforms.inc, to align some
objects to a spline.  The macro is Spline_Trans(Spline, Time, SkyVector,
ForeSight, Banking). The basic use of this macro is to align the z-axis of a
created object to the 'forward' direction of the spline, at any particular
interpolated point along its surve. And it works very well; but the docs are
not quite clear about the Foresight value. To make the object alignment *exact*
at a particular spline point, it's recommended to set Foresight "close to zero".
SO...my own assumption was that setting it TO zero would be even more exact; but
that's not the case. What actually happens (at 0) is that the object suddenly
flips 90-deg.--it's now aligned at a right-angle to the spline's 'forward'
direction (which is wrong). So indeed the value SHOULD be 'close to zero' but
not zero.

Taking a look at the macro code itself, I *think* I see where this little
discrepancy lies (although I have to admit that I'm unfamiliar with such things
as Matrix and the other math-intensive functions found there.)

If Foresight=0, there are THREE #locals that now equal each other:
Location
LocationNext
LocationPrev

and Forward (also inside the macro) ends up as vnormalize(<0,0,0>). By making
Foresight some non-zero value (even a small one), vnormalize now has an actual
vector direction to work with.

How these things may affect the Matrix, Transform and VProject_Plane stuff there
is beyond me; but Foresight=0 obviously isn't a good recipe for success.
IMHO--and in an ideal world-- the code should be rewritten to be more elegant
and 'all-inclusive,' so to speak--so that a value of zero IS exact alignment.
But I haven't a clue how to do so! Maybe it isn't possible in the macro's
present form, relying--as it indeed needs to-- on the difference between any
two spline-point positions (and feeding that difference to vnormalize, to
create a vector direction.)

Ken W.


Post a reply to this message

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