Tutorial 3D Distance - Mathematical

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat


Dank Tier Donator
Mar 24, 2016
Did you ever yoused the 3D Distance function or wondered on what the Distance between you and your Enemy depends on?
Well here I will show you what it actually does and how you can write your own one. If you already know how it works, that's good. If not this could be useful to understand the Math behind it all, so you can come up with new ideas.
Before we start you should have a basic understanding of Math, that's all. Also im sorry for my bad English, I am german.​

In this picture you can see a Three Dimensional Coordinate System.​

So now i will add to Points to the System. I will call them A and B because that's what you usually do. A will be our Player.

They have the Coordinates: A = (-4.70635, 2.31164, 1.63883) and B = (3.18464, 3.96405, 2).

So now we "Pull a line between the two Points" or "Create a Vector that represent quantities that have a magnitude and als a direction".

So the Vector has the Coordiantes X (7.89) Y (1.65) Z (0.36).
How to you Calculate this? Its very Simple:

Because we start at A and got Towards B, our Tip is at B.
So now you have to Subtract the X Coordinate of B from the X Coordinate of A.
When you do the same with the Y and the Z Coordinates you will get the Value of the Vector AB.

XB - XA = X
YB - YA = Y
ZV - ZA = Z

Well now all thats left is to Calculate the Magnitude of the Vector.
We will achieve this with Pythagoras' Theorem. Well there was a smart Guy about 2000 Years ago who found out that when a triangle has a right angle and squares are created on each of the three of the triangle sides, then the biggest square has the same area as the two smaller squares put together. The Equation is called: a² + b² = c².​

This is how its done:

|AB| = √( X²+ Y²+ Z²) = Magnitude
|AB| = √( 7,89² + 1,65² + 0,36²) = √(65,1042) = 8,0687

As the Coordinates are only correct to two decimal places, the Valid digits are only 8,07.

And this is the Magnitude between you and the Enemy.
So here you are thats all to it.

Have a Great Day,
Last edited:


I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
Awesome post, we need more math tutorials like this. Just curious, what prpgram did you use to render the coords?


Dank Tier Donator
Mar 24, 2016

Well thank you very much for the good support.
Well since I am at the last thew month of a Math specific school, we have to use this for school. Its called GeoGebra and some German guys made it :D
Here is the Link/.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods