Getting Degree's of where you are to a players Radius menu

User Tag List

Results 1 to 3 of 3
  1. #1
    SwInY's Avatar Member
    Reputation
    29
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Degree's of where you are to a players Radius

    Hey Guys,

    i have a really technical maths question. and due the fact i hate maths. im asking you guys lol.

    What im trying to get is,

    my Degree's or radian of where my location is, compared to a other person.

    Getting Degree's of where you are to a players Radius-pic-jpg

    Basiclly its the "guts" out of IsBehind, exept the bool is a output.

    ANY help!?

    Getting Degree's of where you are to a players Radius
  2. #2
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, I don't know if can get this right, but I will try.

    First you have to calculate the distance on x and y (or z) axes, to get the necessary values for a (arc-)tangens calculation
    DiffX = EnemyPosX - YourPosX
    DiffY = EnemyPosY - YourPosY (Or Z, depending on your point of view)

    Rule: tan(alpha) = X / Y and tan(beta) = Y / X

    MeToEnemyDegrees_Absolute = tan^-1 * (DiffX / DiffY)
    or
    EnemyToMeDegrees_Absolute = tan^-1 * (DiffY / DiffX)

    To determine if something is behind someone/something, you can do the folllowing: (Not tested)
    Code:
    public bool IsBehind(GameObject obj)
    {
    	double x = obj.x - this.x;
    	double y = obj.y - this.y;
    	double d = Math.Atan() * (y / x); // Absolute rotation "Object to Object"
    					  // If you set your rotation to this value, you will face the object
    					
    	double r = d - this.RotationZ; 	  // substracting object rotation from absolute rotation
    	
    	if(Math.Abs(r) > 180) r = (Math.Abs(r) - 360) * -1;
    	return (r > 90);		  // If the relative rotation to the object is bigger than 90 degrees,
    					  // the given object is behind "this"
    }
    Last edited by xalcon; 03-27-2012 at 02:43 AM.
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  3. #3
    SwInY's Avatar Member
    Reputation
    29
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that, got it working.

    Code:
            public static double GetStandingDegrees
            {
                get
                {
                    double d = Math.Atan2((Target.Y - Me.Y), (Target.X - Me.X));
    
                    double r = d - Target.Rotation; 	  // substracting object rotation from absolute rotation
                    if (r < 0)
                        r += (Math.PI * 2);
    
                    return r;
                }            
            }

Similar Threads

  1. [Release] PokeSniper2 - Pokemon Sniper - Catch any Pokemon no matter where you are
    By maclone in forum Pokemon GO Hacks|Cheats
    Replies: 3630
    Last Post: 02-18-2017, 12:10 PM
  2. Getting honor in AV if you are pugging.
    By Mikeydoes in forum World of Warcraft Guides
    Replies: 9
    Last Post: 11-13-2009, 04:54 AM
  3. How to get on US servers when you are EU and reversed.
    By freakolivier in forum World of Warcraft Guides
    Replies: 13
    Last Post: 11-02-2008, 06:32 PM
  4. Replies: 8
    Last Post: 02-12-2008, 11:33 PM
All times are GMT -5. The time now is 08:18 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search