POV-Ray : Newsgroups : povray.unofficial.patches : Spline bug: floats converted to vectors Server Time
1 Sep 2024 18:15:02 EDT (-0400)
  Spline bug: floats converted to vectors (Message 1 to 10 of 10)  
From: Rune
Subject: Spline bug: floats converted to vectors
Date: 2 Dec 2000 18:47:16
Message: <3a298a04@news.povray.org>
This is about the spline type by Wolfgang Ortmann. (Splines with variables.)

The documentation says that it can handle both vectors and floats, but
whenever I use floats they are converted to vectors, as the code below
shows.


#version unofficial MegaPov 0.6;
#declare MySpline = spline {cubic_spline
   0.0, 0.2,
   0.5, 0.3,
   1.0, 0.1,
}
#debug str(MySpline(0),7,4)


Is there any way around this problem?

Using MySpline(0).x is not an option, because I use the same macro to handle
floats and vectors, and I don't want my vectors to be converted to floats.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Warp
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 03:38:51
Message: <3a2a069b@news.povray.org>
Rune <run### [at] inamecom> wrote:
: whenever I use floats they are converted to vectors
[snip]
: I don't want my vectors to be converted to floats.

  There's an inconsistency here.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Rune
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 07:13:40
Message: <3a2a38f4@news.povray.org>
"Warp" wrote:
> : whenever I use floats they are converted to vectors
> [snip]
> : I don't want my vectors to be converted to floats.
>
>   There's an inconsistency here.

No there's not. First I was talking about the *problem*, which is that
floats are converted to vectors.

Then I asked for a solution.

Oh, but can't I just add .x after the spline call to avoid vectors?

No, because that would convert my vectors to floats, and I don't want that
either.

If you reread my original post I believe that you will find it clear that
that is what I really meant. :)

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Warp
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 08:53:16
Message: <3a2a504c@news.povray.org>
Uh, it was a bit too complicated for my simple mind... :)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Margus Ramst
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 09:17:39
Message: <3A2A5676.4CED75F9@peak.edu.ee>
Rune wrote:
> 
> Using MySpline(0).x is not an option, because I use the same macro to handle
> floats and vectors, and I don't want my vectors to be converted to floats.
> 

Well, if I understand the problem correctly, this should avoid converting the
values to float when they shouldn't be (untested!):

#if(MySpline(n).x = MySpline(n).y & MySpline(n).x = MySpline(n).z)
#declare Val = 0 + MySpline(n).x; //float
#else
#declare Val = <0,0,0> + MySpline(n); //vector
#end

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Rune
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 11:14:34
Message: <3a2a716a@news.povray.org>
"Margus Ramst" wrote:
> Well, if I understand the problem correctly, this should avoid
> converting the values to float when they shouldn't be (untested!):
<snipped>

Yes, that works in many cases, but vectors such as <0,0,0> and <3,3,3> will
still be converted to floats 0 and 3 respectively.

Anyway, I think I can get around it, I just hope it will be fixed for the
next version.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Margus Ramst
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 13:24:21
Message: <3A2A9049.EEF3A868@peak.edu.ee>
Rune wrote:
> 
> Yes, that works in many cases, but vectors such as <0,0,0> and <3,3,3> will
> still be converted to floats 0 and 3 respectively.
> 

Does it matter? They get promoted back to <0,0,0> and <3,3,3> respectively, if a
function requires a vector value.
If you want to use them with e.g. dot operators, you can force vector promotion
with (Float + <0,0,0>)

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Rune
Subject: Re: Spline bug: floats converted to vectors
Date: 3 Dec 2000 15:05:17
Message: <3a2aa77d@news.povray.org>
"Margus Ramst" wrote:
> Rune wrote:
> >
> > Yes, that works in many cases, but vectors such as <0,0,0> and
> > <3,3,3> will still be converted to floats 0 and 3 respectively.
>
> Does it matter? They get promoted back to <0,0,0> and <3,3,3>
> respectively, if a function requires a vector value.

Ah, yes. You're right!

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Andrew Clinton
Subject: Re: Spline bug: floats converted to vectors
Date: 4 Dec 2000 15:18:50
Message: <3A2C25E2.E423AAE9@ibm.net>
While we are talking about spline bugs, here is another one.  One cannot do the
following:

#declare thespline = Spline {
    cubic_spline
    ..
    floats, points
    ..
}

...
do something with the spline
...

#undef thespline // this produces an error

This problem can become an issue when you are using huge numbers of splines in
the scene and the memory for them never gets freed (needless waste of space)

Andrew C


Post a reply to this message

From: Mark Wagner
Subject: Re: Spline bug: floats converted to vectors
Date: 4 Dec 2000 23:49:42
Message: <3a2c73e6$1@news.povray.org>
Andrew Clinton wrote in message <3A2C25E2.E423AAE9@ibm.net>...
>While we are talking about spline bugs, here is another one.  One cannot do
the
>following:
>
>#declare thespline = Spline {
>    cubic_spline
>    ..
>    floats, points
>    ..
>}
>...
>do something with the spline
>...
>
>#undef thespline // this produces an error


Since I've been working on improving the spline stuff, I'll take a look into
that.

--
Mark

"The derivative of sin(2x) is cos(2x)"  - Matt Giwer
"I never said that" - Matt Giwer


Post a reply to this message

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