[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


How to know curve direction?

Posted on 2002-06-03
Medium Priority
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.


Question by:mansan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
LVL 30

Expert Comment

ID: 7051440
Look at the graph points. If you have to, plot them on paper in the order theyre in.

Author Comment

ID: 7052908
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?

LVL 30

Expert Comment

ID: 7052918
Ahhh...gotta specify stuff like that in the question.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Expert Comment

ID: 7053298
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

Expert Comment

ID: 7056472
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
x is decreasing and y is increasing

then you are plotting in a clockwise direction, while if

x is increasing while y is increasing
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???

Expert Comment

ID: 7057117
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.
LVL 84

Accepted Solution

ozo earned 150 total points
ID: 7060360
The sum
+y11*x0 -y0 *x11
will be positive for clockwize points, and negative for counterclockwize points,
assuming thr curve does not intersect itself

Author Comment

ID: 7061500
Hi ozo,

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

Expert Comment

ID: 7063273
Sorry, I got x and y mixed up.

Author Comment

ID: 7063784
Ozo Thanks for your help.

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
Suggested Courses

656 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