Hi,
I want to draw rectangle beween two points with arbitary width.when i change starting point or end point rectangle also need to be change.It looks like the below url image https://i.stack.imgur.com/vyQD2.gif. Please any one provide suggestions to how to acheive this.Thanks in advance.
Rajkiran SwainPosted Jun 15, 2017, 5:58 AM
We need to calculate 2 values, the shift on the x axis and the shift on the y axis for each of the 4 corners. Which is easy enough.
The dimensions of the line are:
Now the x shift (let's call it xS):
To find the length of the line, use Pythagoras's theorem:
Now you have the x shift and y shift.
And there you go! (Those coordinates are drawn counterclockwise, the default for OpenGL)