# efficienly projecting a line on a surface

Hello,

I have a finite line which lies on a plane parallel to the XY-plane. I need to project this line on a surface and get the normals of the surface along the projected line.
(The whole surface is between the XY-plane and the line-plane).

Currently I have an algorithm which works, but it's VERY slow.
Is there any better way of doing it?

Jones.

My algorithm is:
1. Extend line along Z-axis: Build a plane defined by the Z axis and the line I wish to project.
2. Intersect with surface: Intersect the plane with the surface. Now I have the projection over the whole surface, but I just need to find the end points of the projected line.
3. Extend end points along Z-axis: Build two lines which are parallel to the Z axis and going through the end points of the original line.
4. Intersect with surface: Intersect these lines with the surface to get the projected-line-imagined-end-points (I can't intersect these lines with the projected line because of accuracy: I don't get any intersection points).
5. Project points on line: Project the projected-line-imagined-end-points on the projected line to get the real end points (the nearest projection).
6. Calculate normals: Get the parameters of these points on the surface (by projecting them on the surface), and cross D1U and D1V to find the normal at these points.

> 1. Extend line along Z-axis: Build a plane defined by the Z axis and the line I wish > to project.
> 2. Intersect with surface: Intersect the plane with the surface. Now I have the
> projection over the whole surface, but I just need to find the end points of the
> projected line.
> 3. Extend end points along Z-axis: Build two lines which are parallel to the Z
> axis and going through the end points of the original line.
> 4. Intersect with surface: Intersect these lines with the surface to get the
> projected-line-imagined-end-points (I can't intersect these lines with the projected
> line because of accuracy: I don't get any intersection points).

You can define not a section plane, but a section bar, by extruding your finite line segment along Z axis (make a prism). Thus you will obtain the exactly restricted projected line.

> 5. Project points on line: Project the projected-line-imagined-end-points on the
> projected line to get the real end points (the nearest projection).
> 6. Calculate normals: Get the parameters of these points on the surface (by
> projecting them on the surface), and cross D1U and D1V to find the normal at these
> points.

If you order to build pcurves in the section algorithm then you won't need to project points back to the surface, as the resulting edge will contain pcurve synchronized with 3d curve.