Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 9th Apr 2008 10:40
I'm terrible at trig, so here's what I'm trying to do. I need to know the angle to a point in space, from another point in space. I have, say, the following points:

oldPosX
oldPosZ
posX
posZ

distance = SQRT((posX-oldPosX)^2+(posZ-oldPosZ)^2)

What's the angle from coordinates 1 to coordinates 2 in relative space?

Much appreciated!


Hurray for teh logd!
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 9th Apr 2008 10:43
If you want the angle measure anticlockwise from the x axis, it's:

Theta# = atan( ( posZ# - oldPosZ# ) / ( posX# - oldPosX# ) )

-= Out here in the fields, I fight for my meals =-
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 9th Apr 2008 11:07
wonderful! Thanks!


Hurray for teh logd!
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Apr 2008 15:04 Edited at: 9th Apr 2008 15:04
Don't use that It will only work for angles 0 to 90! Use this:

Angle# = atanfull(posX# - oldPosX#, posZ# - oldPosZ#)

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 9th Apr 2008 20:36
Quote: "Don't use that It will only work for angles 0 to 90! Use this:

Angle# = atanfull(posX# - oldPosX#, posZ# - oldPosZ#)"


Ah ok. I realized it was a little off, and that's when I discovered atanfull and already have it in effect


Hurray for teh logd!

Login to post a reply

Server time is: 2025-06-01 20:23:22
Your offset time is: 2025-06-01 20:23:22