Simple way to compute shortest paths on a polyhedron - c#

I am working on a little computational geometry library that uses Mathematica's NETLink to allow polytopes to be modeled in C# and controlled viewed via Mathematica. I hope to allow easy and exact manipulation of geometry, with a focus on geometry unfolding problems.
Currently I am looking to implement an exact shortest path's algorithm on a convex polyhedron. It's been suggested to me that I use Chen and Han's algorithm to do this, and specifically that I look at O'Rourke's implementation. However, this is a pretty big task. Given that I'm starting with quick-and-dirty techniques for the rest of the functions, I'm looking for something simpler, even if it has significantly worse performance.
There is an algorithm by Sharir and Schorr that gets the shortest path in O(n^3) time (with n I assume being the number of vertices), but I can't seem to find the paper anywhere. I'm wondering if this algorithm is indeed simpler, if any implementations of it already exists, and just if anyone has some general advice.

Related

Is A* capable of handling multiple levels (e.g.: multi-story buildings)?

I have a 3D voxel game and I'm trying to find best fitting pathfinding algorithm to use. I've been wondering if the A* algorithm is capable of handling multiple levels, for example a multi-story building and find routes through staircases or ladders.
Is this possible with A* or should I use something else?
Thanks in advance.
Any path-finding algorithms(uniform or non-uniform) can be used as long as you use them right. You have to decide first on what kind of path-finding you want to use depending on what you want to achieve.
Uniform or graph algorithms can have a lot of overhead for a multi-story building due to excessive nodes. (assuming that you are building the whole building all at once)
Non-uniforms are way slower than graph algorithms but doesn't have much of a overhead.
It really depends on what you want your characters to do, and how you will optimize it.
A* is fast, but you might want to check out some iterations of A* like jump point system.
Try using the NavMesh component based workflow first. If there is a nice staircase behaviour that can be efficiently and automatically used, NavMesh will find it.
Otherwise, you will need to use something called hierarchical search. Read an example here.

A* Pathfinding Algorithm In C#, Implement Ladder System

I have already implemented A star path-finding in C# language via grid based system. But I am trying to make a system which will use a ladder to move to a shortest distance if there is any ladder available in that shortest. But i am without any clue how to do that , i have searched online and read a lot of posts still i am confused how to do that , so it will be much helpful to me how to add the ladder feature in a A star path-finding algorithm.
Image
Thanks.
Think of your ladders as vertices in your graph. Then you just need to apply A*, which is a best-first search. This is a well-documented algorithm. For example:
A* is an informed search algorithm, or a best-first search, meaning
that it solves problems by searching among all possible paths to the
solution (goal) for the one that incurs the smallest cost (least
distance travelled, shortest time, etc.), and among these paths it
first considers the ones that appear to lead most quickly to the
solution. It is formulated in terms of weighted graphs: starting from
a specific node of a graph, it constructs a tree of paths starting
from that node, expanding paths one step at a time, until one of its
paths ends at the predetermined goal node.

Perceptual image hashing

OK. This is part of an (non-English) OCR project. I have already completed preprocessing steps like deskewing, grayscaling, segmentation of glyphs etc and am now stuck at the most important step: Identifcation of a glyph by comparing it against a database of glyph images, and thus need to devise a robust and efficient perceptual image hashing algorithm.
For many reasons, the function I require won't be as complicated as required by the generic image comparison problem. For one, my images are always grayscale (or even B&W if that makes the task of identification easier). For another, those glyphs are more "stroke-oriented" and have simpler structure than photographs.
I have tried some of my own and some borrowed ideas for defining a good similarity metric. One method was to divide the image into a grid of M x N cells and take average "blackness" of each cell to create a hash for that image, and then take Euclidean distance of the hashes to compare the images. Another was to find "corners" in each glyph and then compare their spatial positions. None of them have proven to be very robust.
I know there are stronger candidates like SIFT and SURF out there, but I have 3 good reasons not to use them. One is that I guess they are proprietary (or somehow patented) and cannot be used in commercial apps. Second is that they are very general purpose and would probably be an overkill for my somewhat simpler domain of images. Third is that there are no implementations available (I'm using C#). I have even tried to convert pHash library to C# but remained unsuccessful.
So I'm finally here. Does anyone know of a code (C# or C++ or Java or VB.NET but shouldn't require any dependencies that cannot be used in .NET world), library, algorithm, method or idea to create a robust and efficient hashing algorithm that could survive minor visual defects like translation, rotation, scaling, blur, spots etc.
It looks like you've already tried something similar to this, but it may still be of some use:
https://www.memonic.com/user/aengus/folder/coding/id/1qVeq

C# generic graph search framework

I have now coded up various graph search (A*, DFS, BFS, etc..) algorithms many times over. Every time, the only real difference is the actual search states I am searching over, and how new states are generated from existing ones.
I am now faced with yet another search-heavy project, and would like to avoid having to code and debug a general search algorithm again. It would be really nice if I could define a search state class, including information for generating successive states, heuristic cost, etc, and just plug it in to some kind of existing search framework that can do all of the heavy lifting for me. I know the algorithms aren't particularly difficult to code, but there are always enough tricks involved to make it annoying.
Does anything like this exist? I couldn't find anything.
Perhaps QuickGraph will be of interest.
QuickGraph provides generic
directed/undirected graph
datastructures and algorithms for .Net
2.0 and up. QuickGraph comes with algorithms such as depth first seach,
breath first search, A* search,
shortest path, k-shortest path,
maximum flow, minimum spanning tree,
least common ancestors, etc
This sounds like a perfect use case for either a Delegate or a Lambda Expression.
Using Lambda Expressions for Tree Traversal – C#
http://blog.aggregatedintelligence.com/2010/05/using-lambda-expressions-for-tree.html

Line-breaking algorithm

Where can I find an efficient algorithm for breaking lines of text for formatted display?
One approach to this very problem is addressed in the book Introduction to Algorithms (Cormen, Leiserson, Rivest, Stein) as problem 15-2.
It takes the approach that a nicely broken block of text has as even spacing at the end as possible, punishing large differences.
This problem is solvable using dynamic programming.
Naturally this is only one approach to the problem, but in my opinion it at least looks better than the greedy algorithm.
I'm not much for putting my solutions to textbook problems on the Internet, so I'll leave it to you to either solve it or Google for a solution, in order to get the exact algorithm needed.

Categories