Skip to content

modify __eq__ method for Point class, the original == for float is no…#41

Open
jianantian wants to merge 8 commits intoTaipanRex:masterfrom
jianantian:master
Open

modify __eq__ method for Point class, the original == for float is no…#41
jianantian wants to merge 8 commits intoTaipanRex:masterfrom
jianantian:master

Conversation

@jianantian
Copy link
Copy Markdown
Contributor

modify eq method for Point class since the original == for float is not robust.
add set_epsilon function to change EPSILON value.

…t robust. add set_epsilon function to change EPSILON value
@TaipanRex
Copy link
Copy Markdown
Owner

I know the epsilon approximation for equality is used in papers, I wondering what problem it solves though? If two points differ by less than epsilon, does it matter if eq returns false? I guess my question is, what problem does adding epsilon solve?

Adding a call to abs and the additional arithmetic is a cost to performance, so must weigh that against what benefit it adds.

@jianantian
Copy link
Copy Markdown
Contributor Author

jianantian commented Aug 8, 2018

In my example (at end), there is an exception,

UnboundLocalError: __lt__() in vis_graph.py

but as you can see in the graph, no polygon is overlap with other.

The debug info is the following: (this is the __lt__ method in EdgeKey)

self.edge: {Edge}((-3.51, 1.60), (-2.22, 1.60))
p1 = {Point} (-3.51, 1.60)
    polygon_id = {int} 0
    x = {float} -3.5101999999999998
    y = {float} 1.5981
p2 = {Point} (-2.22, 1.60)
     polygon_id = {int} 0
    x = {float} -2.2232
    y = {float} 1.5981
 

other.edge: {Edge} ((-3.51, 1.95), (-3.51, 1.60))
    p1 = {Point} (-3.51, 1.95)
    polygon_id = {int} 0
    x = {float} -3.5101999999999998
    y = {float} 1.9467000000000003
p2 = {Point} (-3.51, 1.60)
    polygon_id = {int} 0
    x = {float} -3.5101999999999998
    y = {float} 1.5981000000000005

as you can see, the keypoint is

{x = {float} -3.5101999999999998, y = {float} 1.5981} 

and

{x = {float} -3.5101999999999998, y = {float} 1.5981000000000005}.

I think this is caused by the float number precisition.

this is my example data, and you can see the graph in the attachment png file.

polygon_list = [
    [[-5.3231999999999999, 5.9744999999999999], [-5.3231999999999999, 5.0061], [-3.5101999999999998, 5.0061],
    [-3.5101999999999998, 4.5061], [-3.5101999999999998, 3.8466999999999998],
    [-3.0069999999999997, 3.8466999999999998], [-3.0069999999999997, 3.3466999999999998],
    [-3.0069999999999997, 2.4467000000000003], [-3.0069999999999997, 1.9467000000000003],
    [-3.5101999999999998, 1.9467000000000003], [-3.5101999999999998, 1.5981000000000005],
    [-3.5101999999999998, 1.5981000000000001], [-2.2231999999999998, 1.5981000000000001],
    [-2.2231999999999998, 1.0981000000000001], [-2.2231999999999998, -0.90189999999999992],
    [-2.2231999999999998, -1.4018999999999999], [-2.7231999999999998, -1.4018999999999999],
    [-5.8231999999999999, 1.0981000000000001], [-6.4231999999999996, 5.9744999999999999],
    [-6.4231999999999996, 6.4744999999999999], [-5.3231999999999999, 6.4744999999999999]],
    [[3.5348000000000002, 8.5561000000000007], [3.5348000000000002, 8.0561000000000007],
    [3.0348000000000002, 8.0561000000000007], [-0.66520000000000001, 8.0561000000000007],
    [-1.1652, 8.0561000000000007], [-1.1652, 8.5561000000000007],
    [-1.1652, 9.7561], [-1.1652, 10.2561], [-0.66520000000000001, 10.2561],
    [[3.5348000000000002, 7.0980999999999996], [-0.66520000000000001, -1.4018999999999999],
    [-1.1652, -1.4018999999999999], [-1.1652, -0.90189999999999992], [-1.1652, 4.7980999999999998],
    [-1.1652, 5.2980999999999998], [0.23480000000000001, 5.2980999999999998],
    [0.23480000000000001, 6.0980999999999996], [0.23480000000000001, 6.5980999999999996],
    [0.73480000000000001, 6.5980999999999996], [0.73480000000000001, 7.0980999999999996],
    [0.73480000000000001, 7.5980999999999996], [3.5348000000000002, 7.5980999999999996]]]   

out_polygon = [[  3.2848,   8.3061],
    [  3.2848,   7.3481],
    [ -0.9152,  -1.1519],
    [ -2.4732,  -1.1519],
    [ -5.5732,   1.3481],
    [ -6.1732,   6.2245],
    [ -6.1732,  10.0061],
    [ -0.9152,  10.0061]]
   
start_point = [-1.6942, 1.3481]
end_point = [-3.2442,  5.0561]

visgraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants