Jump to content
  • Advertisement
Sign in to follow this  
subflood

Parallelogram and slopes

This topic is 4813 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

Say I have 4 sets of relations (x, y) (x, y), etc. Since I know opposite sides of a parallelogram are parallel do I have to calculate the slope 6 times to check if the relations make up a parallelogram? Or is there an easier way?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You have 4 line segments. You want to know if they form a parallelogram. Correct?

If so, then yeah it is kind of tricky because you don't know how the line segments are arranged, so you don't even know if they form a polygon. So besides checking to see if the lines are parallel you'd have to check that they form a polygon. But once you've checked that, you should know what order the 4 sides of the polygon are in. If you know the order of the line segments, then you can just check that the opposite sides are parallel. Or you can check that opposing corners have the same angle (which probably takes about the same amount of calculating).

Share this post


Link to post
Share on other sites
There is a faster and more efficient way, but it is not "easier". However, when comparing slopes, you have to deal with vertical lines. You can avoid that by checking if the cross product is close to 0 instead.

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!