Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 11:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



x y angle calculation [question]

Discussion on x y angle calculation [question] within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2006
Posts: 48
Received Thanks: 13
x y angle calculation [question]

Hey guys,

I'd like to ask something about a calculation which I was thinking of.

I got 2 points, 1 point is the point where I am and the other point is the point to which I want to move. But first I have to look towards this point ( face angle ). It is about a game, called warhammer.

I heared, that there is a possibility to calculate the angle.

Let's say the point is (which I was reading out CE):
x1 = 27802.375;
y1 = 17086.75;
x2 = 27520;
y2 = 18296.4375;

I know how to calculate the distance between two points, it must be something like.

X = x2 - x1;
Y = y2 - y1;
Distance = Math.sqrt(pow(X, 2) + pow(Y, 2));

Angle:
Angle = Math.Acos(-Y, Distance) / 6.28 * 360;

But I'm not sure and maybe someone has another solution to find out the face angle


best regards
syron198 is offline  
Old 11/16/2008, 14:12   #2
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
What you have is fine, but you could cut out the distance caclucation by using Atan(X, Y). I assume you need the distance for other calculations though anyway.
unknownone is offline  
Old 11/16/2008, 14:21   #3
 
elite*gold: 0
Join Date: Jun 2006
Posts: 48
Received Thanks: 13
oh yes... you're right... Thanks!

This is my function and it works perfectly.

public double angle(double x1, double y1, double x2, double y2)
{
double X = x1 - x2;
double Y = y1 - y2;

double distance = Math.Sqrt(Math.Pow(X, 2) + Math.Pow(Y, 2));
// double result = Math.Acos(-Y / distance) / 6.28 * 360;
double result = Math.Atan(X / Y) / 6.28 * 360;
if (result < 0) result = result * -1;

return result;
}
syron198 is offline  
Reply


Similar Threads Similar Threads
Horus R6 Stab/Staff Engel/Angle
08/24/2010 - Rappelz Trading - 0 Replies
English Hi, as you can see at the Threadname I'm searching a R6 2h Staff!!! This Staff should be an old or with Magic effect, it has to be +15 or higher. To the Angle best would be Lv1^^ but 145+ would be possible to . (I hope it's clear that it should be +25 if its over 115^^) It's wayne which of the two staffs it is. I'm looking forword to hear from you Pls answer bye pm so i will directly see if you have intrest =) Sry for bad English =(
Secure Camera angle change possible?
05/26/2007 - Guild Wars - 5 Replies
hi, i want to rotate the camera into another direction in an autoit script. But i haven't found a secure solution yet that works 100%. i tried things like: move mouse while right mouse button is pressed: MouseMove&#40;1, 200&#41; MouseDown&#40;&#34;right&#34;&#41 ; MouseMove&#40;1, 250, 100&#41;
Character viewing angle
04/13/2007 - Conquer Online 2 - 3 Replies
Having just restarted playing conquer recently, I was a bit disappointed with the equipment window. One of the new patches have changed the character's viewing angle. Instead of seeing the character straight ahead, its now more of a top down view at an angle. I perfer the old view of the character, does anyone have any idea on how to get the old view back? For those who dont know what I mean, heres a screenshot http://img405.imageshack.us/img405/5052/conquerzg 7.jpg



All times are GMT +1. The time now is 11:50.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.