POV-Ray : Newsgroups : povray.newusers : Rollercoaster type maths (not possible in povray?) Server Time
29 Jul 2024 10:30:36 EDT (-0400)
  Rollercoaster type maths (not possible in povray?) (Message 21 to 27 of 27)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Alain
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 7 Aug 2006 19:43:18
Message: <44d7d016@news.povray.org>
CdeathJd nous apporta ses lumieres en ce 06/08/2006 15:25:
> 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
> 
> 
> 
You could alter your speed acording to your hight, usualy represented by the "y" 
coordinate. You go faster when you are low, smaller y values, and slower when 
high, larger y values.

-- 
Alain
-------------------------------------------------
Gossip is when you hear something you like about someone you don't.


Post a reply to this message

From: Alain
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 7 Aug 2006 19:56:01
Message: <44d7d311$1@news.povray.org>
CdeathJd nous apporta ses lumieres en ce 07/08/2006 18:21:
> To all,
> 
> Cheers for all your help people, i finally got it working today, it was done
> in a stange way indeed but i managed to make it work. Thanks to everyone for
> their advice and for putting up with my defeatism, im a pessimist im afraid.
> However doing a lot of research helped me get there in the end.
> 
> For reference, here is the file as it currently stands. Hopefully if others
> run into similar problems this will help them out. Note that the file does
> not depend on the CLOCK value in any way:
> 

> //Save_Velocity()
Use the following instead, and you don't have to stop/restart the rendering.

#if(frame_number = 1) Save_Velocity() #end

On the first frame, the condition is true and the code is executed.
On any other frame, the condition is false and the code is completely skipped.

NO more need to comment out/uncomment :-)

Great tool during scene creation to. Using #if(Flag), Flag been deffined near 
the top of the scene, or #if(1) #if(0) allows you to very easily enable or 
disable part of your code, like temporarily removing some object, texture 
elements or just about anything you may need to.


-- 
Alain
-------------------------------------------------
Fundamentalism: Shit must be born again.


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 9 Aug 2006 10:45:01
Message: <web.44d9f485d4496aa8e2e0912a0@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> Use the following instead, and you don't have to stop/restart the rendering.
>
> #if(frame_number = 1) Save_Velocity() #end
>
> On the first frame, the condition is true and the code is executed.
> On any other frame, the condition is false and the code is completely skipped.
>
> NO more need to comment out/uncomment :-)
>
> Great tool during scene creation to. Using #if(Flag), Flag been deffined near
> the top of the scene, or #if(1) #if(0) allows you to very easily enable or
> disable part of your code, like temporarily removing some object, texture
> elements or just about anything you may need to.

Thanks, i initially tried something like that but i used a variable insted.

Another problem, although not a killer one, is that if the track is pointing
directly up or down, and turns a bit, say like a loop-the-loop, the camera
"flips" over, onto the top of the track, when, naturally it should just
remain underneath.
If anyones got any tips on getting rid of this side-effect i'd be most
gratefull, like i said though, its not a killer of a problem.


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 9 Aug 2006 10:55:00
Message: <web.44d9f66ed4496aa8e2e0912a0@news.povray.org>
Also, is it possible to get predifined track "sections" to work. I had a
ready-made section, but it doesn't rotate it to be aligned, it places the
track pieces correctly, but they all face the same way,

Any advice would be nice, as im still using a tube and its looking a lot
like a monorail rollercoaster, than one on tradition two tracked ones.


Post a reply to this message

From: Tim Attwood
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 16 Aug 2006 05:31:24
Message: <44e2e5ec$1@news.povray.org>
> Any advice would be nice, as im still using a tube and its looking a lot
> like a monorail rollercoaster, than one on tradition two tracked ones.

I was thinking about this. There used to be a nice file Stricia, I still
have it around, but it ran on 3.1g, it would extrude shapes along a 
"spline",
this was before spline was implemented, it worked on arrays.
It's all commented in French, not sure what does what inside ...

There is a small ExtrudeSpline file at
www.oyonale.com/ressources/english/sources09.htm
but it also works with arrays, and doesn't seem to bend the shape to
follow the path.

So I stayed up late last night and wrote some macros to extrude splines, and
manage large splines.

I ended up with...

#declare Path_Spline = Spl_coaster;
#declare Shape_Spline = Spl_Ibeam;
union {
   Extrude_Spline(24, 200, y, 0.01, 0.01)
}

to extrude a shape along a spline from 0 to 1, the splines need to be passed
as declares or else large amounts of memory are used up trying to create
temporary splines. The parameters are the shape-steps, path-steps,
sky-vector, look-forward, and banking. This is the same as Rune's
Spline_Trans macro in transforms.inc, and returns a mesh.

I also added...

VSpline_Trans_Path (Vect, Time, Sky, Foresight, Banking)
which is the same as Spline_Trans, except it returns a vector translated
along Path_Spline, and ...

VMatrix_Trans(vec, A, B, C, D)
which is the same as Matrix_Trans, but returns a vector.

I also did some spline managing to convert the path to 0-1 and control 
points

Remap_Spline(SplA SplB begin_at stop_at rez stype begin_out stop_out)
makes a new spline with different spacing

Save_Spline(SplA SplB Filename begin_at stop_at rez stype)
saves a spline to a file

/*
Remap_Spline(Cdeaths, "Spl_coaster", -2, 215, 1,
   "natural_spline", -1/215, 1+(1/215) )
Save_Spline(Spl_coaster, "Spl_coaster", "coaster_spline.inc",
   -0.0025, 1.0025, 0.0025, "natural_spline" )
*/
#include "coaster_spline.inc"

I'll put the files in p.b.scene_files, they're not completely cleaned up,
but it should get you where you want to go.


Post a reply to this message

From: CdeathJd
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 19 Aug 2006 16:20:00
Message: <web.44e771f5d4496aa8e2e0912a0@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:

> #declare Path_Spline = Spl_coaster;
> #declare Shape_Spline = Spl_Ibeam;
> union {
>    Extrude_Spline(24, 200, y, 0.01, 0.01)
> }
>

I tried that and it errored, there were not enough parameters, 5 given, 8
expected, i looked at the extrude file, but its all gibberish to me,
however the comments helped a little bit, but when i ran it, where it says

// usage :
object{ExtrudeSpline(nseg,nseg,Shape,Path,doSmooth,doTest,doFile,fname)
texture{pigment{Red} finish {phong 1}}}

i put my declared shape where "shape" is supposed to go and the Spline where
"path" is supposed to go, but it says it was expecting an array.

I tried using two "monorail" splines and offseting them by adding

"#declare Point1 = (-0.5*y+1*x)+MySpline(Value1);" but at every turn the
tubes crossed over, so that didnt work.

Everything you put after what u quoted above means nothing to me... I dont
have a PHD in maths, which it seems you need to have to use povray for
complex stuff.

It doesn't matter though, i could get my track making program perhaps to
make a spline for the left rail, a spline for the right rail, a spline
inbetween for some wooden "staples" but this would involve 3 seperate
splines, possibly with as much as 6000 points in each one. Surely theres an
easier way.

Also i could make the program output the spline (which the camera would use)
and also the location AND ROTATION of each left rail, right rail, staple
etc. That would be a completely stupid amount of objects though!

I'm close to giving up once again, at least i know that the fault is mine
for not being superb at maths. I'm pretty good at it, just not trigonometry
(which i cannot understand).


Post a reply to this message

From: Tim Attwood
Subject: Re: Rollercoaster type maths (not possible in povray?)
Date: 20 Aug 2006 20:55:55
Message: <44e9049b$1@news.povray.org>
> // usage :
> object{ExtrudeSpline(nseg,nseg,Shape,Path,doSmooth,doTest,doFile,fname)

I think this is a simple bit of confusion, the sample I posted doesn't use
"extspln.pov", which I linked in my message, it uses "spline_tools.inc",
which I posted as a binary to povray.binaries.scene_files, along with the
whole example file, "roller_coaster2.pov"

Since then I've added a few more macros to "spline_tools.inc",

Extrude_Spline_To_File
Spline_Translate
Spline_Rotate
Spline_Scale

Since you want to do an animation, extrude the spline to a file
as a mesh, then include the mesh, instead of recalculating the extrude
every frame. I'll post them as well.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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