# Co-plane line and triangles' intersection

Hi,
I have 2 ON_MESH_POINTs P_1 and P_2 on a plane ON_Mesh.
and now I want to obtain the intersection point P_i between the triangle and line P_1P_2
Is there any API support in Rhino?

You might iterate the triangle mesh edges and use a `LineLine` intersection method:

@AndersDeleuran
I have found two API method could be helpful:

• `ON_Intersect()`
• `ON_IntersectCoplanarLineAndTriangle()`.

I want to create a new ON_MESH_POINT on triangle edge by intersection point.

I am a student and not familar with OpenNURBS, If it’s not too much trouble, could you kindly provide a code example? I believe this would greatly assist me in understanding the implementation details and advancing my project.

At present, my code is as follows, because I am not familiar with Rhino’s mesh traversal, so I do not know what to do next.

``````ON_MESH_POINT p,q;
ON_Line pq(p.m_P, q.m_P);
ON_3dPoint A, B, C;
p.GetTriangle(A, B, C);

// triangle edge
ON_Line AB(A, B);
ON_Line BC(B, C);
ON_Line CA(C, A);

double isectT;
// traverse each edge to check if was intersected
if (ON_Intersect(pq, AB, nullptr, &isectT)) {

ON_MESH_POINT isectPoint;
isectPoint.SetEdgePoint(mesh,p.m_face_index,)
}
else if (ON_Intersect(pq, BC, nullptr, &isectT)) {

}
else if (ON_Intersect(pq, CA, nullptr, &isectT)) {

}
ON_MESH_POINT newPoint;
newPoint.SetEdgePoint(mesh, faceIndex, edgeIndex, edgeParameter);
``````