Trigonometry, Rotation

Posted on 2006-04-24
Last Modified: 2012-08-13
Hi experts,

I'm looking for some help with trigonometry, more specifically rotating 4 points around a centre point.

I have a rectangle,  with centre point 0,0 and want to rotate this counter-clockwise a variable number of degrees.  Say 45 degrees for example.  The 4 points on the rectangle are 6,3 : -6,3 : -6,-3 : 6,3.

I know this involves sin and cos but I cannot figure out how to use these functions.

So, simply put - how do i work out the new coordinates for a rotation of 45 degrees for the above coordinates.

Any help would be appreciated.

Thanks in advance,
Question by:inema
    LVL 25

    Expert Comment

    New_Y = Old_Y * Sin ( angle )
    New_X = Old_X * Cos ( angle )
    LVL 25

    Expert Comment

    So, rotating the point (6,3) CCW by 45°, would be result in the point:

      ( 6*Cos(45), 3*Sin(45) )  =~  ( 4.2, 2.12 )
    LVL 22

    Expert Comment

    Close but not quite, InteractiveMind.

    New_Y = Old_Y * cos( angle ) + old_x * sin(angle)
    New_X = Old_X * Cos ( angle ) - old_y*sin(angle)

    Notice that when angle=0, the cos is 1 and the sin is 0, so new_x = old_x and new_y = old_y
    LVL 1

    Author Comment

    I have read up a bit more about this:

    Radius, from 0,0 to 6,3, using pythagoras' = 6.7
    sqrt(6^2 + 3^2)
    sqrt(45) = ~6.7

    new_X = radius * cos (angle)
    new_X = 6.7 * cos(45)
    new_X = 2.1

    new_Y = radius * sin (angle)
    new_Y = 6.7 * sin(45)
    new_Y = 6.4

    so 6, 3 rotates to 2.1, 6.4 ?
    Is this correct?

    The other numbers are confusing me because of all this quadrant and negative number stuff, anyone have any ideas?

    Thanks again,
    LVL 1

    Author Comment

    Forgot to add...

    First i got the previous angle using Tan (angle) = Opposite / Adjacent

    Tan (angle) = 3/6
    Tan (angle) = 0.5
    Angle = ~27 degrees

    So new angle to work with is 27+45 = 72 degrees

    I then used
    radius * cos (new angle)
    radius * sin (new angle)

    Does this make sense? It looks correct on a poorly drawn excel spreadsheet i made :)
    LVL 22

    Expert Comment

    inema, my expressions work.

    New_Y = Old_Y * cos + old_x * sin
    New_X = Old_X * Cos - old_y*sin

    new_x^2 + new_y^2 = (old_y*cos + old_x*sin)^2 + (old_x*cos - old_y*sin)^2
     = old_y^2 * cos^2 + 2*old_x*old_y*cos*sin + old_x^2*sin^2 + old_x^2*cos^2 - 2*old_x*old_y*cos*sin + old_y^2*sin^2
    = old_y^2*(cos^2 + sin^2) + (2 - 2)*(old_x*old_y*cos_sin) + old_x*(cos^2 + sin^2)
    new_x^2 + new_y^2 = old_y^2 + old_x^2
    LVL 43

    Expert Comment

    You ought to have a look at polar and cartesian co-ordinates.  At present you are in cartesian co-ordinates (point specified by distance on x and y axes).  Polar co-ordinates are the distance and angle from a defined point/axis.  To rotate in polar co-ordinates about the center point all you do is add the angles together.

    if the point is 2.5, 30 degrees after rotating by 45 degrees the point is now 2.5, 75 degrees.
    LVL 1

    Author Comment

    I used your expression for the top right point (6,3) and it worked.  However when I try the same expression for negative numbers the results are off.

    I read a bit about quadrants and that they change positives and negatives depending on which one you are working in.  Can anyone elaborate?

    Thanks for your input, however I don't think polar co-ordinates will be beneficial as I have a cartesian map to work with - it might be one unneccessary complication too many ;)
    LVL 43

    Accepted Solution

    Two functions - one converts cartesian to polar and one converts polar to cartesian
    LVL 1

    Author Comment

    okay, after doing some research on the polar/cartesian conversions i've found that this is what i was doing with my original calculations.

    Thanks for the help guys.  Points go to Andy.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Excel - Average versus AverageA = Why use AverageA? 2 52
    A problem of optics 16 105
    Perecntage 4 41
    Simplify expression 3 53
    How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I gu…
    Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now