Finding Exit Face of Ray-AABB Intersection (Ray Tracing) - raytracing

I'm trying to implement the traversal algorithm for binary rope trees suggested here, however, I'm stuck at finding a fast and precise way to determine the exit face of a ray-AABB intersection, with the purpose of finding the next rope to follow. The paper does not indicate a method for this, and neither do any articles I've read from the Internet.
Is there a better way to get the exit face of a ray-AABB intersection than checking the intersection of each plane with the ray? (even with dot product elimination, I still see this method as not very precise)
Thank you.

I think I have discovered a satisfactory solution! Knowing the exit point, the exit plane is the one with the smallest distance to the exit point. It's as precise as the ray-AABB intersection algorithm and (being an AABB) it only requires a few subtractions, which makes it pretty fast.
I will mark the question as answered when I can actually test this method.

Related

How to find the optimal path for a line following maze bot?

This question was already posted in robotics stackexchange but i did not get any reply.
Moreover, this question is about solving a maze with some constraints, so its not limited to making a particular robot with uC and all.
First let me explain the problem.
This is a maze made only out of black lines on a white surface. The robot has only a few IR sensors which can sense the position of the line. No other sensory input is available.
This is a maze with many self-loops and so a simple LSRB or equivalent algorithm wont work. The robot is supposed to learn the maze and then solve it as optimally as possible .
The above figure represent the possible intersections as all the paths are at 90deg to each other.
As far as my understanding goes, the robot will first scan how many nodes there are, and what their connections to each other is, thus effectively constructing the graph. Next, implement any shortest path algorithm and make your robot follow it.
However, the main problem that i cant get my head around is this:
How will this blind robot know it isnt viewing the same node multiple times if it keeps coming back to the same point after getting caught in a loop?
Also, please suggest good approaches to solving this problems along with any experience anybody has. How does one shot searching methods like DFS , Iterative deepeing DFS , hill climbing work in such scenarios ?
When it meets a crossing, the robot must keep a trace of the lanes it didn't take and backtrack later. In addition, it must be able to model the paths with enough accuracy to check that it is back in a place it has seen before.
Then I am not sure that there is a better strategy than
traverse the lanes until you find the exit;
every time you have a crossing, note the lane that you skip;
when you are back at a known place, return to a skipped lane by the shortest route.
If the map is not known beforehand, you obviously cannot find the optimal path, unless by chance.
If there is no way to estimate the geometry, all you can do is random moves.

How do you find circle points in Fortune's algorithm?

I know that when your sweepline encounters three centers of your array, you have to check if there is something called "circle points".
I understand that circle points are the poles of the circle that goes through the other 3 points, but my questions is, which is the efficient way to do this, because what you really want is the center of the circle which is the vertex of three Voronoi poligons, so what came to my head is to find the three mediatrices and the intersection of the three will be the center, but it seems to me that if I do that the algorithm will be mor closely to a brute force algorithm, I hope you could help me with this, thanks in advance
EDIT: I think it's worth saying that I'm working on Julia, and that I've already done two brute force algorithms, one aproximate and one exact
There is a rather good and detailed description of this algorithm in this course book:
https://www.springer.com/gp/book/9783540779735
They explain how efficiency is obtained by adding pointers between the status tree and the parts of the diagram being constructed.
Maybe it can help. I have not implemented the algorithm myself.

Simplify a convex hull

My problem is as follows:
I have a convex hull which could look like this:
I would like to group significantly close points together to be represented by some form of averaging, which could be the mean or median point for example.
I am more so focused on how to do the grouping.
How can I perform this grouping in a systematic way?
I understand this seems like a very simple question and the answer is obvious. My main problem is in attempts to solve this I end up with some corner cases such as the answer will change depending on where I start on the hull. For example if I started from the red line and worked clockwise I would end up with (if I made no attempt to catch the corner case):
I had many attempts at this and every time I rethought my idea I ended up with a new corner case that felt unwieldy. I have a habit of finding the most un-intuitive way to solve a problem so I thought it best to ask the a community. A comparative example to the problem I am having now is I've been asked to find an element in a sorted array and I'm initially performing a linear search and I have a gut feeling there is something better out there.
I could not find exactly what I wanted with my research. I found hull simplifying algorithms but it changed the shape of the hull too much which did not suit the goal of my program.
I will add a note here at the end that I am using OpenCV with C++ to generate a convex hull on a project I am working on. Just in case this is a worth while detail (and why I added OpenCV as a tag).
Consider using Douglas–Peucker algorithm
It is intended to simplify polylines, throwing out less important points.
Thanks Berriel for addition: it is implemented in OpenCV: approxPolyDP

Point in polygon algorithm that returns true when the test point is on a polygon edge

I've implemented a point-in-polygon algorithm based on http://alienryderflex.com/polygon/.
It works fine but, as it says in the article:
If the test point is on the border of the polygon, this algorithm will deliver unpredictable results
It turns out I need the algorithm to return true when the test point is on the border/edge (and the vertices) of the polygon.
Is there either:
An alternative algorithm that will help me; or
A way to modify this algorithm to get what I want (e.g. by expanding the polygon a little bit before running the algorithm)
Expanding the polygon a bit is an option but this can be tricky with concave polygons.
My recommendation would be to shift the point into different directions (up/down/left/right) by a tiny amount and do the calculation for each of these shifted points. Then count it as being inside if at least one of the shifted points is determined to be inside.
Another option is to let the line on which the intersections are counted run in different directions, not only horizontally.
But then it might not be worth the while because, as your linked article states:
"That is not generally a problem, since the edge of the polygon is infinitely thin anyway, and points that fall right on the edge can go either way without hurting the look of the polygon."

opencv: Best way to detect corners on chessboard

BACKGROUND
So I'm creating a program that recognizes chess moves. So far, I have implemented a fair number of algorithms to come up with the best results possible. What I've found so far is that the combination of undistorting an image (using undistort ), then applying a histogram equalization algorithm, and finally the goodFeaturesToTrack algorithm (I've found this to be better than the harris corner detection) yields pretty decent results. The goal here is to have every corner of every square accounted for with a point. That way, when I apply canny edge detection, I can process individual squares.
EXAMPLE
WHAT I'VE CONSIDERED
http://www.nandanbanerjee.com/index.php?option=com_content&view=article&id=71:buttercup-chess-robot&catid=78&Itemid=470
To summarize the link above, the idea is to find the upper-leftmost, upper-rightmost, lower-leftmost, and lower-rightmost points and divide the distance between them by eight. From there you would come up with probable points and compare them to the points that are actually on the board. If one of the points doesn't match, simply replace the point.
I've also considered some sort of mode, like finding the distance between neighboring points and storing them in a list. Then I would perform a mode operation to figure out the most probable distance and use that to draw points.
QUESTION
As you can see, the points are fairly accurate over most of the squares (though there are random points that do not do what I want). My question is what do you think the best way to find all corners on the chessboard (I'm open to all ideas) and could you give me a somewhat detailed description (just enough to steer me in the right direction or more if you choose :)? Also, (and this is a secondary question) do you have any recommendations on how to proceed in order to best recognize a move? I'm attempting to implement multiple ways of doing so and am going to compare methods to obtain best results! Thank you.
Please read these two links:
http://www.aishack.in/tutorials/sudoku-grabber-opencv-plot/
How to remove convexity defects in a Sudoku square?

Resources