Dear Forum,
Hoping someone can help me with a little trig and geometry
In the attached pic the grey rectangle has been rotated by @ degrees, the red dotted box is then constructed around it to exactly enclose it.
given the dimensions of the bounding box and the angle of rotation, I want to calucate the size of the original rectangle (and hence its coordinates)
i.e. given w, h and @, what are x, y (and therby a, b, c, d)?
sin @ = c / x = b / y = S
cos @ = a / x = d / y = C
tan @ = c / a = b / d = T
w = a + b
y = c + d
=>
w = xC + yS
x = (w - yS) / C
h = xS + yC
x = (h - yC) / S
=>
(w - yS) / C = (h - yC) / S
S(w - yS) = C(h-yC)
Sw - ySS = Ch - yCC
Sw - Ch = ySS - yCC
Sw - Ch = y(SS - CC)
y = (Sw - Ch) / (SS - CC)
The problem is that at @=45, SS-CC is 0!
So I've trying to find an alternative method of representing this equation.
plotting y against @ for 0-90 degrees, gives the graph in graph.png - which shows a nice smooth curve but with the asymptotic problem at 45 degrees.
Would be quite happy with an equivalent but alternate solution which works well for say, angles < 30 and > 60. (which is what i'm expecting, i.e. some equation dividing by sin or cos, given the /0 at 0 or 90degrees)
Thank you!


LinkBack URL
About LinkBacks

