0

# Intersection of an stl object and plane3d

**This discussion was imported from CodePlex**

**abuseukk** wrote at 2013-02-05 13:35:

Hi guys,

I am trying to find the intersection points of GeometryModel3D and a plane. The model is STL file and loaded by the helix methods. I thought that I have all the triangles and with the implemented intersection of line and Plane3D i will find the points easily but that's not true. I don't know why I find so many points on the plane but not only the intersection points - What I mean is that Plane3D.LineIntersection(...) every time return some points but not null. If someone have an idea it will be grateful :) Thanks

I am trying to find the intersection points of GeometryModel3D and a plane. The model is STL file and loaded by the helix methods. I thought that I have all the triangles and with the implemented intersection of line and Plane3D i will find the points easily but that's not true. I don't know why I find so many points on the plane but not only the intersection points - What I mean is that Plane3D.LineIntersection(...) every time return some points but not null. If someone have an idea it will be grateful :) Thanks

```
MeshGeometry3D modelGeometry = (MeshGeometry3D)hitgeo.Geometry;
for (int i = 0; i < modelGeometry.TriangleIndices.Count; i=i+3)
{
int index1 = modelGeometry.TriangleIndices[i];
int index2 = modelGeometry.TriangleIndices[i+1];
int index3 = modelGeometry.TriangleIndices[i+2];
Point3D point1 = modelGeometry.Positions[index1];
Point3D point2 = modelGeometry.Positions[index2];
Point3D point3 = modelGeometry.Positions[index3];
Point3D? intersection1 = p3d.LineIntersection(point1, point2);
Point3D? intersection2 = p3d.LineIntersection(point1, point3);
Point3D? intersection3 = p3d.LineIntersection(point2, point3);
if(intersection1 != null)
{
IntersectionPoints.Add(intersection1);
}
if(intersection2 != null)
{
IntersectionPoints.Add(intersection2);
}
if(intersection3 != null)
{
IntersectionPoints.Add(intersection3);
}
}
```

**abuseukk** wrote at 2013-02-07 09:50:

I found it ... the interesction is not line and plane its ray and plane, I had to check if the point is on the line :)

**objo** wrote at 2013-02-07 19:59:

Great! (For general use you may also need to account for transforms applied to your model)

Also see the contouring example in Source\Examples\ExampleBrowser\Examples\Contour

Also see the contouring example in Source\Examples\ExampleBrowser\Examples\Contour

Customer support service by UserEcho