Solved

How to know curve direction?

Posted on 2002-06-03
10
194 Views
Last Modified: 2010-04-06
Dear experts,

There is a closed cutve consisting of 12 x,y points. How can I know that curve is in clockwise or anticlockwise direction?

Please help me. It's urgent.

Thanks.

0
Comment
Question by:mansan
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 30

Expert Comment

by:weed
Comment Utility
Look at the graph points. If you have to, plot them on paper in the order theyre in.
0
 

Author Comment

by:mansan
Comment Utility
Hello weed,

Yes, by plotting the curve on paper I can know the curve direction, but I'm making a project in c++ to convert a 2D image in 3D. In that I'm facing this problem so I need a  routine to know curve direction.

any idea?

Thanks.
0
 
LVL 30

Expert Comment

by:weed
Comment Utility
Ahhh...gotta specify stuff like that in the question.
0
 
LVL 2

Expert Comment

by:shlezman
Comment Utility
The alorithm goes like that you'll have to figure out how to implement it, sorry
1. connect the dots.
2. draw a vertical line to the one of the segments.
3. if the vertical line crosses the curve odd number of times to the right then it's a clockwise, if it crosses odd number of times to the left, it counterclockwise.
       ______
      /      \
    ^ |------|----
      \______/

the ^ shows the real direction
the ---- line is the vertical line
sorry for the too simplified drawing.

good luck
0
 
LVL 3

Expert Comment

by:TheRedGuy
Comment Utility
Surely this is a question of perspective on the curve itself? How can one say whether a curve is going in a particular direction? Unless of course the order of the twelve co-ordinates dtermines the direction but you have not stated this!!

If that is your intention, then can you not simply take account of the co-ordinates that you are plotting? For a 2D curve, if

x is increasing, while y is decreasing
OR
x is decreasing and y is increasing

then you are plotting in a clockwise direction, while if

x is increasing while y is increasing
OR
x is decreasing while y is decreasing

then you are plotting in an anti-clokwise direction.

Having said that, the question of whether either x or y is increasing or decreasing would be relative to the origin of the curve!

I think you need to explain a little more what you are after!

btw, is this a homewrok question???
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:shlezman
Comment Utility
I guess it is homework or some kind of riddle on graphics and polygons.
This sounds like a very well known and basic polygon algorithm, assuming curve=polygon otherwise there is no meaning to direction.
The polygon can take any closed shape and it's line can cross itself like the number "8", there are two ways to describe a polygon with the shape of "8", very much like writing it, for example if you start writing it from the bottom point, you can continue to the right or to the left. If you continue drawing to the right you'll get counterclockwise description, continuing to the left will get you clockwise shape.
Hope it was clear.
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
Comment Utility
The sum
 y0*x1-y1*x0
+y1*x2-y2*x1
+y2*x3-y3*x2
...
+y10*x11-y11*x10
+y11*x0 -y0 *x11
will be positive for clockwize points, and negative for counterclockwize points,
assuming thr curve does not intersect itself
0
 

Author Comment

by:mansan
Comment Utility
Hi ozo,

This method is really working. But when I compute, sum is positive for counterclockwise & negative for clockwise.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Sorry, I got x and y mixed up.
0
 

Author Comment

by:mansan
Comment Utility
Ozo Thanks for your help.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I've been using this technique since Adobe CS2, and it should work with any version of Illustrator that includes the appearance panel. In this tutorial we'll create a button using the appearance panel in Adobe Illustrator, and then save it as a r…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now