Jump to content

Trigonometry... v.v


robhol

Recommended Posts

Posted

I need a function like this:

float float getXYInFrontOf(float x, float y, float rotation, float distance) 

Anybody got it handy? Thanks in advance.

(I hate trigonometry, I hate trigonometry, I hate trigonometry.)

Posted

Off the top of my head:

x2 = x + cos(rotation) * distance

y2 = y + sin(rotation) * distance

Posted

A couple of lines from my code:

  
    local tx        = x - math.sin(math.rad(rz)) * radius        
    local ty        = y + math.cos(math.rad(rz)) * radius 
  

Where rz is your rotation in degrees e.g. from getPlayerRotation()

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