Is there a way of visualising isolines in 3D space (x, y and z)?
I am basically trying to show the flow of some points based off the velocities of these points and the example on the VTK website only does this in 2D (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/LabelContours) and I don't know how to adapt this. I have tried replacing the plane variable with a 3D glyph but I am getting a lot of errors and nothing appears in the render window
I am not sure if what you want is an isoline. Because an isoline is defined on a scalar field, which means one attribute at each point. Since you are talking about velocity of points, it seems to me you are dealing with a vector field. In that case, you should not create an isoline, but a streamline instead. Take a look at this example, it might help you.
the vtkContourFilter class works for both 2D and 3D. there is an example here.
Related
I am not a very experienced Qt C++ Programmer, but unfortunately I have to create a 3D Cube containing 8x8x8 points.
I already found the Qt tutorial to create a simple cube, but I am completely lost on how to make it hollow and draw the 512point matrix within the cube. Furthermore the goal is to change the color of specific points within this matrix.
Anybody know how to proceed?
Thank you in advance!
https://github.com/peteristhegreat/circles-in-a-cube
Check out the awesome example I put together!
Basically I took the Grabber example and did some modifications to it.
http://doc.qt.io/qt-5/examples-widgets-opengl.html
http://doc.qt.digia.com/qt-quick3d-snapshot/qt3d-examples.html
http://doc.qt.digia.com/qt-5.2/qtopengl-grabber-example.html
It looks like you could modify this one to something similar.
http://doc.qt.io/qt-5/qtopengl-hellogl2-example.html
The core features of what is going on, is holding on to information about the individual spheres and modifying them when you need to.
To hold the pointers to sphere objects, I used two different lists.
One is a straight forward QList, and the other is a 3D Vector. The 3D QVector allows you to access a sphere pointer with spheresInSpace[x][y][z], where x,y,z are any integer between 0-7.
To change the colors of the spheres, I change the reflectance values.
Hope that helps.
I don't really know how to explain it in a better way, so please look at the following images :
This is what I create for the moment
This is what I whish to create instead
I am currently using C++ with Qt 4.8.
Do you know a way that would allow me to reach my goal ? Using a library or a transformation matrix ? Or something else ?
I am a total newbie to image manipulation, so every advice is precious for me.
Thanks
EDIT :
I draw each colored pixel from Lat/Long measures, if it can help.
Use what is called a morphological operator. In this case, you would require the 'open' operator. OpenCV provides a pretty good implementation (and documentation of these) which can be found here.
Draw circles instead of points is all I can think of. Creating a triangle mesh is tricky with the concave elements of the distribution.
EDIT: Just looked at the full size version of the image and wondered if the data set is stored radially? You could scan adjacent radial lines and try to match up the changes in value along each line to form a set of quads. There will be a large number of edge conditions to consider though.
EDIT2: Alternatively, form a uniformly distributed set of quads and interpolate the vertex colours.
you can start by increasing the size of the points,
you could create a triangle mesh by using a sweepline algorithm:
sort the points by lat
keep a subset sorted by long
when you add a point compare to the 4 adjacent points and add triangles to the "to draw" set (remove points too far away from the current lat as needed)
with opengl you can use an index buffer to hold which point should be drawn
I need to unwrap a 3D fingerprint (convert to 2D). I cannot just remove z coordinate and make it 2D. I need to unwrap it in a manner that it resembles as if the fingerprint would have been scanned as 2D at first place.
The input I am having is a ply file with just the x,y,z coordinates.
Any suggestion? Any software out there that will do it for me directly?
I heard there are some spring solvers that will do it for me. Any idea how can I implement it?
I want to do it the easy way rather than getting into too much complexity.
Thanks!
This is a problem in a field called distance geometry. This discipline attempts to project N dimensional points into lower dimensions, whilst attempting to preserve the original distances as closely as possible.
The simplest algorithm I have ever encountered to solve this problem is:
http://www.dimitris-agrafiotis.com/Papers/jcc20078.pdf
I coded this up in a very short time.
Welcome to SO btw....
I cannot just remove z coordinate and make it 2D. I need to unwrap it
in a manner that it resembles as if the fingerprint would have been
scanned as 2D at first place.
Well, that's pretty much the way it would be done, isn't it?
Perhaps with a filter on z so that points far away from the "camera" are not scanned?
I'd like to make a game where the terrain is not even and is based on a png. How s this done in theory, given the object's vec2 and its angle, because if for instance there is a hill, the character will rotate based on the angle of the hill. Thanks
2d like mario
I think you are talking about a heightmap which is you PNG which is then converted to a 3D triangle mesh. You need to use the information from the mesh (or PNG color value) to calculate the current height where you should place your character.
If this is a flying character your pretty much done here, but in your case you need to calculate the normal vector of the current triangle the character is standing on. This is pretty simple using the cross product of the two triangle vectors (V2 - V1) x (V3 - V1). That should be your characters angle as well. You could maybe average this vector by including normals from the surrounding trangles as well.
Btw, when you have the normals of the triangle you can apply some basic shading to the ground as well.
Added: The OP changed the question to be a 2D problem. The above approach still works, but it much easier in 2D.
Use the height values not as triangles but as lines (silhouette) and calculate the normal of the current line instead. That is, create a vector, v, between the current height value and the next. Then the normal of that vector is n = <-v.y, v.x>. Use that as the angle of your character.
You need a mapping function that converts the PNG data to a 3-d representation... This mapping function can be simple, as in simply interpreting greyscale values in the PNG as altitude or via human guidance, or it can be complex, as in shadow detection used in advanced computer vision algorithms. In either case, you would then move your character based on the data gleaned thru the mapping function.
In c++, I would suggest looking for a 3d-gaming engine that support more than just plain terrains.
You could start with this list
That is of course, if you're not trying to start from scratch, in which case you need to look for algorithms first.
Edit:
since it's the game and not the terrain that is 2d, if you want to make your environment out of an image, you're in for quite some edge-detection.
From My last question: Marching Cube Question
However, i am still unclear as in:
how to create imaginary cube/voxel to check if a vertex is below the isosurface?
how do i know which vertex is below the isosurface?
how does each cube/voxel determines which cubeindex/surface to use?
how draw surface using the data in triTable?
Let's say i have a point cloud data of an apple.
how do i proceed?
can anybody that are familiar with Marching Cube help me?
i only know C++ and opengl.(c is a little bit out of my hand)
First of all, the isosurface can be represented in two ways. One way is to have the isovalue and per-point scalars as a dataset from an external source. That's how MRI scans work. The second approach is to make an implicit function F() which takes a point/vertex as its parameter and returns a new scalar. Consider this function:
float computeScalar(const Vector3<float>& v)
{
return std::sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}
Which would compute the distance from the point and to the origin for every point in your scalar field. If the isovalue is the radius, you just figured a way to represent a sphere.
This is because |v| <= R is true for all points inside a sphere, or which lives on its interior. Just figure out which vertices are inside the sphere and which ones are on the outside. You want to use the less or greater-than operators because a volume divides the space in two. When you know which points in your cube are classified as inside and outside, you also know which edges the isosurface intersects. You can end up with everything from no triangles to five triangles. The position of the mesh vertices can be computed by interpolating across the intersected edges to find the actual intersection point.
If you want to represent say an apple with scalar fields, you would either need to get the source data set to plug in to your application, or use a pretty complex implicit function. I recommend getting simple geometric primitives like spheres and tori to work first, and then expand from there.
1) It depends on yoru implementation. You'll need to have a data structure where you can lookup the values at each corner (vertex) of the voxel or cube. This can be a 3d image (ie: an 3D texture in OpenGL), or it can be a customized array data structure, or any other format you wish.
2) You need to check the vertices of the cube. There are different optimizations on this, but in general, start with the first corner, and just check the values of all 8 corners of the cube.
3) Most (fast) algorithms create a bitmask to use as a lookup table into a static array of options. There are only so many possible options for this.
4) Once you've made the triangles from the triTable, you can use OpenGL to render them.
Let's say i have a point cloud data of an apple. how do i proceed?
This isn't going to work with marching cubes. Marching cubes requires voxel data, so you'd need to use some algorithm to put the point cloud of data into a cubic volume. Gaussian Splatting is an option here.
Normally, if you are working from a point cloud, and want to see the surface, you should look at surface reconstruction algorithms instead of marching cubes.
If you want to learn more, I'd highly recommend reading some books on visualization techniques. A good one is from the Kitware folks - The Visualization Toolkit.
You might want to take a look at VTK. It has a C++ implementation of Marching Cubes, and is fully open sourced.
As requested, here is some sample code implementing the Marching Cubes algorithm (using JavaScript/Three.js for the graphics):
http://stemkoski.github.com/Three.js/Marching-Cubes.html
For more details on the theory, you should check out the article at
http://paulbourke.net/geometry/polygonise/