[RESOLVED] How to find new width and height after rotate
Hey everyone,
What I am trying to do is rotate a string (or rectangle) 45degrees and find the new height and width after the string has been rotated.
Basically the width and height of the rectangle draw area the new 45degree string takes.
Could someone PLEASE help. My math skills ain't so great......
Thanks in advance.
Re: How to find new width and height after rotate
It's simple trigonometry. The string occupies a rectangle. As you rotate the text, the long side of that rectangle becomes the hypotenuse of a right triangle. You know the length of that hypotenuse and you know the angle it makes with the horizontal and vertical axes. It's s single trig function to calculate the length of the vertical side of that triangle. You then do the same for the right triangle that has the short side of the string's bounding rectangle as the hypotenuse and then add the two results together. The Math class is where you'll find .NET trig functions.
Draw a picture and you'll see how simple it is. Just because you're writing code on a computer doesn't mean that you can't pick up pen and paper.
Also, keep in mind that this is a VB.NET forum, not a maths form. This is not the place to learn basic trigonometry. Once you have an algorithm, we can help you implement it in VB.NET if required but coming up with the algorithm is not a VB.NET issue. In fact, it's not even a programming issue because algorithms should be able to be performed manually on the same problem to produce the same result.
Re: How to find new width and height after rotate
Thanks for that. You make me feel so dumb now. Stay in school kids.....
Re: [RESOLVED] How to find new width and height after rotate
It wasn't my intention to make you feel dumb, but to realise that many problems are much simpler than they appear. We are visual creatures so don't ever be afraid to draw a picture to illustrate a problem because, if you do, things often become clear that previously weren't.
It's also important to understand what is a programming problem and what isn't. Many people try to write code before they even really understand what the problem is that they're trying to solve. The solution to the problem should come first. Only when you have the solution should you think about writing code. That code implements the solution, not the problem.