CalcWorldHub
Free online calculator · no signup

Ray triangle intersection calculator

Test a forward 3D ray against a finite triangle and recover the intersection position.

4,000 tools
Ray triangle intersection calculator — Ray origin x y z, Ray direction x y z, First triangle vertex and calculation method
Ray triangle intersection calculator: inputs and calculation method.

How to use this calculator

Test a forward 3D ray against a finite triangle and recover the intersection position.

  1. Enter Ray origin x y z, Ray direction x y z, First triangle vertex, Second triangle vertex, then complete the remaining labeled fields. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Ray triangle intersection explained

Ray parameter at hit1
Ray parameter at hit: 1 in the worked scenario.

A numerical walkthrough

Ray origin x y z = 0.25, 0.25, 1; Ray direction x y z = 0, 0, -1; First triangle vertex = 0, 0, 0; Second triangle vertex = 1, 0, 0; Third triangle vertex = 0, 1, 0.

  • Ray parameter at hit: 1
  • Intersection point: 0.25, 0.25, 0
  • Triangle weights: 0.5, 0.25, 0.25

The ray reaches z = 0 at t = 1 and point (0.25, 0.25, 0). Its barycentric weights (0.5, 0.25, 0.25) sum to one and place the hit inside the triangle.

The model behind the numbers

Möller–Trumbore ray barycentric intersection

Cross products reduce the ray/plane equation to the triangle’s two barycentric coordinates and the ray parameter. A hit requires nonnegative barycentric coordinates, their sum at most one, and a forward ray parameter. Parallel and coplanar cases are handled separately.

What to enter

o — Ray origin x y z
Ray origin x y z. Use comma-separated values in the stated order.
d — Ray direction x y z
Ray direction x y z. Use comma-separated values in the stated order.
a — First triangle vertex
First triangle vertex. Use comma-separated values in the stated order.
b — Second triangle vertex
Second triangle vertex. Use comma-separated values in the stated order.
c — Third triangle vertex
Third triangle vertex. Use comma-separated values in the stated order.

Interpreting the result

Double-sided triangle and t≥0; ray direction need not be normalized. Coplanar rays are reported separately, not expanded into overlap intervals.

Frequently asked questions

Is t a physical distance?

Only when the direction vector has unit length.

Does it include triangle edges?

Yes, with a numeric tolerance.

Can it hit the back face?

Yes, this tool does not cull back faces.

How do I use the Ray triangle intersection calculator?

Enter Ray origin x y z, Ray direction x y z, First triangle vertex, Second triangle vertex, then complete the remaining labeled fields. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Ray triangle intersection?

Ray origin x y z = 0.25, 0.25, 1; Ray direction x y z = 0, 0, -1; First triangle vertex = 0, 0, 0; Second triangle vertex = 1, 0, 0; Third triangle vertex = 0, 1, 0. Ray parameter at hit: 1 Intersection point: 0.25, 0.25, 0 Triangle weights: 0.5, 0.25, 0.25 The ray reaches z = 0 at t = 1 and point (0.25, 0.25, 0). Its barycentric weights (0.5, 0.25, 0.25) sum to one and place the hit inside the triangle.