Project to plane with projection vector

I seem to recall having asked for this sometime back, but my memory is failing me here…

I would like to project some curves or surfaces to a plane along a direction vector that is not normal to that plane. (XFormPlanarProjection() projects only along a vector normal to the plane.)

Is there an easy way to do this with transformations? I can extrude the curves/surface edges along the direction vector and then intersect them with the plane, but I’d rather not do that if I don’t have to…

Thanks, --Mitch

Projection to a plane means that all control points lie on that plane.
Projection along a direction is basically moving each control point along a line defined by its original location and the projection direction. So, this problem boils down to calculating the intersection between a line and a plane. I’m sure rhinoscriptsyntax has functions for this, if not it can be found in RhinoCommon Intersection.LinePlane

Hi Mitch
rs.ProjectCurveToSurface doesn’t do what you want?

Hi Alain, Menno,

Yeah, thanks, I was just looking for a shortcut…

There actually isn’t a surface there to project to (although I could create one) - it’s just a plane, and I’m also “projecting” surfaces in addition to curves…

I was just hoping for a workaround to avoid looping through and transforming individual curve/surface points, but looks like the best thing to do is exactly that - get the NurbsCurvePointList or NurbsSurfacePointList and loop through all, projecting the locations to the plane along the direction vector and then using SetPoint()/SetControlPoint() to set the cp’s to the new location.

–Mitch

Hi Mitch

I think it could be done using rs.XformPlanarProjection() and rs.XformShear()
… but now I’m a little too tired to be able to make it work … or to find out it’s a bad idea …
Sorry … :blush:

Yeah, I thought about a shear transform as well, but my brain was too small to figure out how to do it.

I just made a small definition to project points to a plane along a vector (as Menno suggested):

def ProjPtsToPlaneAlongVector(pts,plane,vec):
    proj_pts=[]
    for pt in pts:
        line=Rhino.Geometry.Line(pt,vec)
        rc,ipt=Rhino.Geometry.Intersect.Intersection.LinePlane(line,plane)
        if not rc: return #exit if one of the points doesn't hit the plane
        proj_pts.append(line.PointAt(ipt))
    return proj_pts

I can then use that to transform the control points of curves or surfaces.

Cheers, --Mitch

1 Like