POV-Ray : Newsgroups : povray.newusers : Rollercoaster type maths (not possible in povray?) Server Time
29 Jul 2024 10:21:56 EDT (-0400)
  Rollercoaster type maths (not possible in povray?) (Message 8 to 17 of 27)  
<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Trevor G Quayle
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 18:06:44
Message: <44cfd074$1@news.povray.org>
> Thanks for the example, i've not looked into macros, they look a bit like
> function statements, but i dont understand the example i'm afraid. It 
> looks
> like A is the position of the first object and b, is how much the next 
> moves
> from it, i get the rotation, but how is the user supposed to know the
> correct movement between the track pieces if there are hundreds of 
> objects?

Macros are slightly different than function statements.  Basically anything 
that is inside the macro is essentially replaced inline with the code in 
place of the macro call at parse time.  They make doing repetitive things a 
lot easier.

If you posted some code that you tried to do (cleaned up of course) someone 
could probably see what you are doing wrong or what assumptions you are 
mistaken on and lead you in the right direction.

-tgq


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 18:20:00
Message: <web.44cfd28cd4496aa8e2e0912a0@news.povray.org>
"Trevor G Quayle" <Tin### [at] hotmailcom> wrote:

> If you posted some code that you tried to do (cleaned up of course) someone
> could probably see what you are doing wrong or what assumptions you are
> mistaken on and lead you in the right direction.
>
> -tgq

see above post, dated 1 Aug 2006 20:50:01


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 18:30:00
Message: <web.44cfd56ad4496aa8e2e0912a0@news.povray.org>
"CdeathJd" <nomail@nomail> wrote:
> "Trevor G Quayle" <Tin### [at] hotmailcom> wrote:
>
> > If you posted some code that you tried to do (cleaned up of course) someone
> > could probably see what you are doing wrong or what assumptions you are
> > mistaken on and lead you in the right direction.
> >
> > -tgq
>
> see above post, dated 1 Aug 2006 20:50:01

EDIT: Did some more investigating, it was the *11 value at the end, it was
some how scaling between the first 11 points only, i should have realised
this sooner really. Thanks for the help. Trial and error, helping hands and
experimentation have won through again!


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 19:05:01
Message: <web.44cfdd2bd4496aa8e2e0912a0@news.povray.org>
damn, im gonna have to remake my track, as it uses boxes, and it doesn't
rotate the objects in the loop, does anyone know a way of finding the
correct rotation? or do i have to have some weirdly track, made only of
cylinders?


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 19:40:01
Message: <web.44cfe5e0d4496aa8e2e0912a0@news.povray.org>
As well as that, im now trying to go full-throttle and put velocity in. I
know the easiest way to do it, but i doubt pov-ray will like it, if i could
store velocity as a global variable this would be bliss.

Unfortunately every variable has to be #declare'd. So each time it runs
through the scene it loses all the data from the last frame. I though about
outputting the velocity to a file and then reading it back in at the start
of the next frame. The pov-ray help file doesn't really explain anything
very well to me, so has anyone got any advice?


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 1 Aug 2006 21:25:00
Message: <web.44cffe45d4496aa8e2e0912a0@news.povray.org>
Also i tried the only other thing i could think of, making pov ray calculate
through each frame, from the beginning adding the velocity if it was facing
downwards, this didn't work, gave an error, and stopped letting me render
untill i reloaded the program, no idea why, heres my attempt at it:

   camera {
      location 0
      look_at z
      translate <0,0.4,0.4>

      #declare clock1=0;
      #declare newy=0;
      #declare oldy=0;
      #declare velocity=1;
      #while (clock1<clock)
                #declare oldy=newy;
                Spline_Trans (MySpline, velocity+(clock*130), y, 0.5, 0.5)
                #declare newy=camera.y;
                #if (newy>oldy)
                        velocity=velocity+0.5;
                #end
                #declare clock1=clock1+1;
      #end


   }


Post a reply to this message

From: Charles C
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 2 Aug 2006 01:50:01
Message: <web.44d03b1bd4496aa8200a56120@news.povray.org>
Ok, for file writing in POV, try this to get you started....  Note that
there should be a backslash in front of some of the n characters denoting a
new line, but it doesn't make it into the newsgroup.   You'll have to fix
that before this'll work.

// ------------------------------------------

#macro Save_Velocity()
  #fopen IFV_File "InterFrameVelocity.inc" write
  #write ( IFV_File, "// This is a generated file which " )
  #write ( IFV_File, "can probably be deleted without too much harm.n" )
  #write ( IFV_File, concat(  "#declare Velocity = <",
                         vstr(3, Velocity, ",", 0,15),
                         ">;n"
                     )
  )
  #fclose IFV_File
#end

#declare Velocity = <1,0,0>;

Save_Velocity()

#undef Velocity

#ifndef(Velocity)
  #debug "nUh oh, Velocity is undefined.  Including InterFrameVelocity.incn"
  #include "InterFrameVelocity.inc"
#end

#debug concat("nVelocity is <", vstr(3, Velocity, ",", 0,15), ">n" )


// -----------------------------------------


Note that vstr() is the vector version, but there's also str() to convert
floats to strings.

Charles


"CdeathJd" <nomail@nomail> wrote:
> As well as that, im now trying to go full-throttle and put velocity in. I
> know the easiest way to do it, but i doubt pov-ray will like it, if i could
> store velocity as a global variable this would be bliss.
>
> Unfortunately every variable has to be #declare'd. So each time it runs
> through the scene it loses all the data from the last frame. I though about
> outputting the velocity to a file and then reading it back in at the start
> of the next frame. The pov-ray help file doesn't really explain anything
> very well to me, so has anyone got any advice?


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 2 Aug 2006 06:10:00
Message: <web.44d07985d4496aa8e2e0912a0@news.povray.org>
"Charles C" <nomail@nomail> wrote:
> Ok, for file writing in POV, try this to get you started....  Note that
> there should be a backslash in front of some of the n characters denoting a
> new line, but it doesn't make it into the newsgroup.   You'll have to fix
> that before this'll work.
>
> // ------------------------------------------
>
> #macro Save_Velocity()
>   #fopen IFV_File "InterFrameVelocity.inc" write
>   #write ( IFV_File, "// This is a generated file which " )
>   #write ( IFV_File, "can probably be deleted without too much harm.n" )
>   #write ( IFV_File, concat(  "#declare Velocity = <",
>                          vstr(3, Velocity, ",", 0,15),
>                          ">;n"
>                      )
>   )
>   #fclose IFV_File
> #end
>
> #declare Velocity = <1,0,0>;
>
> Save_Velocity()
>
> #undef Velocity
>
> #ifndef(Velocity)
>   #debug "nUh oh, Velocity is undefined.  Including InterFrameVelocity.incn"
>   #include "InterFrameVelocity.inc"
> #end
>
> #debug concat("nVelocity is <", vstr(3, Velocity, ",", 0,15), ">n" )
>
>
> // -----------------------------------------
>
>
> Note that vstr() is the vector version, but there's also str() to convert
> floats to strings.
>
> Charles
>
>
> "CdeathJd" <nomail@nomail> wrote:
> > As well as that, im now trying to go full-throttle and put velocity in. I
> > know the easiest way to do it, but i doubt pov-ray will like it, if i could
> > store velocity as a global variable this would be bliss.
> >
> > Unfortunately every variable has to be #declare'd. So each time it runs
> > through the scene it loses all the data from the last frame. I though about
> > outputting the velocity to a file and then reading it back in at the start
> > of the next frame. The pov-ray help file doesn't really explain anything
> > very well to me, so has anyone got any advice?

Cheers, thats really good, although i should maybe have looked around a bit
more. I'm stuck now anyways as i can find no way of finding out the
camera's y value, and quite frankly i've no idea how to make it work (as i
never manages this in normal programming either).


Post a reply to this message

From: Urs Holzer
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 4 Aug 2006 13:23:08
Message: <44d3827c@news.povray.org>
CdeathJd wrote:
> As well as that, im now trying to go full-throttle and put velocity
> in. I know the easiest way to do it, but i doubt pov-ray will like it,
> if i could store velocity as a global variable this would be bliss.
> 
> Unfortunately every variable has to be #declare'd. So each time it
> runs through the scene it loses all the data from the last frame. I
> though about outputting the velocity to a file and then reading it
> back in at the start of the next frame. The pov-ray help file doesn't
> really explain anything very well to me, so has anyone got any advice?

POV-Ray doesn't save variables between frames. Every frame is parsed for
itself.

If you use splines, you can calculate the velocity easely. In physics,
the velocity is defined as the derivative of the position. I guess
there is no simple way to compute the derivative of a spline in
POV-Ray. But there is an easy way to calculate it with a nummerical
method which is not exact, but exact enough.
Just evaluate the spline at two times. Once where you are in time now
and once a second later. This gives you the position you have now and
the position you will have a second later. If you substract these two
values you will have the velocity. (The velocity is a vector pointing
in the direction you move. His length is your speed.)

It seems you are making progress. I think the documentation of POV-Ray
is very good. Read in the documentation the parts that could help you
and try to understand them. Also try to understand the mathematic
behind the things. And look also at the tutorial in the documentation
which contains many examples.

A little Hint: If you want to move or rotate objects in a
coordinatesystem relative to them, try the following:
Do all transforms in reverse order.

Happy POV-Ray-coding!


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 6 Aug 2006 15:30:01
Message: <web.44d6421dd4496aa8e2e0912a0@news.povray.org>
Urs Holzer <urs### [at] andonyarcom> wrote:
> Just evaluate the spline at two times. Once where you are in time now
> and once a second later. This gives you the position you have now and
> the position you will have a second later. If you substract these two
> values you will have the velocity. (The velocity is a vector pointing
> in the direction you move. His length is your speed.)
>

This would be good to do, if its gone down, add some velocity, but im too
used to basic and i cant do it in pov-ray, its two different languages, the
only similarity is the maths.

I have no idea how to grab the x,y,z value from the camera, or the spline. I
failed here in basic aswell, but cant really explain why, and that wasnt
using splines at all.

I tried doing this in the camera statement:
      Spline_Trans (MySpline, clock-1, y, 0.85, 0.85)
      //translate <50, 42.5, -212>
      #declare ythen=y;
      Spline_Trans (MySpline, clock, y, 0.85, 0.85)
      #declare ynow=y;

it didnt error, but the camera then went far to the left of the track, even
if by chance, the "ythen" and "ynow" values worked, and the view didnt
shift to the left, i still wouldn't know what to do next. Its a shame it
doesnt work more like other programming languages! Then it would have been
easier :S


Post a reply to this message

<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>

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