Intersecting a minkowski difference from the origin in a direction, how do i find the face im intersecting?
Date : March 29 2020, 07:55 AM
it helps some times Project the polyhedron in the direction of the ray, and your problem reduces to 2D, and finding which triangle encloses the origin. To test a single triangle, consider whether a given directed line segment (AB) is going clockwise or counterclockwise with respect to the origin. This is easy to determine with a simple crossproduct test: it's counterclockwise iff A x (BA) > 0. If all three sides of a triangle have the same sense (clockwise or counterclockwise) then the triangle encloses the origin and that's the face you want.

How do I draw squares on top of applications, get coordinates/size of the squares, and check to see if the image beneath
Tag : chash , By : Goeran
Date : March 29 2020, 07:55 AM
wish of those help Using Java, Zoom uses createScreenCapture() to render an enlarged 16 x 16 pixel BufferedImage taken as the mouse is dragged across the screen. Once you have the BufferedImage, you can periodically recapture the screen at the same point and use the getRGB() method to compare. See also Using Timers in Swing Applications.

Running the Optimal Flood Fill on a Grid While Limited to just NonIntersecting Squares
Date : March 29 2020, 07:55 AM
may help you . Gareth Rees posted a very nice answer to this question that expands on David Eppstein's answer at Math Overflow citing multiple authors. In a sentence, the algorithm, which yields optimal solutions, is first to cut a maximum noncrossing set of lines between concave vertices (found in polynomial time by maximum independent set in a bipartite graph) and then to extend these cuts greedily so that the remaining faces are rectangles. Finding a MIS in a bipartite graph requires a maximum matching algorithm. If this is too much work, then just the greedy step, where a vertical cut is made from each concave vertex, is a 2approximation.

Changing color of intersecting area of squares
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Lets think a bit how we could represent the intersecting area between two squares. Surely, one of the ways to do is simply to represent it as another rectangle, whose color we simply change based on the intercepting area. To draw a rectangle, we need to know the coordinates of the upper left corner, the width and the height. Therefore the challenge is to calculate those as we drag our squares around. This should be done in the draw() function. You already have the intersection check implemented, whats left is to calculate the new rectangle upper left point (newX, newY), width (newW) and height (newH). ...
//block checking collision
if (i != j && squares[i].collides(squares[j])) {
squares[i].changecolor();
//set intersection color
fill(50);
//calculate parameters
newX = Math.max(squares[i].position.x, squares[j].position.x);
newY = Math.max(squares[i].position.y, squares[j].position.y);
newW = Math.min(squares[i].position.x + squares[i].w, squares[j].position.x + squares[j].w)  newX;
newH = Math.min(squares[i].position.y + squares[i].h, squares[j].position.y + squares[j].h)  newY;
//draw rectangle
rect(newX, newY, newW, newH);
}

Check if two line segments are colliding (only check if they are intersecting, not where)
Date : March 29 2020, 07:55 AM

