Confused by DraftGeomUtils.isPtOnEdge behaviour (a bug?)

Need help, or want to share a macro? Post here!
kwahoo
Posts: 275
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Confused by DraftGeomUtils.isPtOnEdge behaviour (a bug?)

Postby kwahoo » Tue Jun 10, 2014 4:10 pm

Hi,

Those two scripts draw two arcs and find their intersection. isPtOnEdge should return true in the both cases, but it's not:

Code: Select all

p1 = Vector(0, 0, 0)
p2 = Vector(5, -10, 0)
r = 10
pl = FreeCAD.Placement(p1, Vector(0,0,1), -90)
pl2 = FreeCAD.Placement(p2, Vector(0,0,1), 180)
arc = Draft.makeCircle(radius=r,placement=pl,face=False,startangle=-90,endangle=90,support=None)
arc2 = Draft.makeCircle(radius=r,placement=pl2,face=False,startangle=-90,endangle=90,support=None)
intersect = DraftGeomUtils.findIntersection(arc.Shape.Edges[0], arc2.Shape.Edges[0])
inters = intersect[0]
is_point = DraftGeomUtils.isPtOnEdge(inters, arc2.Shape.Edges[0])
print inters, is_point
returns:

Code: Select all

Vector (-4.916198487095665, -8.708099243547831, 0.0)True
While

Code: Select all

p1 = Vector(0, 0, 0)
p2 = Vector(5, -5, 0)
r = 10
pl = FreeCAD.Placement(p1, Vector(0,0,1), -90)
pl2 = FreeCAD.Placement(p2, Vector(0,0,1), 180)
arc = Draft.makeCircle(radius=r,placement=pl,face=False,startangle=-90,endangle=90,support=None)
arc2 = Draft.makeCircle(radius=r,placement=pl2,face=False,startangle=-90,endangle=90,support=None)
intersect = DraftGeomUtils.findIntersection(arc.Shape.Edges[0], arc2.Shape.Edges[0])
inters = intersect[0]
is_point = DraftGeomUtils.isPtOnEdge(inters, arc2.Shape.Edges[0])
print inters, is_point
returns:

Code: Select all

Vector (-4.114378277661477, -9.114378277661476, 0.0)False
edit (Normand would kill me;)
OS: Ubuntu 14.04 LTS
Platform: 64-bit
Version: 0.14.3653 (Git)
Branch: master
Hash: 2fcce866a73bb4c3d5ca55195d676dc7e0fad3ab
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.0
User avatar
yorik
Site Admin
Posts: 11845
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Confused by DraftGeomUtils.isPtOnEdge behaviour (a bug?)

Postby yorik » Wed Jun 11, 2014 1:40 pm

Good catch, that code was indeed a bit buggy... I just found and committed a much more efficient method... It should work OK now. git commit b0c157a
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Confused by DraftGeomUtils.isPtOnEdge behaviour (a bug?)

Postby NormandC » Fri Jun 13, 2014 1:49 am

kwahoo wrote:edit (Normand would kill me;)
These days forgetting to post FreeCAD info doesn't nearly annoys me as much as people posting help requests in the Part Design forum. Even with a big honking topic "Please do not post help requests here" staring right at them. :roll: