Knowing two points of a rectangle, how can I figure out the other two?

前端 未结 9 1120
刺人心
刺人心 2021-01-05 01:47

Hey there guys, I\'m learning processing.js, and I\'ve come across a mathematical problem, which I can\'t seem to solve with my limited geometry and trigonometry knowledge o

9条回答
  •  抹茶落季
    2021-01-05 02:19

    It's definitely a rectangle? Then you know the orientation of the short sides (they're parallel to the line between your points), and hence the orientation of the long sides.

    You know the orientation and length of the long sides, and you know their midpoints, so it's straightforward to find the corners from there.

    Implementation is left as an exercise to the reader.

提交回复
热议问题