Hello everybody,
I try to make a code find an intersection between a ray and a box. I read a
lot of thing on the internet and one of the best code I could find is this
one.
def box_aabb_intersect(bbox_min, bbox_max, ray, direction):
t1 = (bbox_min.x - ray.x) * direction.x
t2 = (bbox_max.x - ray.x) * direction.x
t3 = (bbox_min.y - ray.y) * direction.y
t4 = (bbox_max.y - ray.y) * direction.y
t5 = (bbox_min.z - ray.z) * direction.z
t6 = (bbox_max.z - ray.z) * direction.z
t_min = max(max(min(t1, t2), min(t3, t4)), min(t5, t6))
t_max = min(min(max(t1, t2), max(t3, t4)), max(t5, t6))
if t_max < 0.0 or t_min > t_max:
return
return t_min
Everyone says it works but I can not make it work at home. Does someone
have an idea?
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/18ab0a86-841b-4390-9999-b23b51665012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.