Jump to content

trigonometry, need 2 functions


adsad2

Recommended Posts

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

Link to comment
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.

Link to comment

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 ...

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...