Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
21 May, 2013, 00:06:07 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2 3   Go Down
  Print  
Author Topic: Rotation- How does it work?? -  (Read 1031 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
3rik
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 02 April, 2013, 22:45:02
Date Registered: 09 August, 2011, 04:04:54
Location: Right over there.
Posts: 92


Total Post Ratings: +8

View Profile
« on: 13 March, 2012, 05:18:03 »
+1

First of all, I have no idea what math teachers would say about any of this. I was playing around with some stuff, and I stumbled upon it. I read a few things to confirm I was right.

 There are ways of looking at it: rotating the coordinate system or rotating all the points. I think the second way is a bit more intuitive. That’s also the way I found it.



This is the basic setup for rotating a point.

First, we need to describe the point you want to rotate relative to the point of rotation and in terms of an angle from standard position.

Let’s say the original point has coordinates of (xi, yi) and the point of rotation has coordinates of (xcenter, ycenter).

Since unit circle trigonometry is based off a circle at the origin, let’s temporarily translate everything to the origin. Since we are working based on how the points are relative to the point of rotation and not a “fixed” point, we can move the whole system as long as we move it back. To do this, all we have to do is subtract (xcenter, ycenter) from both points. This puts the point of rotation at the origin and the other point at (xi- xcenter, yi - ycenter).

When you rotate an object around a point, the points are always the same distance from each other. This means if you draw a circle with the point of rotation at the center and the point you want to rotate on the circle, the rotated point will also be on the circle. Since we know the coordinates of the two points, we can use the distance formula to find this distance.

√((xi - xcenter)2 + (yi - ycenter)2)

Now by dropping a right triangle down from the point, we can find the angle between the point and standard position.

tan(θ) = o / h

tan(θ) = (xi - xcenter)/(yi - ycenter)

θ = arctan(xi - xcenter)/(yi - ycenter)

Now we have everything needed to express the original point using angles.

(Distance*cos(θ), Distance*sin(θ))

To rotate the point, just add the desired angle of rotation.

Since we have to move everything back to their original position, we need to add (xcenter, ycenter)

To put everything together, you would end up with these equations:

xnew = √((xi - xcenter)2 + (yi - ycenter)2)*cos(arctan(xi - xcenter)/(yi - ycenter)+ θrotation)+ xcenter

ynew = √((xi - xcenter)2 + (yi - ycenter)2)*sin(arctan(xi - xcenter)/(yi - ycenter)+ θrotation)+ ycenter

where (xnew, ynew) is the rotated point.

This looks terrible and is a pain to type so let’s simplify it. According to the linear combination of sine and cosine, a*sin(θ)+b*cos(θ)= √(a2+ b2)*cos(θ - arctan(b/a)).
The second half shows a very near resemblance to our two equations.

The shifts on the ends of the equations wouldn’t matter because if the above statement is true wouldn’t a*sin(θ)+b*cos(θ) + 5= √(a2+ b2)*cos(θ - arctan(b/a)) +5?

Starting with the x equation, a would be yi - ycenter because it is on the bottom of the fraction in the arctan.

That means that b is xi - xcenter

In this case we need to make θ =-θrotation so we can change the sign in front of the θrotation (a double negative)

Also because cos(θ)= cos(-θ) we can then distribute a negative through

xnew = √((xi - xcenter)2 + (yi - ycenter)2)*cos( (-θrotation)- arctan(xi - xcenter)/(yi - ycenter))+ xcenter

now that it matches the formula we can write it as

xnew = (yi - ycenter)*sin(-θrotation) + (xi - xcenter)*cos(-θrotation)  + xcenter

Because cos(θ)= cos(-θ) and -sin(θ)= sin(-θ) it can be written like

xnew = (xi - xcenter)*cos(θrotation) - (yi - ycenter)*sin(θrotation) + xcenter

It’s a similar process for the ys but we need to change the sine into a cosine

cos(θ)= sin(90-θ) because a right triangle’s angles add up to 180 and one is already 90 (pi and pi/2 if you prefer)

so in this case we need 90-θrotation instead (the negative distributes into the arctan but we need that negative anyway)

now that the sine is a cosine we can do the same thing as last time.

ynew = (yi - ycenter)*sin(90-θrotation) + (xi - xcenter)*cos(90-θrotation)  + ycenter

Now we can switch the sines (punny)

ynew = (yi - ycenter)*cos(θrotation) + (xi - xcenter)*sin(θrotation)  + ycenter

In the end these are the equations

xnew = (xi - xcenter)*cos(θrotation) - (yi - ycenter)*sin(θrotation) + xcenter

ynew = (yi - ycenter)*cos(θrotation) + (xi - xcenter)*sin(θrotation)  + ycenter

These are similar to the equations in the Wikipedia article (except those are for rotating around the origin).

To use these equations just plug in the coordinates of the points and make θrotation how much you want to rotate it by.

Just so you know it works to put other parametric equations in for (xi, yi) to rotate all the points in the equations thus rotating the equations

If anything needs clairification, I’m happy to explain. Once again I explored this by myself so I don’t know how it is taught in schools.

Logged

Userbars
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.239 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.