You just need to get the two directional vectors, which is direction = from - to; (and normalize those two directions)
a) from getrealeye to bullet hitpoint
b) from getrealeye to getrealeye += foward * 10000
Then do iprintln(vectorDot(a, b)); and you should understand it, basically it gives you the angle between the two vectors
YouTube has enough videos which explains dot product
Made some example code for IPython, for quick testing:
PHP Code:
import numpy as np
def veclength(vec):
return np.sqrt( dot(vec, vec) )
def dot(a, b):
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]
def scale(vec, s):
return [ vec[0]*s, vec[1]*s, vec[2]*s ]
def a_minus_b(a, b):
return [ a[0]-b[0], a[1]-b[1], a[2]-b[2] ]
def normalize(vec):
l = veclength(vec)
return [ vec[0]/l, vec[1]/l, vec[2]/l ];
player_from = [100,100,100]
player_to_a = [100,100,130]
player_to_b = [100,100,130]
player_to_c = [100,99,130]
dir_a = a_minus_b(player_to_a, player_from);
dir_b = a_minus_b(player_to_b, player_from);
dir_c = a_minus_b(player_to_c, player_from);
dir_a = normalize( dir_a )
dir_b = normalize( dir_b )
dir_c = normalize( dir_c )
print("dir_a", dir_a)
print("dir_b", dir_b)
print("dir_c", dir_c)
print("dot(dir_a, dir_b)", dot(dir_a, dir_b))
print("dot(dir_a, dir_c)", dot(dir_a, dir_c))
Output:
PHP Code:
('dir_a', [0.0, 0.0, 1.0])
('dir_b', [0.0, 0.0, 1.0])
('dir_c', [0.0, -0.033314830232638482, 0.99944490697915433])
('dot(dir_a, dir_b)', 1.0)
('dot(dir_a, dir_c)', 0.99944490697915433)