## translate a point with a vector direction.

Need help, or want to share a macro? Post here!
jr23mx
Posts: 6
Joined: Fri Nov 09, 2018 12:54 am
Location: Monterrey Mexico
Contact:

### translate a point with a vector direction.

Hello guys, hope you are doing great

I wanna create 2 point near to a midpoint on a curve, and those new points should be 2 mm offset in one axis.

the problem for me now, is I only know the normal of the faces, but those are not aligned to a specific axis, it means something like this (-0.059824540910132035, 0.0, 0.9982089081474338) so, I need to increment 2 axis of the point (X,Y,Z), I understand that I need to change 2 axis.

what does the normal values means if those are not 1?

can you suggest me something?

thanks
snap0000017.png (45.25 KiB) Viewed 291 times
JoshM
Posts: 419
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

### Re: translate a point with a vector direction.

I believe, but am not sure, that you want to create two vertex points, relative to a known input point (M1), and two known vectors(Vec_F1_Norm, Vec_F2_Norm), and a fixed offset distance of 2mm for each, and what is confusing you is that the normal vectors are translated away from the XYZ axes. It would be easier in future to post file, not just image.

If I understand you correctly, then P1 will be a point on Face1, and P2 will be on Face2.

P1 is then simply M1 + 2.0 * Vec_F2_Norm, and P2 is M1 + 2.0 * Vec_F1_Norm.

So, in the example you state, if the normal vector for Face2 (assuming as it points upward) = (-0.059824540910132035, 0.0, 0.9982089081474338) and, if M1 is located at (0.0, 0.0, 0.0), then P2 = (-0.11964908182026407, 0.0, 1.9964178162948676).

Attached is an approximation of what you show. In my model, Face7 corresponds to your Face1, and Face5 corresponds to your Face2. If you select the model and paste following code into your python console, it will demonstrate by placing M1, P1, P2 on the model. Note that M1 was chosen as the bottom vertex of the side-edge of the cylinder because it appeared close to what you are doing.

Code: Select all

``````Model = App.ActiveObject

F1=Model.Shape.Face7
F2=Model.Shape.Face5

F1_Center = F1.Surface.Center
M1=F1.Edge1.Vertexes[0].Point

F1Norm=(M1-F1_Center).normalize()
F2Norm = -F1.Surface.Axis

P1 = M1 + (2.0 * F2Norm)
P2 = M1 + (2.0 * F1Norm)

V0=Part.Vertex(M1)
V1=Part.Vertex(P1)
V2=Part.Vertex(P2)

Part.show(V0)
Part.show(V1)
Part.show(V2)
``````

Best,
Josh
Attachments
Dev020.FCStd
jr23mx
Posts: 6
Joined: Fri Nov 09, 2018 12:54 am
Location: Monterrey Mexico
Contact:

### Re: translate a point with a vector direction.

Thanks it works!
Pauvres_honteux
Posts: 259
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

### Re: translate a point with a vector direction.

Is there already a tool (with GUI) for "translating" stuff in general?
JoshM
Posts: 419
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

### Re: translate a point with a vector direction.

Pauvres_honteux wrote:
Mon Feb 18, 2019 5:58 am
Is there already a tool (with GUI) for "translating" stuff in general?
Not sure. I suspect from a GUI use standpoint, there exists placement for each object. If you double-click on an object, you can edit the translation and rotation increments, but it's not clear what this affects.

One thing that surprised me a while ago--only because I wasn't knowledgeable--was that much or all of the "higher level" Part operations can be done to a single Vertex, and this if nothing else demonstrates what is required... For example, if you placed a vertex at M1, you could Extrude it 2mm along the F1-Normal in OP's question. I ran across this when when I realized that I don't adequately understand how to translate a 2d circle in 3d space to an arbitrary position, if I know only the radius and axis vector where I need the circle to be placed. But, knowing the radius and axis-vector of the circle, I could simply place a vertex and revolve it around the axis to form the circle in 3d space.