how to shift a point from surface?

Need help, or want to share a macro? Post here!
Posts: 16
Joined: Mon Jul 29, 2019 11:07 pm

how to shift a point from surface?

Postby silent_missile » Tue Oct 08, 2019 3:21 pm

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
Posts: 7474
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: how to shift a point from surface?

Postby DeepSOIC » Tue Oct 08, 2019 4:36 pm

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.