Marching cubes? - opengl-es

I have an object made of points, lets say its point cloud, i want to render object from those points, i want object to look like those points were wrapped in a sheet of paper. I want to animate it, so first thing that came on my mind was marching cubes, but my object will not be a ball or cube, it will morph, is there any simpler approach than marching cubes?

Depending on what you mean by "wrapped" a 3D convex hull may produce the effect that you want.
Animate your vertices however you want and re-run the hull algorithm each time.

The Marching Cubes algorithm seems like the best fit to what you're looking for -- not all point clouds are convex. The algorithm may seem intimidating because of the large lookup table, but it is actually pretty straightforward. I have posted an example (using Three.js) at:
http://stemkoski.github.com/Three.js/Marching-Cubes.html

This seems like what you're looking for:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=25

Related

How can I efficiently implement raycasting through a 2D mesh?

I'm implementing a nav mesh pathfinding system and I need to be able to raycast between two points in the mesh and get a list of all edges crossed by the ray. Obviously I'll need to be able to test for individual line intersections, but I expect there to be an efficient way of picking which lines actually need to be checked rather than brute force iterating over every edge in the entire mesh. Does anyone know how I might go about that?
If your mesh is rectangular grid, consider effective method of Woo and Amanatides from article "Fast Voxel Traversal Algorithm..."
Implementation example

How can I create an internal spiral for a polygon?

For any shape how can I create a spiral inside it of a similar shape. This would be a similar idea to bounding (using Minkowski sum). Rather than creating the same shape inside the shape though it would be a spiral of same shape.
I found this - http://www.cis.upenn.edu/~cis110/13su/lectures/Spiral.java
It creates a spiral based on the parameters passed so it can be for any regular shape.
I want the above for all shapes i.e. irregular polygons too.
I am not hugely familiar with geometric terminology but I have looked up Involutes and an Internal Spiral Search Algorithm too but haven't been useful to me.
Does anyone have any idea where I'd find an algorithm such as this or at least ideas of how I'd come up with one?
this task is extremly hard to do.
need to have the boundary polygon you want to fill with spiral
I think you have it already
create new smaller polygon by shifting all lines inwards by the step.
It is similar to create stroke line around polygon. Step is the screw width so at start of polygon it is 0 and on the end it is d
remove invalid lines from the newly generated screw
Some lines on corners and curvatures will intersect. This is very hard to detect/repair reliably see
this for basics
repeat (do next screw) ... until no space for screw found
But now after the first screw the step is always d this will not necessarily fill the whole shape. For example if you have some thinner spot on shape it will be filled much more faster then the rest so there can still be some holes left.
You should detect them and handle as you see fit see
Finding holes in 2d point sets
Be aware detection if the area is filled is also not trivial
This is how this approach looks like:
[Notes]
If you forget about the spiral and want fill the interior with a zig zag or similar pattern then this is not that hard.
Spiral filling makes a lot of hard geometric problems and if you are not skilled in geometry and vector math this task could be a too big challenge for beginner or even medium skilled programmer in this field to make it work properly. That is at least my opinion (as I done this before) so handle it as such.
I worked on something like this using offsets from the polgyon based on medial axis of Voronoi diagram. It's not simple. I can't share the code as it belongs to the company I worked for and it may not exactly fit your needs.
But here are some similar things I found by other people:
http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf
http://www.cosy.sbg.ac.at/~held/teaching/seminar/seminar_2010-11/hsm.pdf

What algorithms exist for finding a bounding surface to a set of points?

Suppose you have a point cloud, and you want a surface that wraps those points to enclose them all, and wrap them fairly tightly so it intersects with the outer points in the cloud - how do you generate this wrapped surface? That is, where some or many points may be inside the volume and so the surface does not need to intersect them, only enclose them, but the surface should be a good fit for the "outside" layer of points.
(I'm aware of triangulation algorithms (such as Delaunay) for fitting a mesh through - I think - all points in a set, but I don't think that algorithm will work unless there's a good way to discard all but the outer shell of points. Feel free to point out approaches I'm missing here, too!)
What algorithms (or even search keywords beyond "mesh", "fit", "wrap" "point cloud" etc) should I look for?
I think that you're looking for a convex hull algorithm. The convex hull is the shape you get if you were to wrap a set of points in some sort of wrapping paper, leaving the outermost boundary. I may be misinterpreting your question, but this sounds like exactly what you're looking for.
Hope this helps!
I think, what you are searching for is a convex hull.
For algorithms to compute it, take a look here.
You can use TetGen to compute the convex hull or, if needed, a surface triangulation in the case your point set is not convex.
I am not sure this is useful to you, Mathematica has a TetGenLink interface to TetGen.

Minimize RMSD between two sets of points

I need to plot the transformation of a 3d object against time. I have the 3d shapes for each moment in time, but they are not guaranteed to be geometrically well placed, so I cannot just render them and slap the pictures together into a movie. I therefore need to align them so that they are pleasantly and consistently oriented with respect to the camera.
What I would do is to take pairs of 3d objects, center them with respect to the geometric center, then perform the proper rotation around some axis so to minimize the RMSD among the points. That's not hard, but I'd enjoy to know if there's something ready out there so not to reinvent the math (and the code). Of course, I'd also accept objections to my method.
I'm working in python, but any code will do, and I will convert it.
The Kabsch algorithm does that. See: http://en.wikipedia.org/wiki/Kabsch_algorithm.
It appears that what I need is the Kabsch algorithm.

Ray-Polygon Intersection Point on the surface of a sphere

I have a point (Lat/Lon) and a heading in degrees (true north) for which this point is traveling along. I have numerous stationary polygons (Points defined in Lat/Lon) which may or may not be convex.
My question is, how do I calculate the closest intersection point, if any, with a polygon. I have seen several confusing posts about Ray Tracing but they seem to all relate to 3D when the Ray and Polygon are not on the same Plane and also the Polygons must be convex.
sounds like you should be able to do a simple 2d line intersection...
However I have worked with Lat/Long before and know that they aren't exactly true to any 2d coordinate system.
I would start with a general "IsPointInPolygon" function, you can find a million of them by googling, and then test it on your poly's to see how well it works. If they are accurate enough, just use that. But it is possible that due to the non-square nature of lat/long coordinates, you may have to do some modifications using Spherical geometry.
In 2D, the calculations are fairly simple...
You could always start by checking to make sure the ray's endpoint is not inside the polygon (since that's the intersection point in that case).
If the endpoint is out of the line, you could do a ray/line segment intersection with each of the boundary features of the polygon, and use the closest found location. That handles convex/concave features, etc.
Compute whether the ray intersects each line segment in the polygon using this technique.
The resulting scaling factor in (my accepted) answer (which I called h) is "How far along the ray is the intersection." You're looking for a value between 0 and 1.
If there are multiple intersection points, that's fine! If you want the "first," use the one with the smallest value of h.
The answer on this page seems to be the most accurate.
Question 1.E GodeGuru

Resources