# Width of object after rotation and finding distance from perpendicular • ### Question

• I have a rectangle. This can be freely rotated around the centrepoint. How do I find the width of the rectangle after rotation (ie: the width of the diamond shape)?

So now that it is rotated, I need to find the perpendicular distance of the cursor from the rotated edge. How do I do that?

Thanks

edit: I suppose that one pair of corners will be at the max/min horizontal points and one pair at the max/min vertical points after rotating so trigonometry could be used to find the height and width after rotation, based on these, and the angle, which should be known.
Wednesday, December 16, 2009 11:42 AM

• Hi Peter,

you can calculate the Width with based on sin/cos and the trigonometry functions of the great Pythagoras. :-)

Imagine your Rectangle is 100 Width, so as you rotate in center your radius is 50.

Now image you rotate about 45°.

you can use the formula sin alpha = opposite kathete (i don't know the exact english word for it) / hypotenuse

that means sin of 45 = oppositeKathete / 50

with that you can calculate your oppositeKathete and thats your width. Two times and you have it (it was radius-based)

Friday, December 18, 2009 2:37 AM

### All replies

• Hi Peter,

you can calculate the Width with based on sin/cos and the trigonometry functions of the great Pythagoras. :-)

Imagine your Rectangle is 100 Width, so as you rotate in center your radius is 50.

Now image you rotate about 45°.

you can use the formula sin alpha = opposite kathete (i don't know the exact english word for it) / hypotenuse

that means sin of 45 = oppositeKathete / 50

with that you can calculate your oppositeKathete and thats your width. Two times and you have it (it was radius-based)

Friday, December 18, 2009 2:37 AM
• Transform the vertices to screen-space and use the transformed values to calculate it in 2D

Or if it's not visible, cast them onto some axis-aligned plane so that one of the components may be ignored and the other two represent the vertice in 2D

Monday, January 4, 2010 12:02 PM