POV-Ray : Newsgroups : povray.general : Need help figuring something out Server Time
26 Dec 2024 00:44:57 EST (-0500)
  Need help figuring something out (Message 1 to 9 of 9)  
From: DJ Wiza
Subject: Need help figuring something out
Date: 29 Apr 2006 18:40:52
Message: <4453eb74$1@news.povray.org>
If you look at the p.b.animation newsgroup, you can see my recent posts 
with my current project, which is a program that converts No Limits 
(http://www.nolimitscoaster.de - domain is .de, but the site is in 
English) roller coaster tracks into a POV-Ray scene.

My problem is figuring out banking.  No Limits uses bezier curves to 
define the track, and each point has a banking value.  The problem comes 
when you make a vertical loop.  At the entrance and exit of the loop, 
the banking is 0.  At the top, the banking is 180.

Because of this, I can't just use simple interpolation between banking 
angles.  Otherwise, the track twists 90 degrees as it enters and exits 
the loop.  This effect can be seen at 
http://www.sohcahtoa.net/images/thriller.png.

Another problem (which probably will have the same solution) is with 
corkscrew elements (A good example can be seen at 
http://www.rcdb.com/ig13.htm?picture=4).  If you defined a corkscrew 
with 5 points, the first point would have zero banking, then 90, 180, 
but the next to last ends up being either 270 or -90, and the last ends 
up being 0, but is guaranteed not to be 360.  The No Limits track editor 
won't allow it.  If you try to rotate it past 270, nothing happens.  It 
stays at 270.  But then if you put it to 0, it looks exactly as 
expected, and you get your nice smooth corkscrew.

Does anyone know how I could implement a system to calculate banking 
like this?

-DJ


Post a reply to this message

From: Roman Reiner
Subject: Re: Need help figuring something out
Date: 29 Apr 2006 19:40:01
Message: <web.4453f81cfd5b7a09dad8fec00@news.povray.org>
Hi Wiza

I'm following your threads with great interest. Concernig your problem i
can't say very much as i have no insight to the code (neither yours nor to
that of no limit) but i guess i see where the problem is.
when the car leaves a loop its banking is drilled by 360 degrees compared to
the banking at which it entered.
It's difficult to describe, but if you watch a car going through a loop from
above and observe for example its front and its end point you can interpret
their movement as a rotation around the vertical axis if you leave the
vertical components of the movement out (when you make it more a corkscrew
it will become more obvious).
Regarding your image i can see that in your case the movement watched from
above is similar to a S curve.

I hope this helpes you to find the problem!

Regards Roman


Post a reply to this message

From: Roman Reiner
Subject: Re: Need help figuring something out
Date: 30 Apr 2006 04:35:01
Message: <web.445475acfd5b7a09e7dcb31e0@news.povray.org>
Me again.

I thought about your problem and i'd like to make a suggestion how the
problem could possibly be solved (and as i guess it is handled in no
limits).

First of all. Yes a loop and a corkscrew is basically the same thing.

From what i read you are interpolating the banking between values that are
given at specific points. let's look at the last quarter of a loop. as you
wrote the banking goes from 270 to 0 by making 270-270=0. As it went from 0
to 270 during the first three quaters its roling back and gives that
distortion you're facing with.
Instead the banking should go from 270 to 0 by doing 270+90=360=0.

If you calculate the banking between two control points i would at first
check if any angle is negative. if so add 360 until it's positive.
afterwards mod(x,360) all the angles. Now they should all be in the range 0
to 360 degrees.
now calculate the (absolute) angle between the two controlpoints (second
minus first). if that is bigger than 180 degrees use the inverse angle
(360-angle).
In our example (270 to 0) it would calculate abs(0-270)=270>180 and
therefore use 360-abs(0-270)=90 instead and 270+90=360=0 leads to the
correct
handling.

Another example would be 90 --> 280. Here It goes abs(280-90)=190>180 ==>
360-abs(280-90)=170.

You said no limits wont allow you to use banking values greater than 270 but
i guess it's basically doing the same thing as i suggested above. My
algorithm is untested and may contain errors but this is how it should do
basically.

If you can give a hint which method/function you're using to interpolate the
values between the controlpoints i could propably suggest a smoother method.
Maybe not :)

Hope that helps
Regards Roman


Post a reply to this message

From: Sebastian
Subject: Re: Need help figuring something out
Date: 30 Apr 2006 04:41:52
Message: <pan.2006.04.30.08.41.51.21562@gmx.de>
> Does anyone know how I could implement a system to calculate banking 
> like this?

If you interpolate between two banking values you could assume
that for angles >= 180 (or >= 270?) there can only be 
"forward rotation" towards zero. And if it should be "backwards"
towards zero there must be intermediate steps below 180 or 
something. Great animations btw..

Sebastian


Post a reply to this message

From: DJ Wiza
Subject: Re: Need help figuring something out
Date: 30 Apr 2006 10:29:13
Message: <4454c9b9$1@news.povray.org>
Roman Reiner wrote:
> Me again.
> 
> I thought about your problem and i'd like to make a suggestion how the
> problem could possibly be solved (and as i guess it is handled in no
> limits).
> 
> First of all. Yes a loop and a corkscrew is basically the same thing.
> 
> From what i read you are interpolating the banking between values that are
> given at specific points. let's look at the last quarter of a loop. as you
> wrote the banking goes from 270 to 0 by making 270-270=0. As it went from 0
> to 270 during the first three quaters its roling back and gives that
> distortion you're facing with.
> Instead the banking should go from 270 to 0 by doing 270+90=360=0.
> 
> If you calculate the banking between two control points i would at first
> check if any angle is negative. if so add 360 until it's positive.
> afterwards mod(x,360) all the angles. Now they should all be in the range 0
> to 360 degrees.
> now calculate the (absolute) angle between the two controlpoints (second
> minus first). if that is bigger than 180 degrees use the inverse angle
> (360-angle).
> In our example (270 to 0) it would calculate abs(0-270)=270>180 and
> therefore use 360-abs(0-270)=90 instead and 270+90=360=0 leads to the
> correct
> handling.
> 
> Another example would be 90 --> 280. Here It goes abs(280-90)=190>180 ==>
> 360-abs(280-90)=170.
> 
> You said no limits wont allow you to use banking values greater than 270 but
> i guess it's basically doing the same thing as i suggested above. My
> algorithm is untested and may contain errors but this is how it should do
> basically.
> 
> If you can give a hint which method/function you're using to interpolate the
> values between the controlpoints i could propably suggest a smoother method.
> Maybe not :)
> 
> Hope that helps
> Regards Roman
> 
> 
> 

The problem with that is that it still doesn't solve the vertical loop 
problem, where there is no banking.

My current method of interpolation between banking values is simple 
linear interpolation.  If one control point has 0 banking, and the next 
has 90, then at t=0.5 on the bezier curve there will be 45 degrees of 
banking.  Of course, this creates the nasty side effect of the corkscrew 
problem, where one control point has 270 banking, the next has 0, so at 
t=0.5 it has 135 degrees.  Your solution would certainly fix that, but 
it doesn't solve the vertical loop problem.

With the loop, everything in the entrance and exit have 0 banking. 
Everything on the top has 180 degrees, otherwise, the track would roll 
to keep right-side up.  But if I interpolate between 0 and 180 degrees, 
it rolls, just like the picture in the original post.

Though I THINK I've found a way to fix that.  Interpolate between the up 
vectors!

At the beginning, I'll pre-calculate the orientation of the up vectors 
(Its more then just <cos(theta), sin (theta), 0> because the track could 
be heading north/south/east/west/everything in between) of the track at 
every control point, then when moving the camera, placing track ties, 
and spheres/cylinders (Faster than sphere_sweeps!) for the track, I'll 
use some method of interpolation between those up vectors.

-DJ


Post a reply to this message

From: Roman Reiner
Subject: Re: Need help figuring something out
Date: 1 May 2006 11:35:00
Message: <web.4456283afd5b7a09c80c0aa10@news.povray.org>
DJ Wiza <Kil### [at] sohcahtoanet> wrote:
> The problem with that is that it still doesn't solve the vertical loop
> problem, where there is no banking.

There's no perfect vertical loop with the characteristics you described
because with a perfect loop the entrance end exit point would be at the
same location. in the case of a "normal" loop the problems gets similar to
the corkscrew problem (the banking angles may be very close to 0/180
degrees but are not equal 0/180.

> My current method of interpolation between banking values is simple
> linear interpolation.  If one control point has 0 banking, and the next
> has 90, then at t=0.5 on the bezier curve there will be 45 degrees of
> banking.  Of course, this creates the nasty side effect of the corkscrew
> problem, where one control point has 270 banking, the next has 0, so at
> t=0.5 it has 135 degrees.  Your solution would certainly fix that, but
> it doesn't solve the vertical loop problem.

Apart from my suggestion (>180 degrees check) i think the problem could be
solved by simply changing the interpolation method.
imagine the perfect loop. in the first and the last quarter the banking is
zero and at the point where the car points straight up/down the banking
"jumpes" to 180 degree and back to zero respectivaly without any
interpolation. the more the entrance and exit point move away of each other
(the loop becomes a corkscew) the transition gets smoother and smoother
until it gets linear in the other extrem case namely a straight line with a
360 degrees drill. maybe the amount of interpolation can be extracted by
checking the distance of the entrace and exit point. this could require some
math though ;)

> Though I THINK I've found a way to fix that.  Interpolate between the up
> vectors!
>
> At the beginning, I'll pre-calculate the orientation of the up vectors
> (Its more then just <cos(theta), sin (theta), 0> because the track could
> be heading north/south/east/west/everything in between) of the track at
> every control point, then when moving the camera, placing track ties,
> and spheres/cylinders (Faster than sphere_sweeps!) for the track, I'll
> use some method of interpolation between those up vectors.
>
> -DJ

Could surely work that way as well but it sounds more difficult than my
suggestion IMHO. My version has the advantage that the interpolation needs
work anyways. You could give both approachs a try though.

Regards Roman


Post a reply to this message

From: DJ Wiza
Subject: Re: Need help figuring something out
Date: 1 May 2006 14:19:24
Message: <4456512c$1@news.povray.org>
Roman Reiner wrote:
> There's no perfect vertical loop with the characteristics you described
> because with a perfect loop the entrance end exit point would be at the
> same location. in the case of a "normal" loop the problems gets similar to
> the corkscrew problem (the banking angles may be very close to 0/180
> degrees but are not equal 0/180.

In theory, you're right.  However, No Limits is used by many amateurs 
who will use values of just 0 and 180 when making a loop.  Of course, 
this creates an oddly shaped loop that would be a bit uncomfortable to 
ride, but they do it because they don't know otherwise.

  > Apart from my suggestion (>180 degrees check) i think the problem 
could be
> solved by simply changing the interpolation method.
> imagine the perfect loop. in the first and the last quarter the banking is
> zero and at the point where the car points straight up/down the banking
> "jumpes" to 180 degree and back to zero respectivaly without any
> interpolation. the more the entrance and exit point move away of each other
> (the loop becomes a corkscew) the transition gets smoother and smoother
> until it gets linear in the other extrem case namely a straight line with a
> 360 degrees drill. maybe the amount of interpolation can be extracted by
> checking the distance of the entrace and exit point. this could require some
> math though ;)

Every bit of math I add makes a longer parsing time.  However, I 
recently made a HUGE optimization that cut the parse time of creating 
track ties immensely.  It allows the user to decide how accurate they 
want the positions of the track ties to be, and it steps along the 
beziers in steps based on that accuracy by dividing the requested 
precision by the estimated length of the bezier.  The length of the 
bezier is estimated by taking 100 steps along the bezier and adding up 
the distances between each step.

> Could surely work that way as well but it sounds more difficult than my
> suggestion IMHO. My version has the advantage that the interpolation needs
> work anyways. You could give both approachs a try though.

I just implemented my method.  It was actually extremely easy to 
implement.  Rather than taking a weighted average of two integers and 
creating a vector on that, I created two vectors, and created a weighted 
average of those.

It works.  The corkscrew problem works out, and loops work, but really 
tight loops (As in, very little lateral movement) have a slight glitch 
when it goes vertical.

I'm about to post the latest track to p.b.animations.  You'll see it there.

-DJ


Post a reply to this message

From: Daniel Nilsson
Subject: Re: Need help figuring something out
Date: 2 May 2006 14:19:15
Message: <4457a2a3@news.povray.org>
DJ Wiza wrote:
> I just implemented my method.  It was actually extremely easy to 
> implement.  Rather than taking a weighted average of two integers and 
> creating a vector on that, I created two vectors, and created a weighted 
> average of those.
> 
> It works.  The corkscrew problem works out, and loops work, but really 
> tight loops (As in, very little lateral movement) have a slight glitch 
> when it goes vertical.
 >
> I'm about to post the latest track to p.b.animations.  You'll see it there.

First I must say I like your animations, keep up the good work!

About the interpolation I think I understand the problem you have at the 
vertical point in the loop. You are just linearly interpolating the x, y 
& z values of the up-vector and than normalizing the result, right? So 
if the first vector is close to straight up and the second close to 
straight down there is a point near t=0.5 where the vector is close to 
the zero-vector before normalization and then normalization makes errors 
show up.
One way to fix the problem is to us quaternion interpolation. 
Quaternions is an extension of complex numbers to 4D and are good for 
representing rotations in 3D. Try google for "quaternion interpolation".
I found this include file that may be of interest:
http://news.povray.org/Xns940C86DC9B1D4None%40204.213.191.226

The spherical interpolation that Tim Nikias talks about in 
http://news.povray.org/44480022%40news.povray.org may also be of use to you.

Hope you solve your problems because I'm looking forward to a cool ride...

-- 
Daniel Nilsson
Long time lurker


Post a reply to this message

From: DungBeatle
Subject: Re: Need help figuring something out
Date: 2 May 2006 22:19:48
Message: <44581344@news.povray.org>
: I found this include file that may be of interest:
: http://news.povray.org/Xns940C86DC9B1D4None%40204.213.191.226

An error in that include file was corrected later:

http://news.povray.org/povray.binaries.scene-files/thread/%3CXns940E6C1F42D3FNone%40204.213.191.226%3E/?ttop=227233&toff=250


Post a reply to this message

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