adsad2 Posted June 21, 2009 Posted June 21, 2009 I'm not good in trigonometry and need these functions to the script, preferably in pure mathematics. Determining point given a point, distance and direction (x, y, z, distance, direction) Speed in one direction (find x, y-speed) (direction, speed) As said, I'm not good in trigonometry, I am very grateful for the help. Thanks in advance. PS. sorry for bad English, using automatic translation
adsad2 Posted June 22, 2009 Author Posted June 22, 2009 Please help me, I need the features of the script and can not figure out how I can make them. It seems that it is easy for anyone who can trigonometry?
robhol Posted June 22, 2009 Posted June 22, 2009 I'm not good in trigonometry and need these functions to the script, preferably in pure mathematics. Determining point given a point, distance and direction (x, y, z, distance, direction) Speed in one direction (find x, y-speed) (direction, speed) As said, I'm not good in trigonometry, I am very grateful for the help. Thanks in advance. PS. sorry for bad English, using automatic translation Function #1: function relativePoint(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end I assume this is what you wanted. If I understood you correctly you can just use the same function for the second question too, if you put 0 for x and y and just use the distance and angle/rotation arguments.
adsad2 Posted June 27, 2009 Author Posted June 27, 2009 Thanks robhol, it works fine! But I need another function. I write the prototype here and hope someone can help me find the angle rotation from the points (x1, y1), (x2, y2) if a ped was on point 1 and I set x to this value the ped would look toward point 2. Sorry my English ...
DiSaMe Posted June 27, 2009 Posted June 27, 2009 math.deg(math.atan2(x2-x1,y2-y1)) I think this should work, but you may have to negate it (put - at the start of the line) or swap x1 with x2 and y1 with y2.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now