Parallelogram and slopes

Started by
1 comment, last by JohnBolton 18 years, 7 months ago
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?
Advertisement
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).
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement