Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection of two sets #139

Closed
schillic opened this issue Jan 11, 2018 · 15 comments
Closed

Intersection of two sets #139

schillic opened this issue Jan 11, 2018 · 15 comments
Assignees
Labels

Comments

@schillic
Copy link
Member

schillic commented Jan 11, 2018

Add a lazy binary operator type Intersection (and maybe an n-ary variant) representing the intersection of two sets S1 and S2.
Also have a convenience alias ∩(S1, S2), for which Julia's built-in alias is intersect.

Related but simpler: #67

@schillic schillic added the feature ➕ A new feature label Jan 11, 2018
@schillic schillic added this to the v1.1.0 milestone Jan 11, 2018
@schillic
Copy link
Member Author

  1. What do we do if the intersection is not representable? Overapproximate? Underapproximate? Support both with a parameter?
  2. Do we want to have a lazy type Intersection? It would be almost insonsistent to not have this, but the support vectors might not be as easy as with the other types.

@schillic schillic added the discussion 🗣️ Requires human input label Jan 11, 2018
@mforets
Copy link
Member

mforets commented Jan 11, 2018

yes, i think should be lazy. we can provide an option to compute it exactly, as it is the case for the minkowski sum of 2d clouds of points, for example.

@schillic
Copy link
Member Author

Okay, I edited the first post.

@schillic schillic removed the discussion 🗣️ Requires human input label Jan 11, 2018
@schillic
Copy link
Member Author

schillic commented Jan 11, 2018

Is it correct that, assuming that the intersection is nonempty, the support vector is just the minimum/maximum of both operands' support vectors?

function σ(d::AbstractVector{N}, I::Intersection{N, S1, S2})::AbstractVector{N} where {N<:Real}
    v = copy(d)
    sv1 = σ(d, I.X1)
    sv2 = σ(d, I.X2)
    for i in 1:length(d)
        v[i] = d[i] < 0 ? max(sv1[i], sv2[i]) : min(sv1[i], sv2[i])
    end
end

I am not sure about the case where a vector entry is 0.

And of course we need to detect that the intersection is nonempty. Can we just ask σ(-d, I) and see if the results contradict?
EDIT: No, take two nonintersecting boxes with the same x coordinates. Asking for d = [1, 0] does not detect emptiness of the intersection.

@mforets
Copy link
Member

mforets commented Jan 11, 2018

cc: @viryfrederic

@schillic
Copy link
Member Author

schillic commented Jan 11, 2018

Okay, this is Section 8.1, first paragraph in Le Guernic's thesis. I just have to study it.

EDIT: Actually, this section is only for detecting emptiness, which would rather fit for #67.
What we want here is Section 8.3, and it sounds complicated.

And forget my algorithm above. I think it works for hyperrectangles, but definitely not for arbitrary sets (take two circles for instance).

schillic added a commit that referenced this issue Jan 11, 2018
schillic added a commit that referenced this issue Jan 17, 2018
@schillic
Copy link
Member Author

The implementation we have now just crashes when asked for the support vector. We should think about what we can do here, maybe solve a complicated optimization problem or resort to subcases.

@schillic schillic reopened this Jan 17, 2018
@schillic schillic removed this from the v1.1.0 milestone Jan 17, 2018
@schillic schillic added the discussion 🗣️ Requires human input label Jan 17, 2018
@mforets
Copy link
Member

mforets commented Jan 17, 2018

we could also write an intersect function that works by dispatching on some special pairs of sets for which we can implement it.

@schillic schillic added this to the v1.1.0 milestone Jan 17, 2018
@schillic schillic removed the discussion 🗣️ Requires human input label Jan 17, 2018
@schillic
Copy link
Member Author

@mforets found this paper about the general case.

@schillic
Copy link
Member Author

We should pull out the LinearConstraints.intersection function here, too. See #57.

@mforets mforets removed this from the v1.1.0 milestone Jan 26, 2018
@mforets
Copy link
Member

mforets commented Jan 26, 2018

still this is open:

the implementation (of the intersection) we have now just crashes when asked for the support vector.

one approach is to compute the concrete intersection (done in #173), and ask for the support vector. but i wouldn't do it this way since this wouldn't be a lazy operation at all. seems to me that it will be preferable to apply Lemma 4 from Frehse and Ray.

@schillic
Copy link
Member Author

Well, there are different levels of laziness.

  1. Intersection waits with computing the intersection until you ask for it. This is what we could have with Polyhedra interface #173.
  2. All our other lazy types never compute the actual set but only provide the support vector of a given direction by passing the query to their child sets. This is what you meant, and I agree that this is better (assuming it is actually cheaper).

@mforets
Copy link
Member

mforets commented Jan 27, 2018

Lots of interesting material: https://www.geometrictools.com/Documentation/Documentation.html

@schillic
Copy link
Member Author

Another interesting page: http://www.realtimerendering.com/intersections.html

@schillic schillic added this to the Intersection milestone Jul 20, 2018
@schillic schillic removed this from the Intersection milestone May 13, 2019
@schillic
Copy link
Member Author

Closing this one and continuing the meta collection in #1391.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants