Results 1 to 4 of 4

Thread: [RESOLVED] How to find new width and height after rotate

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Resolved [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.
    Last edited by Developer2007; Aug 16th, 2010 at 08:02 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: How to find new width and height after rotate

    Thanks for that. You make me feel so dumb now. Stay in school kids.....

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width