POV-Ray : Newsgroups : povray.beta-test : bug in trans_spline (transforms.inc) Server Time
1 Nov 2024 09:21:04 EDT (-0400)
  bug in trans_spline (transforms.inc) (Message 1 to 5 of 5)  
From: Martial
Subject: bug in trans_spline (transforms.inc)
Date: 4 Jun 2002 16:04:26
Message: <3cfd1d4a$1@news.povray.org>
Sorry if this is a recursif message :)

Bug in Spline_Trans in transforms.inc ?

povwinRC5
Win98 PII 350  256 RAM

File: C:\Program Files\POV-Ray for Windows v3.5\INCLUDE\transforms.inc
Line: 183
   #local LocationPrev = <0,0,0>+Spline(Time-Foresight);
   #local Forward = vnormalize(LocationNext-Location) <----ERROR
Parse Error: Cannot normalize zero-length vector.
Returned from renderer with error status
+kff10

/**********START*******************/
#include "transforms.inc"
#declare Rad=.2;
#declare Ray=1;
#declare Object=sphere{y*(Rad+(Ray*.5)),Ray*.5 pigment{rgb <1,1,1>}}
#declare Spline1 =
      spline {
       cubic_spline
    -.25, <0,0,-1>
    0.00, <1,0,0>
    0.25, <0,0,1>
    0.50, <-1,0,0>
    0.75, <0,0,-1>
    1.00, <1,0,0>
    1.25, <0,0,1>
      }

object {Object Spline_Trans(Spline1,clock,y, 0,0)}
// bug transforms.inc  Line: 183
object {Object Spline_Trans(Spline1,clock,y, .2,.5)}
//bug  transforms.inc  Line: 234

/*********END***************/

--
Martial
http://cathemline.org
http://pov-monde.org
http://pov-wip.fr.st


Post a reply to this message

From: bob h
Subject: Re: bug in trans_spline (transforms.inc)
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

From:
Subject: Re: bug in trans_spline (transforms.inc)
Date: 5 Jun 2002 02:13:09
Message: <o1arfuse6fs4qg0uonb1hnitb4uitahqr7@4ax.com>
On Tue, 4 Jun 2002 22:04:12 +0200, "Martial" <mar### [at] cathemlineorg> wrote:

> Sorry if this is a recursif message :)
> Bug in Spline_Trans in transforms.inc ?

No, that's not a bug, that's problem of your script. In one word RTFM but I'll
explain You what is wrong:

> object {Object Spline_Trans(Spline1,clock,y, 0,0)}
> // bug transforms.inc  Line: 183

Nothing strange. In this case You failed on fourth parameter of macro.
Documentation clearly stays it should be positive value. To determine
direction of axis for trensformation it use current value of spline and next
value of spline. The next value is forward about fourth parameter of this
macro. In case of 0 it is the same as current. There is no direction between
current and current point of spline.

> object {Object Spline_Trans(Spline1,clock,y, .2,.5)}
> //bug  transforms.inc  Line: 234

In this case you failed either on second parameter or on definition of spline.
Fourth parameter is specified so fail of previous case is removed. But what in
case of Clock=1 ? It will calculate locations and direction between
Spline1(1+.2) and Spline1(1). Spline1(1.2) is calculation outside of valid
arguments (according to description of splines) so it results the same
location as for Spline1(1). There is no direction between Spline1(1) and
Spline1(1).

Perhaps it could be possible to modify Spline_Trans macro to be ready for such
illegal values but at this moment it is bug in your script. I hope I wrote
understable answer.

ABX


Post a reply to this message

From: Martial
Subject: Re: bug in trans_spline (transforms.inc)
Date: 5 Jun 2002 13:21:13
Message: <3cfe4889@news.povray.org>
Thanks ABX and bob h  for your answer. 
Thanks Bob for your News Macros Spline_Trans :) 

All right ABX the demo scene splinefollow.pov is good !
But I do not see how to change my Spline, 
I come to grips with random value but I do not understand  :( 

Well I read again the doc :)

-- 
Martial
http://cathemline.org
http://pov-monde.org
http://pov-wip.fr.st


Post a reply to this message

From:
Subject: Re: bug in trans_spline (transforms.inc)
Date: 6 Jun 2002 01:53:32
Message: <psttfusdr1skrgvb60jl1asru84unpu6di@4ax.com>
On Wed, 5 Jun 2002 19:20:51 +0200, "Martial" <mar### [at] cathemlineorg> wrote:
> All right ABX the demo scene splinefollow.pov is good !
> But I do not see how to change my Spline, 

Value (max value of second parameter + value of fourth parameter)
should be not greater than two greatest and different time values of spline.
Usually it could be "two last time values" but I can't write it becouse they
can be listed in any order.

ABX


Post a reply to this message

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