Jump to content

Need Some Help


vytas
 Share

Recommended Posts

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

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

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

  • 2 weeks later...

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

180° = πrEdit: whoops, JSG got there first, while I was trying to find the pi character in the character map!

Edited by Synook
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...