Posts ID:153765 Creations
 ID:153765   Feb 9 2003, 4:27 pm How does one determine the new location of an object that is set to rotate around an origin not centred on the object? I know it has something to do with arc length, but that was in the first semester of grade 12, and man, it's been one and a half years since then, so you certainly can't expect me to remember that. ;-)
 #1 Feb 9 2003, 5:21 pm hmm... Isn't it something like: y = r*sin(a) x = r*cos(a) ...where r=radius, a=angle, x=x-coordinate, y=y-coordinate. I could be wrong...
Spuzzum wrote:
How does one determine the new location of an object that is set to rotate around an origin not centred on the object? I know it has something to do with arc length, but that was in the first semester of grade 12, and man, it's been one and a half years since then, so you certainly can't expect me to remember that. ;-)

Well, first you'd start out like this (in pseudocode:
 ```var/newx = rotate_x(x-pivotx, y-pivoty, angle) + pivotxvar/newy = rotate_y(x-pivotx, y-pivoty, angle) + pivoty ```
The rotation formulas should be fairly simple. Assuming the angle goes clockwise, they'll be thus:
 ```rotated_x = x'*cos(angle)+y'*sin(angle)rotated_y = y'*cos(angle)-x'*sin(angle) ```
Therefore your formula should look like this:
 ```var/newx = (x-pivotx)*cos(angle) + (y-pivoty)*sin(angle) + pivotxvar/newy = (y-pivoty)*cos(angle) - (x-pivotx)*sin(angle) + pivoty ```

Lummox JR
 #3 Feb 9 2003, 8:58 pm In response to Lummox JR (#2) ...thou art scaring me. ;-)
 #4 Feb 9 2003, 10:56 pm In response to Lummox JR (#2) Being from Missouri (well, not really), I was wondering if you could explain the logic behind the formulas. Just because I absolutely suck at math doesn't make me one who would use a formula without understanding it, after all. =) Of course, you don't have to -- I know you have better things to do than to teach mathematics to some Canadian who really should have been paying more attention in school. ;-) (You can probably safely assume that I have an upper level of understanding of math, however -- I did take entry-level Calculus in school, and I didn't do too bad (relatively speaking to my normal suckiness) either.)
In response to Lummox JR (#2)
Lummox JR wrote:

Well, first you'd start out like this (in pseudocode:
 ```dhfjkhlsjdhlukhsnkldjvhljnlsemnlkjhvlkbslkfdhjkashdkjhlasjhlkjnclkjhakjwnlkjnadjfhgwliuahl ```
The rotation formulas should be fairly simple. Assuming the angle goes clockwise, they'll be thus:
 ```jkjflksdjsghjagkjhgwkhbckahjbkdhgawhskljshlajhdlsjdhljdhdhsjakjhiuhebb ```
Therefore your formula should look like this:
 ```dhkjhfkjshfkjenkuhvdnvjnslefujshdfjsbdvlkfjhldjfhsljhdljkfhsdkjvhsldjhflksjhlkjdfh ```

Lummox JR

Souper new-B r not understanding souper intelagent code. I r wantin' to no what it r mean!

Heh. That's about how stupid I feel compared to you, Lummox. I think I should look into what all these things mean. O.O;

~>Volte
 #6 Feb 10 2003, 12:04 am In response to Spuzzum (#4) Spuzzum wrote: Being from Missouri (well, not really), I was wondering if you could explain the logic behind the formulas. Just because I absolutely suck at math doesn't make me one who would use a formula without understanding it, after all. =) Well, the subtraction and addition parts should be simple enough for starters--basically I changed the coordinates so that they were relative to the pivot point, by subtracting the pivot, and then after rotation I added that back in. The rotation part is a formula I can never fully remember, so I have to work it out every time. But basically it goes like this: For the sake of discussion I'll call the rotated coordinates x' and y'. Consider a right triangle. One side is x, and it goes all the way from the origin to (x,0). The next side is y, and it goes from (x,0) to (x,y). The hypotenuse goes from the origin to (x,y). Now, tip that triangle clockwise, pivoting it around the origin. Take a look at the bottom side first: It now goes from (0,0) to (x*cos(angle),-x*sin(angle)). (You can figure this out by just taking this line alone and making a new right triangle where the hypotenuse is x and the angle of rotation is at the origin.) The right side, considered alone, extends (y*sin(angle),y*cos(angle)) from wherever it starts; it starts at (x*cos(angle),-x*sin(angle)) where the right angle is, and ends at (x',y'). This'd be a lot easier to explain with diagrams. The way I figure it out is: x' will be the same as x if no rotation is used, so that's the cosine term. If you rotate 90° clockwise, it's y, and that's the sine term. Therefore x'=x*cos(angle)+y*sin(angle). Similar reasoning goes into y'; it's normally y unless you rotate, so that's the cosine term, while y'=-x if you rotate 90° clockwise, so y'=y*cos(angle)-x*sin(angle). I can never keep the signs straight without doing this each time because coordinate systems differ. Lummox JR
 #7 Feb 10 2003, 12:27 pm In response to Lummox JR (#6) Take a look at the bottom side first: It now goes from (0,0) to (x*cos(angle),-x*sin(angle)). (You can figure this out by just taking this line alone and making a new right triangle where the hypotenuse is x and the angle of rotation is at the origin.) The right side, considered alone, extends (y*sin(angle),y*cos(angle)) from wherever it starts; it starts at (x*cos(angle),-x*sin(angle)) where the right angle is, and ends at (x',y'). This is probably one of the few times in my life that I've actually understood a concept like this -- the former line being a hypoteneuse of a new triangle made it easy to understand. Thanks a bunch. (Incidentally, I'm taking grade 11 mathematics* through night school, so I'll build up a geometric foundation within the next few months. =)) * It's too lengthy to explain the B.C. math curriculum here -- suffice it to say that it's a comprehensive course designed to teach people upper high-school level mathematics in all fields, ranging from geometry to algebra. Grade 12 mathematics is top level non-calculus stuff that you take before college.