# psychopy.tools.mathtools.intersectRaySphere¶

psychopy.tools.mathtools.intersectRaySphere(rayOrig, rayDir, sphereOrig=(0.0, 0.0, 0.0), sphereRadius=1.0, dtype=None)[source]

Calculate the points which a ray/line intersects a sphere (if any).

Get the 3D coordinate of the point which the ray intersects the sphere and the distance to the point from orig. The nearest point is returned if the line intersects the sphere at multiple locations. All coordinates should be in world/scene units.

Parameters
• rayOrig (array_like) – Origin of the ray in space [x, y, z].

• rayDir (array_like) – Direction vector of the ray [x, y, z], should be normalized.

• sphereOrig (array_like) – Origin of the sphere to test [x, y, z].