Say I've got a line segment L created with something like Part.makeLine(v1,v2)
How do I add (or subtract) some arbitrary amount to one end? For example add 2mm to the v1 end?
extending a segment
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: extending a segment
You mean find the direction and the coordinates needed for the new end of the line? I think this works.
Code: Select all
v1 = App.Vector(0,0,0)
v2 = App.Vector(10,10,5)
l1 = Part.makeLine(v1,v2)
Part.show(l1)
dir1 = (v2-v1).normalize()
#add 3.14 mm to line
v3 = App.Vector(dir1.multiply(l1.Length+3.14))
l2 = Part.makeLine(v2,v3)
Part.show(l2)
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: extending a segment
It occurs to me if v1 is not on the origin another addition might be needed to get v3 correctly offset from v1.