Page MenuHome

math_utils.geometry.intersect_line_line_2d gives incorrect results for colinear segments
Closed, ArchivedPublic

Description

System Information
Ubuntu 15.04 x86-64, Intel HD 4000 GPU.
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2

Blender Version
Broken: 2.72b (Ubuntu package), 2.74rc1 (built from git, 4aa5109)

Short description of error

For some values where the two segments are well separated but nearly colinear, the function will claim that they intersect. However because the function operates on segments (not infinite lines), there should be no intersection.

Exact steps for others to reproduce the error

  1. Open the Python console in Blender.
  2. Type:
import mathutils.geometry
geometry.intersect_line_line_2d(Vector((-0.11303041130304337, 0.5093119144439697)), Vector((-0.015013276599347591, 0.6790825724601746)), 
                  Vector((0.08300385624170303, 0.8488532304763794)), Vector((0.18102099001407623, 1.0186238288879395)))
  1. Result will be: Vector((-0.015013276599347591, 0.6790825724601746))
  1. Expected result: None. See attached file for illustration of the segments in coordinate system.

Event Timeline

Petteri Aimonen (jpa) raised the priority of this task from to 90.
Petteri Aimonen (jpa) updated the task description. (Show Details)
Petteri Aimonen (jpa) edited a custom field.

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Oct 12 2015, 7:48 PM
Bastien Montagne (mont29) claimed this task.

intersect_line_line_2d… Clearly does not talk about segments, but lines, and so does the doc.

Petteri Aimonen (jpa) changed the task status from Archived to Unknown Status.Oct 12 2015, 8:02 PM

So is this issue incorrect then: https://developer.blender.org/T46002

Also does not seem to work correctly for infinite lines either:
mathutils.geometry.intersect_line_line_2d((0,0), (1,0), (2,2), (2,1)) = None
If it was for infinite lines, then it should give (2,0).

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Oct 13 2015, 9:45 AM

Yeah, as a matter of fact, something is definitively not correct here! Will check this a bit more.

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Oct 13 2015, 10:05 AM

OK, fixed ugly T46002 now, doc will be correct at least, if not fun name itself.

Now, here when I paste your code in py console I get None, not any Vector. Could confirm the bug in 2.74 and even 2.75, but we just released 2.76, in which it seems to be fixed, please always check against latest version (even from our buildbot before reporting a bug.

Ah yeah, confirmed fixed on 2.76. Sorry about that, I did not notice that my git build was on old tag instead of master branch.