Grasshopper

algorithmic modeling for Rhino

Hello,

could someone post a code snippet on how to get the normal vector of a point on a surface? 

Any hints appreciated,

Andy

Views: 2301

Replies to This Discussion

Hi, You first need to get the UV coordinates using this: http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Surface_Cl...

Then you can use the property normal:

http://4.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Geometry... 

I hope this helps,

Pirouz

Hello,

thanks for that. It appears to work for the most part. One problem i have is that it doesn't always line up with GH's EvalSrf component. Sometimes the EvalSrf gives {0,1,0}(which is correct) while my C# code results in {0,-1,0} (which is not).

Any ideas?

Hm i realized some other things i dont understand. Here is what i would like to do: i have a bunch of planar trimmed surfaces (most have holes in them). I want to iterated over them and sum up their area, but only if they have a specific normal vector.

Here is what i have so far:

AreaMassProperties massProp = AreaMassProperties.Compute(surf);

Point3d cent = massProp.Centroid;

double u,v;
surf.ClosestPoint(cent, out u, out v);

SurfaceCurvature cur = surf.CurvatureAt(u, v);

Vector3d normal = cur.Normal;

double area = massProp.Area;

However, if i check the area in Rhino it gives a different result than AreaMassProperties.Area. And GH's EvalSrf component shows different(and correct) normal vectors than what i get with the code above.

Any hints appreciated,

Andy

The surface has a method NormalAt(u,v). Maybe, you get better results with that.

Also it's much easier to work with surfaces after reparametrizing - method .SetDomain

Mateusz: is there somewhere a description available, what SetDomain actually does? the docs are a bit short on that..

You can manually set the U and V domains of the surface. In GH we use reparametrize option to set it to 0 to 1 in both directions, however you can set it to any domain with code. It's just much more convinient to work with reparametrized surface, both in code and in grasshopper.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service