For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How can I get the normal vector of a point on a surface?

Anonymous's picture
Forums: 

Hello everyone:
In my project,I want to draw a sphere on a surface which is tangent to the surface.I have known the three coordinates of the tangent point,but how can I get the normal vector of the point on the surface?

Thanks.

Torsten Sadowski's picture

Hi Andy,

you can get the direction from the plane assuming its a gp_Pln:

gp_Dir dir=yourPlane.Axis().Direction();

HTH, Torsten

Stephane Routelous's picture

if you have a Geom_Surface, you can use the D1 method to compute the D1U and D1V and after that, compute the cross product of both vector to get the normal (if I remember correctly. I don't have the OCC code installed)

Stephane

Andy's picture

Thank you,Torsten and Stephane.In my project ,the type of the surface is uncertain,maybe it's a plane,maybe a cylindrical surface or some other type of suface,so I want to find a way that will be ralative universal to all situations.I have also thought about the method of computing the cross of the D1U and D1V,but how to get the parameters of the point on a random surface so that I can compute the D1U and D1V ?

Thanks a lot!

Andy

Torsten Sadowski's picture

Hi Andy,

Geom_Surface::Value(U,V) returns the point on the surface.

You should take a web browser and point it to

whereeverthisis/OpenCASCADE5.2/doc/ClassBrowser/index.htm

Then you have only to find the right class ;-))

Torsten

Andy's picture

Hi Torsten ,
Thanks for your help. I also know that function and the Geom_Surface class,but what I want to do is just the opposite.The three coordinates of the point is known to me,I want to get the parameters of the point on a random surface so that I can compute the D1U and D1V ,and afetr that,compute the cross product of both vector to get the normal of the point.

Torsten Sadowski's picture

Hi Andy,

Points are a bit difficult at this point because they are easily outside the surface. I don't know how you got your point but the GeomAPI_IntCS class gives you all intersection points between curve and surface and the parameters for curve and surface.

Torsten

Andy's picture

Hi Torsten,
In fact,I only want to draw some spheres which are all tangent to a surface.Firstly,I got some points on a curve which is in the surface, i.e. a sequence of equidistant points.That is to say,the three coordinates of the point is known to me.Then I want to draw some spheres tangent to the surface with these points.Do you have some good suggestion?

Andy

Stephane Routelous's picture

the good way is to use GeomAPI_ProjectPointOnSurf.
the method LowerDistanceParameters gives you the U and V you are searching

Stephane

Andy's picture

Thank you very much,Stephane.Your suggestion is very useful for me.That's a good idea.But I also have a question.If the point exists in the surface,is the way to use GeomAPI_ProjectPointOnSurf on the point also effectual?

Stephane Routelous's picture

you can try to use Geom_Tools::Parameters or ElSLib::Parameters if you have surfaces where you know the types

Andy's picture

Thank you very much!

Andy

Stephane Routelous's picture

you can try to use Geom_Tools::Parameters or ElSLib::Parameters if you have surfaces where you know the types