POV-Ray : Newsgroups : povray.beta-test : bug in trans_spline (transforms.inc) : Re: bug in trans_spline (transforms.inc) Server Time
29 Jul 2024 10:27:28 EDT (-0400)
  Re: bug in trans_spline (transforms.inc)  
From: bob h
Date: 5 Jun 2002 01:36:23
Message: <3cfda357@news.povray.org>
"Martial" <mar### [at] cathemlineorg> wrote in message
news:3cfd1d4a$1@news.povray.org...
>
> Bug in Spline_Trans in transforms.inc ?

You might, or might not, have learned before that vnormalize(<0,0,0>) is
illegal now. I don't know if there will be changes to the transform.inc and
math.inc (and any others) to accomodate for that. There was discussion of
such things in the recent past among pre-beta people.

Hopefully I won't be stepping on any toes here by showing you what I did to
the Spline_Trans() as a workaround just now:

/* BEGIN */
// Author: Rune S. Johansen
// [temporarily added checking for <0,0,0>. bob h]
#macro Spline_Trans (Spline, Time, Sky, Foresight, Banking)
   #local Location = <0,0,0>+Spline(Time);
   #local LocationNext = <0,0,0>+Spline(Time+Foresight);
   #local LocationPrev = <0,0,0>+Spline(Time-Foresight);
 #if
((LocationNext.x*LocationNext.y*LocationNext.z)-(Location.x*Location.y*Locat
ion.z)=0)
   #local Forward = <0,0,0>;
 #else
   #local Forward = vnormalize(LocationNext-Location);
 #end
 #if ((Forward.x*Forward.y*Forward.z)=0)
   #local Right = <0,0,0>;
 #else
   #local Right   = VPerp_To_Plane(Sky,Forward);
 #end
 #if ((Forward.x*Forward.y*Forward.z)|(Right.x*Right.y*Right.z)=0)
   #local Up = <0,0,0>;
 #else
   #local Up      = VPerp_To_Plane(Forward,Right);
 #end
   #local Matrix = Matrix_Trans(Right,Up,Forward,Location)
   #local NextL=(LocationNext-Location);
   #local LPrev=(Location-LocationPrev);
 #if ((NextL.x*NextL.y*NextL.z)|(LPrev.x*LPrev.y*LPrev.z)=0)
   #local BankingRotation = <0,0,0>;
 #else
   #local BankingRotation =
   degrees(atan2(
      VRotation(
         VProject_Plane((LocationNext-Location),Sky),
         VProject_Plane((Location-LocationPrev),Sky),
         Up
      )*Banking
      ,1
   ));
 #end
   transform {
      rotate BankingRotation*z
      transform Matrix
   }
#end
/* END */

As you can see this isn't exactly elegant but all I knew to do. The math.inc
has vnormalize all over in it so you pretty much need to check for <0,0,0>
as soon as possible to prevent the error. I was looking for some way to go
about that from the scene file but I didn't have any revelations.

bob h


Post a reply to this message

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