so, i tried to use the “custom” function from **here** and it worked!

well kind of, the result had the Y, and Z axis mirrored, so i multiplyed those by -1, and it kind of worked, still a litle bit wrong, but its an improvement!

here are some pics:

as you can see, the reflection its pretty close, but still a little bit off the place it shoud be…

and the code:

import Mathutils as M

import bpy, math

from Mathutils import Vector

# begin the reflected ray calculation

def Ray_calc():

```
starVec = Vector(2,0,0)
endVec = Vector(-6,0,0)
#print(starVec,endVec)
ob = bpy.context.active_object
ray = ob.ray_cast(starVec, endVec)
col = Vector(ray[0][0],ray[0][1],ray[0][2]) #gets the coalision vector
nor = Vector(ray[1][0],ray[1][1],ray[1][2]) #gets the normal vector
newVec = Vector(vec_reflect_py(starVec, nor)) #reflects
newVec += col #adding the coalinsion vector to the result vector
newVec = Vector(newVec[0],newVec[1]*-1,newVec[2]*-1) #weird Y, Z axis flipin
return starVec, col, newVec
```

#begin reflect function

def vec_reflect_py(vec, mirror):

```
reflect = [0.0, 0.0, 0.0]
# normalizing
length = 0.0
for i in range(3):
length += mirror[i] * mirror[i]
length = float(math.sqrt(length))
for i in range(3):
mirror[i] /= length
dot2 = 2 * (vec[0]*mirror[0]+vec[1]*mirror[1]+vec[2]*mirror[2])
reflect[0] = vec[0] - (dot2 * mirror[0])
reflect[1] = vec[1] - (dot2 * mirror[1])
reflect[2] = vec[2] - (dot2 * mirror[2])
return reflect
```

#begin to draw the calculated ray

def Ray_draw(v0,v1,v2):

```
verts_loc = []
a = 0
b = 0
c = 0
while a < 3:
verts_loc.append(v0[a])
a += 1
while b < 3:
verts_loc.append(v1[b])
b += 1
while c < 3:
verts_loc.append(v2[c])
c += 1
```

```
print("sequence ---> " + str(verts_loc))
mesh = bpy.data.meshes.new("Ray")
mesh.add_geometry(3,0,0)
mesh.verts.foreach_set("co", verts_loc)
#mesh.faces.foreach_set("verts_raw", faces )
scene = bpy.context.scene
mesh.update()
ob_new = bpy.data.objects.new("Reflection Vectors", 'MESH')
ob_new.data = mesh
scene.objects.link(ob_new)
ob_new.selected = True
ob_new.location = (0,0,0)
obj_act = scene.objects.active
```

Ray_calc() #executes the reflection

Ray_draw(Ray_calc()[0],Ray_calc()[1],Ray_calc()[2]) #draws the reflection

ps1: the ray starts at (2,0,0), and ends at (-6,0,0) OBJECT SPACE, so a good idea is to place the mesh center at (0,0,0) global space, with applied rotation, scale, so that the coordinates don´t get mixed up.

ps2: the Ray_draw function creates a new object with 3 vertices, if no face is hited by the ray, a ZeroDivisionError will occur