I have this code:
graphicsContext.setCanvas(canvas);
graphicsContext.clear();
camera.applyTransform(graphicsContext);
RectF screen = camera.getCamRect(getWidth(), getHeight());
for(Road r : roads) {
if(screen.contains(r.getRect())) {
r.draw(graphicsContext);
}
}
for(Intersection i : intersections) {
if(screen.contains(i.getRect())) {
i.draw(graphicsContext);
}
}
The only problem is the contains method must have all 4 verticies of B in A to return true.
What type of algorithm could I use, given top, left, bottom, right to check if B is either part or completely inside B.
Thanks
Just use
RectF.contains()with each of the vertices of the shape you want to test for intersectionor even easier,
RectF.intersects()will handle all that for you.It’s all in the documentation.