Find a new point on a rectangle given an angle from the center

648 Views Asked by At

I am a software engineer and I'm trying to edit some images. Trying to find a good formula to find a new point on the rectangle, I know the center x and y coordinates, the height and width of the rectangle, and the theta in the direction of the new point.

if I can find the length of the line from the center to the edge I can just take a sin and cos to get my new position. The issue I'm having is that it seems like there are a lot of special cases given different angles for whether I should be shifting it with regards to width or height etc and I was hoping that someone would have a simpler formula I could use.

Thanks a lot for taking the time to try and help me!