vytas Posted October 1, 2009 Share Posted October 1, 2009 Ok lets say I have an object with the position: x: 3 & y: 5. I want to move the object with 5 pixels with an angle of 30 degrees. How would I calculate the new position? Im giving alot of thought in this, but I can't figure it out. Hope I made myself clear. Thanks Vytas. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 1, 2009 Share Posted October 1, 2009 That's trigonometry. Look up sines, cosines, and tangents. I still remember "SohCahToa" from my high school trig classes. If you know the angle and the distance, you can calculate the X and Y needed.Soh: sine(angle) = opposite/hypotenuseCah: cosine(angle) = adjacent/hypotenuseToa: tangent(angle) = opposite/adjacentSo the sine of 30 degrees is the same as the opposite leg (Y value) divided by the hypotenuse. If you know the hypotenuse is 5 and the value of the sine of 30 degrees, then you can figure out the one missing value. e.g.:sin(30) = Y/5Y = 5 * sin(30)cos(30) = X/5X = 5 * cos(30)Just make sure you don't confuse degrees and radians.http://en.wikipedia.org/wiki/Hypotenuse Link to comment Share on other sites More sharing options...
vytas Posted October 1, 2009 Author Share Posted October 1, 2009 Thank you so much for that information, I knew it had something to do with the SIN, COS or TAN but I just didn't know how to make it work. Link to comment Share on other sites More sharing options...
Jack McKalling Posted October 13, 2009 Share Posted October 13, 2009 Hmm, I never actually completely understood the difference between radians and degrees, but I also didn't know what radians were in the first place... I know degrees devide a circle into 360 cakeslices, but would that make radians something like the amount of thumbs around a wheeltire?Lol. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 13, 2009 Share Posted October 13, 2009 There are 2pi radians in a circle, an arc with an angle of 1 radian gives a curve that is the same length as the radius.http://en.wikipedia.org/wiki/Radians Link to comment Share on other sites More sharing options...
Synook Posted October 13, 2009 Share Posted October 13, 2009 180° = πrEdit: whoops, JSG got there first, while I was trying to find the pi character in the character map! Link to comment Share on other sites More sharing options...
Jack McKalling Posted October 13, 2009 Share Posted October 13, 2009 Ah, that clears up a bit. So basically, a radian is somewhat like 58 degrees, based on a different measurement. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.