Two line intersection in 3d
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 439
- Joined: Tue Apr 04, 2017 6:06 pm
- Location: SF Bay Area, California
Two line intersection in 3d
I can't seem to find a two line intersection function in FreeCAD. I would like to use it on Part edges in my scripts.
Do i need to make my own?
http://mathforum.org/library/drmath/view/63719.html
Do i need to make my own?
http://mathforum.org/library/drmath/view/63719.html
Re: Two line intersection in 3d
You can use the common function, which results in a vertex at the intersection point if both intersect. Or use distToShape to get the zero distance point.
Re: Two line intersection in 3d
I think you have better result with section functionickby wrote:You can use the common function
Code: Select all
section = edgeA.section(edgeB)
point = section.Vertexes[0].Point
Code: Select all
distance = edgeA.distToShape(edgeB)
-
- Posts: 439
- Joined: Tue Apr 04, 2017 6:06 pm
- Location: SF Bay Area, California
Re: Two line intersection in 3d
Oops, I should have said lines or vector directions defined by the end points of edges. This means that they are infinite. Functions like distToShape would not work.damian wrote:I think you have better result with section functionickby wrote:You can use the common functionorCode: Select all
section = edgeA.section(edgeB) point = section.Vertexes[0].Point
Code: Select all
distance = edgeA.distToShape(edgeB)
Re: Two line intersection in 3d
Oops, perhaps you are looking for something like thisdamian wrote:Oops, I should have said lines or vector directions defined by the end points of edges
Code: Select all
>>> l=Part.Line(App.Vector(0,0,0),App.Vector(10,0,0))
>>> ll=Part.Line(App.Vector(5,5,0),App.Vector(5,-5,0))
>>> l.intersect(ll)
[<Point (5,0,0) >]
Re: Two line intersection in 3d
Look at Flamingo WB add-on, the path tool in Frame toolbox.
It creates a Dwire object connecting together, with the shortest path rule, all selected edges.
It creates a Dwire object connecting together, with the shortest path rule, all selected edges.
-
- Posts: 439
- Joined: Tue Apr 04, 2017 6:06 pm
- Location: SF Bay Area, California
Re: Two line intersection in 3d
It's not clear to me why i would do this given the various functions already built into freeCAD to do this that have already been posted. Can you please explain?jidoeuf wrote:Look at Flamingo WB add-on, the path tool in Frame toolbox.
It creates a Dwire object connecting together, with the shortest path rule, all selected edges.
Re: Two line intersection in 3d
Code: Select all
DraftGeomUtils.findIntersection()
-
- Posts: 439
- Joined: Tue Apr 04, 2017 6:06 pm
- Location: SF Bay Area, California
Re: Two line intersection in 3d
On a related topic, is there a fast point/finite line segment (edge) intersection test that just gives back a true or false but does not proceed to calculate the intersection location?
Re: Two line intersection in 3d
hi
mario
Code: Select all
# 2. Solution using DraftGeomUtils
import DraftGeomUtils
s = FreeCADGui.Selection.getSelection()
L1 = s[0]
L2 = s[1]
v = DraftGeomUtils.findIntersection(L1.Shape.Edges[0],L2.Shape.Edges[0])
print(v) # [Vector (-1.3432017072221727, 0.28294823146762915, 0.0)]
print(v[0]) # Vector (-1.3432017072221727, 0.28294823146762915, 0.0)
print(v[0].x) # -1.3432017072221727
print(v[0].y) # 0.28294823146762915
print(v[0].z)# 0.0
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.