Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2006-08-08 20:48:44

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Following the orientation of a path

Hi, all

I have a set of x,y points that define a curve (path) that was delivered by a Hermite polynomial.

Anyway, I need to find the rotation angle for each x,y point so that if an arrow moves along
this curve it will always point to the direction of the curve.

Here is a flash animation of what I am trying to implement  (see the sprite rotates along path)
http://www.developingwebs.net/flash/orient.php 

Any ideas,

Cheers

Offline

#2 2006-08-08 22:21:35

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

I haven't really ever made too many graphical programs, so my help may be limited. It sounds like you want your object to be facing in the direction of the tangent to your curve. I can tell you what the tangent is, at least.

You say you have a Hermite polynomial, but you didn't mention which Hermite polynomial, so I'll give you the general equation. All you need to do is take the derivative of Rodrigue's formula for Hermite polynomials:

Its derivative is

Just plug in the appropriate n for your Hermite polynomial's degree and you'll have the equation for the tangent. Ask more questions if your needs aren't satisfied with this.

Edit: After reading my post and then yours again, I don't feel that I answered your actual question. I apologize. Hopefully this might be helpful to you though, and as I said, feel free to ask for other things.

Last edited by Zhylliolom (2006-08-08 22:25:16)

Offline

#3 2006-08-08 22:31:52

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

Thank you for your answer. This is the polynomial I am using.

0ce42119aa1d269ec890b74c49fc322b.png

It sounds like you want your object to be facing in the direction of the tangent to your curve.

up That's it

Offline

#4 2006-08-08 22:39:26

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

So you're good? No further assistance is required as of now?

What are you trying to make this for? What is the end product supposed to be?

Offline

#5 2006-08-08 22:48:27

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

Actually, I am bit confused by the derivative formula you have mentioned.
This is what I was doing but I am NOT satisfied with the results I need more accuracy

dx := p1.x - p0.x;
dy := p1.y - p0.y;
theta := 180 - 180/pi * arctan2(dy,dx);

Then this theta angle is used to rotate the points of the circle accordinly on the Z axis in order to follow the path.
The problem is that I get some strange rotation values throughout the path.

I am trying to produce a circle to extrude along a spline in 3D space

Last edited by akoutsou (2006-08-08 22:50:31)

Offline

#6 2006-08-08 22:54:17

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

I'm a bit confused about your equation myself wink.

Could you post a link to some information about it? (It looks like it's from a Wikipedia page, so if it is just post that link)

Offline

#7 2006-08-08 22:55:59

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

http://en.wikipedia.org/wiki/Cubic_Hermite_spline

Offline

#8 2006-08-08 23:13:29

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

Oh, the problem is that we are considering two entirely different things. The Hermite polynomials I was talking about are the kind from differential equations.

I've never heard of this "spline technology", but maybe I can try to help still. I have questions though. What do the start/end points and the start/end tangents do for us? Is this something that creates a curve defined by one polynomial between two points, then another curve defined by another polynomial between the next points, and so on?

Offline

#9 2006-08-08 23:15:48

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

Once again thank you for your answer. Yes, that it. You have a number of start/end points and start/end tangents and then you produce a 2D curve (that was the initial set of x,y points coords I was talking about)

Last edited by akoutsou (2006-08-08 23:16:29)

Offline

#10 2006-08-08 23:20:23

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

What role do the tangents play in the construction of the curve though? What exactly is the equation

telling us? In other words, how do we know what to draw from the equation?

Offline

#11 2006-08-08 23:23:45

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

p.x := round((h1 * p1.x) + (h2 * p2.x) + (h3 * t1.x) + (h4 * t2.x));
p.y := round((h1 * p1.y) + (h2 * p2.y) + (h3 * t1.y) + (h4 * t2.y));

This is what you actually drawing a point derived from x,y coords of p1,t1,t2,p2  and then next set starting from last point p2 t3 t4 p3

Offline

#12 2006-08-08 23:35:37

Zhylliolom
Real Member
Registered: 2005-09-05
Posts: 412

Re: Following the orientation of a path

I think I'm too tired to understand anything right now(it's 6:30 AM now, I've been kept up by an intense theorem). Sorry. There are a few members on this forum who are much more accomplished programmers than I'll ever be, and I think that they will be better suited to help you out. Maybe after I have rested my mind will be working better and I'll be a better help. Until then, good luck.

Offline

#13 2006-08-09 00:32:52

akoutsou
Member
Registered: 2006-08-08
Posts: 8

Re: Following the orientation of a path

Thanks mate.

Offline

Board footer

Powered by FluxBB