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
Tags:
I usually check to see how rhinoscriptsyntax does things to get an understanding of how Rhinocommon's methods work. There is no ProjectToPlane command in rhinoscritpsyntax, but there is a ProjectToSurface. It should be similar.
Hi Jesus,
Thank you for the reply. As you can see in line 2324 script uses ProjectToBrep method which is the work around that I mentioned.
newcurves = Rhino.Geometry.Curve.ProjectToBrep(curves, breps, direction, tolerance)
To do this I need to generate the surface each time based on the plane that I want to avoid if possible.
Yea, this method is quite problematic. Try this http://www.grasshopper3d.com/forum/topics/about-oblique-projection-...
Awesome! This is exactly what I was looking for...Thanks Mateusz! :)
Hi guys, does anybody have this info saved? The page that Mateusz refers to is gone...
Given a curve (or any geometry that is derived from GeometryBase, and possibly others too)
you can project a single curve like this:
yourCrv.Transform(Rhino.Geometry.Transform.PlanarProjection(yourPlane))
I haven't tested Arend's suggestion and if that works it is much more elegant from the function that I wrote:
https://github.com/mostaphaRoudsari/ladybug/blob/master/src/Ladybug...
Hi Mostapha, thanks for the link to your approach. Arend's method is a planar projection, so I'll try and translate this python script.
Seems like a challenge, let's see what happens..:)
Thanks again.
Hmm. Not too sure how to create that transformation matrix, but it should certainly be possible:
What you're looking for is called an oblique projection, (see http://en.wikipedia.org/wiki/Oblique_projection and http://www.slideshare.net/SanuPhilip/projection-in-computer-graphics )
Yes, I read that in the link Mateusz posted, hence my curiousness, but unfortunately the page is gone. Let me see what I can get from your links, thanks for that.
I gave it a little try - I think it worked quite well.
The transformation matrix is solved here by using the plane equation and the direction vector, creating a rhinocommon transformation matrix seemed to work quite well:
/**
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.M01 = -a * dy / D;
oblique.M02 = -a * dz / D;
oblique.M03 = 0;
oblique.M10 = -b * dx / D;
oblique.M11 = 1 - b * dy / D;
oblique.M12 = -b * dz / D;
oblique.M13 = 0;
oblique.M20 = -c * dx / D;
oblique.M21 = -c * dy / D;
oblique.M22 = 1 - c * dz / D;
oblique.M23 = 0;
oblique.M30 = -d * dx / D;
oblique.M31 = -d * dy / D;
oblique.M32 = -d * dz / D;
oblique.M33 = 1;
oblique = oblique.Transpose();
return oblique;
}
Thanks Arend :)
I was going to try to prepend a shear transformation to your earlier ProjectPlanar script (I read somewhere "Oblique projection = Shear + Orthogonal projection"), but I haven't had the time to do so. Will be after this weekend before I can try that.
Thanks for your contibution Arend, unfortunately your code yields a CS1061 error over here:
Rhino.Geometry.Transform bevat geen definitie voor Transpose en er is geen extenstemethode Transpose gevonden waarmee het eerste argument van het type Rhino.Geometry.Transform wordt geaccepteerd (mogelijk ontbreekt er een gebruiksinstructie of een assembly-verwijzig)(line 116).
I'll get back to you after the weekend. Ik ga effe uitwaaien op Texel:)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by