Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to understand this document:

but I don't understand how this distance is calculated:

vector b = vertex3 – vertex1
vector c = vertex2 – vertex1
vector Normal = cross( c, b )
distance = -dot( O – vertex1, N ) / dot( D, N )

vertex1 is a vector to a triangle's first vertex, vertex2 to its second and vertex3 to its third. Normal is the normal vector to two vertices and it's needed because I'm trying to figure out if a vector intersects a plane or not.

O is a vector's origin point and D is the same vector's destination point.

My question is: how's that "distance" calculated? It should be something like the vector's distance from the plane but I'm unsure how it works

share|cite|improve this question
$O$ is the origin? And what is $D$? – user7530 Feb 7 '13 at 17:09
The document doesn't say it.. but I suppose O it's a ray's origin vector and D its direction vector. This code should be used to check whether a ray intersects a triangle – Marco A. Feb 7 '13 at 17:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.