Jump to content
  • Advertisement
Sign in to follow this  
Talyrond

CAD programmer, in search of help!

This topic is 4903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a long shot guys!! Hi, I know this is a games forum but there is a certain amount of cross over between CAD and Games programming and to be honest there is just not a lot of info on the Web for us poor old CAD programmers! Any way, if anyone can help that would be great, my problem: I have a closed curve (not self intersecting) that is made up of a combination of Line segments and arcs, in the Cartesian plane. I need to know the direction of the closed curve: CW or CCW. I have found info on polygons, this uses the cross product etc to determine the direction. But I have no idea where to start when I introduce arc!! Any idears: Cheers Talyrond

Share this post


Link to post
Share on other sites
Advertisement
Direction isn't an inherent property of a loop. Only when something is moving along the path defined by the loop does direction come into play, like in a circuit loop. Now if you're referring to the direction in which the loop is stored or rendered in CAD, then that's perfectly OK. What I would do is use the fact that there are 360° in a closed loop, and then iterate each piece of the loop. Start at the first piece. If the next piece turns "left" relative to the direction of the previous piece, then subtract that angle from your total. If it goes "right", then add that angle. Iterate all the pieces like that until you finish. In the end your sum should ideally be -360 (CCW) or +360 (CW), but in practice just checking if it's negative or positive will suffice. It also doesn't matter if your piece is a line or an arc, just use the start and end points to define a straight direction.

Share this post


Link to post
Share on other sites
Zipster, appreciate you taking the time out to respond to my post

You are quite right, the context I am talking about is when moving along the path!
Now I just had a quick play on my CAD system and draw a loop and measured the angles. I think the loop only adds up to 360° if each arc is tangential to each other, does this sound right to you?

Share this post


Link to post
Share on other sites
If you treat an arc like a straight line between its start and end point, then what I said should still hold true. Just remember to measure the turn angle from the current direction you were going in. So after you make a "turn", you either add or subtract the turn angle but you are now going in a new direction.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!