how to shift a point from surface?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
silent_missile
Posts: 16
Joined: Mon Jul 29, 2019 11:07 pm

how to shift a point from surface?

Post by silent_missile »

hello, I have some problems, please give me some guidance.

here is a free surface like NURBS, and a free curve like B-Spline

they intersect, so there is an intersection point

now I need to shift this intersection point from the surface for some distance to get a new point, the law of the shift is normal to the surface at the intersection point

if I program the NIURBS algorithm, it's too complected, also python is slower than c++, so I hope FreeCAD has some api to do this, finally output the xyz coordinate value of the point

I checked the wiki but can't find the api, please tell me how to do this.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: how to shift a point from surface?

Post by DeepSOIC »

1. ubtain u,v values for your intersection point.
This can be in a return value of distToShape method, which you may be using to computer the intersection. If you are doing it somehow differently, you can obtain u,v values with u,v = a_face.Surface.parameter(point_in_3d_as_App_Vector)
2. compute the normal:

Code: Select all

n = a_face.Surface.normal(u,v)
3. compute the moved point:
p_moved = point_in_3d_as_App_Vector + n*5.5 #shift away from surface by 5.5 mm
It may be a good idea to normalize the normal vector before that, just in case.
Post Reply