Closed Angular-Angel closed 6 years ago
I believe this to be due to faulty logic in RGeomElem.java
public boolean contains(RPoint[] ps) {
boolean contains = false;
if(ps != null){
for(int i=0; i < ps.length; i++) {
contains &= this.contains(ps[i]);
}
}
return contains;
}
In my hands always returns false Simple crude fix:-
public boolean contains(RPoint[] ps) {
if (ps.length == 0) {
return false;
}
for (RPoint p : ps) {
if (!this.contains(p)) {
return false;
}
}
return true;
}
Since java-8 possible to use lambda for a more elegant solution, and it makes sense not to overload contains.
public boolean containsPoints(RPoint[] pts) {
Stream<RPoint> outside = Arrays.stream(pts).filter(pt -> !contains(pt));
return outside.count() == 0;
}
Hmm. Is this library maintained? If not it might be necessary to fork it. A pain, but I could do it if I need to. :/
As for the function, the earlier fix you posted seems more efficient. It returns immediately upon discovering false, whereas this one performs a bunch of unnecessary computation. And yeah, this ones shorter, but it's also a lot denser and more complicated. Personally, I'd prefer the first, simpler option.
Sorry for the delay fellows. I have been swamped with pressing deadlines and hadn't had a chance to look into this.
Do I need to do anything to update my library for this? I tried running Processing and it didn't show any updates, or say anything about updates. :/
I have made a new release (42) and published it on the web: http://ricardmarxer.com/geomerative/geomerative.zip Processing didn't seem to pick up this update. I have asked the Processing library contact to see what's going on.
On Sat, Nov 10, 2018 at 4:25 AM Angular-Angel notifications@github.com wrote:
Do I need to do anything to update my library for this? I tried running Processing and it didn't show any updates, or say anything about updates. :/
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/rikrd/geomerative/issues/7#issuecomment-437554615, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA73JaZvJBdosrBCAG_P8dss0XZdibrks5utkcMgaJpZM4X9ODA .
-- ricard http://twitter.com/ricardmp http://www.ricardmarxer.com http://www.caligraft.com
RShape.contains(RShape) always seems to return false, no matter what. Here's a sketch that accurately describes the problem - the small rectangle should turn red when inside the larger one, but it never does, despite intersecting with it, and then not intersecting with it after it goes inside.