POV-Ray : Newsgroups : povray.advanced-users : How to calculate Banking of Bezier-Splines...? Server Time
18 Oct 2026 20:08:54 EDT (-0400)
  How to calculate Banking of Bezier-Splines...? (Message 1 to 14 of 14)  
From: Tim Nikias
Subject: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 06:04:54
Message: <3C77775E.C685782E@gmx.de>
The problem is actually pretty simple. Using a simple
cubic bezier-spline as input (2 Nodes, 1 Direction for each
node = 4 Vectors), I want to calculate the outward
pointing direction of any point on the spline.

Think of the centrifugal-force when driving around a
corner. That's what I want to calculate.

I know that Chris Colefax has done a macro for
splines, but I can't see through his algorithms. Any
suggestions, reference PDF-Files, or whatever?

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From:
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 06:31:46
Message: <lrue7uo02l8bpo1vgdj7o3b5ld3it7biiu@4ax.com>
On Sat, 23 Feb 2002 12:05:02 +0100, Tim Nikias <tim### [at] gmxde> wrote:
> The problem is actually pretty simple. Using a simple
> cubic bezier-spline as input (2 Nodes, 1 Direction for each
> node = 4 Vectors), I want to calculate the outward
> pointing direction of any point on the spline.

With 4 vetors you have to calculate three equations x(t), y(t), z(t).
It is so called parametric curve. Direction of this curve for particular t
(tangent at this point) is IIRC value of derivative at this point. Look at
http://www.google.com/search?q=derivative+parametric+tangent

ABX


Post a reply to this message

From: Rune
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 06:59:34
Message: <3c778426@news.povray.org>
"Tim Nikias" wrote:
> The problem is actually pretty simple.

> Think of the centrifugal-force when driving around a
> corner. That's what I want to calculate.

Assuming you have a spline function Spline(T) where T is the input
interpolation value, I think you can do it like this:

(Spline(T)-(Spline(T+0.001)+Spline(T-0.001))/2)

Some ASCII art to illsustrate the code:

          *****P*****
     *****           ******
   *A          C           B*
 **                          **
*                              *

P is Spline(T), A is Spline(T-0.001), B is Spline(T+0.001), C is the average
of A and B. Then you just find the vector from C to P.

Is this what you need, or did I understand you wrong?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Tim Nikias
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 07:21:03
Message: <3C778937.91C884D6@gmx.de>
You were right, that is what I am looking for.
But I already did come up with this method, there
was just one problem:

Bezier-Splines stay longer on the beginnings and
ends of a curve, and when using very small values
for the difference between the Ts, the three
positions may line up, resulting in weird centrifuges.

So I'm looking for possibilites of somehow detecting
which centrifuge there would be, if there would be a
more distinct curvature...


> Assuming you have a spline function Spline(T) where T is the input
> interpolation value, I think you can do it like this:
>
> (Spline(T)-(Spline(T+0.001)+Spline(T-0.001))/2)
>
> Some ASCII art to illsustrate the code:
>
>           *****P*****
>      *****           ******
>    *A          C           B*
>  **                          **
> *                              *
>
> P is Spline(T), A is Spline(T-0.001), B is Spline(T+0.001), C is the average
> of A and B. Then you just find the vector from C to P.
>

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From: Tim Nikias
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 07:24:04
Message: <3C7789EC.8C504189@gmx.de>
The problem is, I don't need the tangent (I was able
to figure that out, still, thanks for the reply). I need
to find the centrifugal-force, and I don't know if
tangents actually help me there...


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From: Rune
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 07:40:05
Message: <3c778da5@news.povray.org>
"Tim Nikias" wrote:
> Bezier-Splines stay longer on the beginnings and
> ends of a curve

I'm not sure what you mean by "stay longer".

> and when using very small values for the difference
> between the Ts, the three positions may line up,
> resulting in weird centrifuges.

I don't understand. If the three points line up it's either because there's
no centrifugal force at that point or because you're using so small
differences in T values that POV-Ray don't give you precise enough results.
Can't you just use larger differences in T values?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Tim Nikias
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 09:34:39
Message: <3C77A883.A442B0E3@gmx.de>
>
> I'm not sure what you mean by "stay longer".
>

If you place spheres on a bezier-spline (just an example),
they will clutter up on beginnings and ending of a section.
Each section is defined by the already mentioned 2 Nodes
and their 2 directions. When using tiny T amounts, the
calculated positions may be very close to each other,
resulting in no centrifugal force.
It's like looking at a millimeter of a 100 meter curve...

>
> I don't understand. If the three points line up it's either because there's
> no centrifugal force at that point or because you're using so small
> differences in T values that POV-Ray don't give you precise enough results.
> Can't you just use larger differences in T values?
>

In general, a section has some sort of curvature, and I would
like to use some general sort of the centrifugal force.

Its not very easy to explain...

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From: Rune
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 10:26:00
Message: <3c77b488@news.povray.org>
"Tim Nikias" wrote:
> If you place spheres on a bezier-spline (just anexample),
> they will clutter up on beginnings and ending of a section.

That really depends on the lengths of the tangents (the two direction
vectors). The way I usually use bezier splines, the spheres are not
cluttered up around the ends. And thinking about it, when they *do* clutter
up around the ends due to short tangents, it's actually because the
curvature is higher near the ends... The curved parts usually have denser
spheres in general.

> It's like looking at a millimeter of a 100 meter curve...

As I said, why not use bigger differences in T values?

> In general, a section has some sort of curvature, and I would
> like to use some general sort of the centrifugal force.

See above.

> Its not very easy to explain...

Hmm, apparently not... :(

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 10:52:38
Message: <chrishuff-5AD572.10522923022002@netplex.aussie.org>
In article <3C7789EC.8C504189@gmx.de>, Tim Nikias <tim### [at] gmxde> 
wrote:

> The problem is, I don't need the tangent (I was able
> to figure that out, still, thanks for the reply). I need
> to find the centrifugal-force, and I don't know if
> tangents actually help me there...

Find the tangent at the point, and the tangent a little distance ahead. 
The amount of force will be related to the angle between these tangents 
(normalize them, and the dot product will be the cosine of the angle) 
and the distance between the two points on the spline.
Find the angle first, if it is too small just don't bother with the 
force calculations.
A vector perpendicular to the direction of the force can be found by 
taking the cross product of the two tangents. You can then find the 
direction of force by getting the cross product of this vector with the 
first tangent.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Tim Nikias
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 16:59:34
Message: <3C7810D0.3D0DECEF@gmx.de>
>
> ...

Very elaborate, thank you!

I don't want to calculate the actual force, but only the
centrifugal-vector. When thinking about your advice
with the cross-products etc, I'm wondering, if
I can be 100% sure, that the resulting vector
will be the centrifuge, or perhaps may be the
inverse (which would also be perpendicular)?

I'll try. Thanks for your help!

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From: Tim Nikias
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 17:01:45
Message: <3C781153.ACCF0564@gmx.de>
Christopher Hames Huff has replied and given me
some mathematical insight with cross-products
and dot-products. I'll guess going from there, I'll
find a solution to what I am heading for. Your
replies are still thanked for. Its worth noting that
you actually spend time on others problems...

Thank you very much!

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html


Post a reply to this message

From: Rune
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 18:51:30
Message: <3c782b02@news.povray.org>
"Tim Nikias" wrote:
> Christopher Hames Huff has replied and given me
> some mathematical insight with cross-products
> and dot-products. I'll guess going from there, I'll
> find a solution to what I am heading for.

I didn't know that was your problem. :)

It's worth noting that the solution I suggested still is valid. Chris Huff
suggested a method involving angles and checking the spline at four
different places (in order to get two tangents), while my method doesn't
involve angles (or dot products) and needs only the spline tested at three
places.

But you basically get the same thing. It sounds like your problem was that
you wanted the centrifugal force vector calculated to be perpendicular to
the tangent of the spline at that point. Using my own example as basis this
is very easy as you already have the tangent, which is (B-A). Now you just
need to adjust the vector (P-C) so that it's perpendicular to the vector
(B-A). POV-Ray 3.5 has a macro to do that, called VPerp_Adjust. The
VPerp_Adjust macro do automatically the things with vcross that Chris Huff
talked about. You can read about the macro in the documentation.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 23 Feb 2002 22:09:46
Message: <chrishuff-12FCA8.22093623022002@netplex.aussie.org>
In article <3c782b02@news.povray.org>,
 "Rune" <run### [at] mobilixnetdk> wrote:

> It's worth noting that the solution I suggested still is valid. Chris Huff
> suggested a method involving angles and checking the spline at four
> different places (in order to get two tangents), while my method doesn't
> involve angles (or dot products) and needs only the spline tested at three
> places.

Actually, my method only needs 3 points tested...I was just trying to 
simplify my explanation when I said 2 tangents. It would probably work 
better with 4 though, less opportunity for precision error. The basic 
idea is to look ahead to two points to estimate the direction and amount 
of curvature of the spline, find the normal of the plane the spline is 
in at that point (the three points form a triangle), and get a vector 
perpendicular to that, which will be perpendicular to the spline and in 
the "outward" direction of curvature.


> But you basically get the same thing. It sounds like your problem was that
> you wanted the centrifugal force vector calculated to be perpendicular to
> the tangent of the spline at that point. Using my own example as basis this
> is very easy as you already have the tangent, which is (B-A). Now you just
> need to adjust the vector (P-C) so that it's perpendicular to the vector
> (B-A). POV-Ray 3.5 has a macro to do that, called VPerp_Adjust. The
> VPerp_Adjust macro do automatically the things with vcross that Chris Huff
> talked about. You can read about the macro in the documentation.

I have a sneaking suspicion our two solutions are mathematically the 
same, just arrived at differently...
VPerp_Adjust() is defined as:
vnormalize(vcross(vcross(Axis, V), Axis))
Which is basically what I wrote. Ah, well...

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Rune
Subject: Re: How to calculate Banking of Bezier-Splines...?
Date: 24 Feb 2002 05:18:44
Message: <3c78be04@news.povray.org>
"Christopher James Huff" wrote:
> The basic idea is to look ahead to two points to
> estimate the direction and amount of curvature of
> the spline

I think it's better if the point in question is the middle one of the three
points rather than the back one.

> I have a sneaking suspicion our two solutions are
> mathematically the same, just arrived at differently...

The same, or very close.

> VPerp_Adjust() is defined as:
> vnormalize(vcross(vcross(Axis, V), Axis))
> Which is basically what I wrote.

My point exactly. I use that macro a lot by the way - it's really useful. :)

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

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