Grasshopper

algorithmic modeling for Rhino

Hi all,

I want to project curves onto a plane in a specified direction using rhinoCommon. As far as I understand the ProjectToPlane method has no input for projection direction:

ProjectToPlane(curve: Curve, plane: Plane) -> Curve

A possible work around is to make a big enough planar surface and then use ProjectToBrep but I wonder if there is a better way?

I know that David added a Grasshopper component that already does this but as I said I want to do it inside the scripting component.

Thanks,

Mostapha

Views: 4363

Replies to This Discussion

Hmm. Are you sure you've got the latest rhino service release? Otherwise the workaround is quite easy: flip the digits of the matrix indices (actually a nicer solution anyway):

  /**
  See: http://stackoverflow.com/questions/2500499/howto-project-a-planar-p...
  1-a*dx/D    -b*dx/D    -c*dx/D   -d*dx/D
  -a*dy/D   1-b*dy/D    -c*dy/D   -d*dy/D
  -a*dz/D    -b*dz/D   1-c*dz/D   -d*dz/D
  0          0          0         1
  */
  public Transform GetObliqueTransformation(Plane Pln, Vector3d V)
  {

    Transform oblique = new Transform(1);
    double[] eq = Pln.GetPlaneEquation();
    double a,b,c,d, dx, dy, dz, D;
    a = eq[0];
    b = eq[1];
    c = eq[2];
    d = eq[3];
    dx = V.X;
    dy = V.Y;
    dz = V.Z;
    D = a * dx + b * dy + c * dz;
    oblique.M00 = 1 - a * dx / D;
    oblique.M10 = -a * dy / D;
    oblique.M20 = -a * dz / D;
    oblique.M30 = 0;
    oblique.M01 = -b * dx / D;
    oblique.M10 = 1 - b * dy / D;
    oblique.M21 = -b * dz / D;
    oblique.M31 = 0;
    oblique.M02 = -c * dx / D;
    oblique.M12 = -c * dy / D;
    oblique.M22 = 1 - c * dz / D;
    oblique.M32 = 0;
    oblique.M03 = -d * dx / D;
    oblique.M13 = -d * dy / D;
    oblique.M23 = -d * dz / D;
    oblique.M33 = 1;
    return oblique;
  }

Attachments:

Thanks Arend, got both your scripts working now, sorry about my late reply. I did try to get the "Oblique projection = Shear + Orthogonal projection" approach working, but to no avail.
My question was triggered by my previous one, and now I have all answers needed (for the moment).
Thank you very much everyone:)

There's a typo in this code. Where is says:

oblique.M10 = 1 - b * dy / D;

It should read:

oblique.M11 = 1 - b * dy / D;

:)

Thanks Arend, I'm going to see how can I extend this method to project it along a vector.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service