Calculate rectangle vertices

851 Views Asked by At

I have a programming problem and I've forgotten some of my math rectangle formulas. I have to make a program that creates a rectangle that isn't parallel to the X and Y axis, I assume this means a diagonal rectangle in the first quadrant of a Cartesian graph.

My inputs are the following:

  • coordinates of the vertex closest to the X axis and the origin
  • angle the long side makes with relation to the X axis.
  • area of the rectangle
  • length of the long side

The outputs expected are the following:

  • length of the short side,
  • coordinates of all the rest of the rectangle's vertices.

Given these input how do I calculate the output mentioned?

2

There are 2 best solutions below

0
On

Well, to calculate the length of the rectangle's short side, you can do the area divided by the length of the rectangle's long side. Then, if you use the distance formula, you can say if the starter coordinate is (0,0) and the length of the short side is, say, 3, you can do $3 = \sqrt{(0-x_2)^2+(0-y_2)^2}$ and then do, say, $9 = (0-x_2)^2+(0-y_2)^2$. I'm not sure how to proceed from there, I'll continue thinking about it.

4
On

Hope the following can be of some help:enter image description here

For example, $x_S = h - (\dfrac {A}{L}) \sin\theta$. All other co-ordinates can be done in the similar fashion.

enter image description here All the lengths of the line segments can be found and hence the x-coordinates of S, Q and R (in terms of $h, k, A, L, \theta$). The y-coordinates can also be found by drawing appropriate dotted vertical lines.