public bool Intersects(Triangle3 triangle) { var v0 = triangle.point2 - triangle.point1; var v1 = triangle.point3 - triangle.point1; var v2 = this - triangle.point1; float dot00 = v0.Dot(); float dot01 = v0.Dot(v1); float dot02 = v0.Dot(v2); float dot11 = v1.Dot(); float dot12 = v1.Dot(v2); float invDenom = 1 / ((dot00 * dot11) - (dot01 * dot01)); float u = ((dot11 * dot02) - (dot01 * dot12)) * invDenom; float v = ((dot00 * dot12) - (dot01 * dot02)) * invDenom; return((u > 0) && (v > 0) && ((u + v) < 1)); }
public bool IntersectTriangle(Triangle3 triangle, out Vec3 intersectionPoint) { return(IntersectTriangle(triangle, triangle.Normal(), out intersectionPoint)); }
public bool IntersectTriangle(Triangle3 triangle, Vec3 triangleNormal, out Vec3 intersectionPoint) { return(IntersectTriangle(triangle.point1, triangle.point2, triangle.point3, triangleNormal, out intersectionPoint)); }
public bool WithinTriangle(Triangle3 triangle) { return(WithinTriangle(triangle.point1, triangle.point2, triangle.point3)); }