Calculate vector distance

Posts 1–7 of 7 · Page 1 of 1
Calculate vector distance
Simple snippets in calculating vector distances.

[highlight=vb.net]Private Structure Vector
Public x As Single
Public y As Single
Public z As Single
End Structure

Private Function VectorDistance(ByVal vec1 As Vector, ByVal vec2 As Vector) As Double
Return Math.Sqrt(Math.Pow(vec1.x - vec2.x, 2) + Math.Pow(vec1.y - vec2.y, 2) + Math.Pow(vec1.z - vec2.z, 2))
End Function[/highlight]

[highlight=c++]#include <math.h>

typedef struct {
float x;
float y;
float z;
} Vector;

float VectorDistance(Vector vec1, Vector vec2)
{
return sqrt(pow(vec1.x - vec2.x, 2) + pow(vec1.y - vec2.y, 2) + pow(vec1.z - vec2.z, 2));
}[/highlight]
This is nice. Always fun to learn/watch new codes I've never seen before.
what program do u guys use to compile this? Visual basic ?
nice you just learned that with c++? ;p
Quote Originally Posted by lolbie View Post
nice you just learned that with c++? ;p
erm, no. I googled 3D Math craps and found some formulas.
Nice brain tommy. Well this would be nice if u want to make a aimbot, with a specific angle of distance :P
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?