what does the output of 3D delaunay triangulation represent? - matlab

I want to know what does the ConnectivityList in Delaunay triangulation in Matlab represent? Why does it have 4 columns?

Looking at Matlab's delaunayTriangulation class documentation,
the ConnectivityList is a triangulation connectivity list represented as a matrix.
Each row of the matrix corresponds to a tetrahedron (for 3D), or a triangle (for 2D).
Each element in the row is one of 4 vertex IDs of the tetrahedron (or for 2D, one of 3 vertex IDs of the triangle), a vertex ID being the row number of one of the points you provided to delaunayTriangulation().

Related

How can I visualise the 3D voronoi diagram in MATLAB?

I don't understand the documentation that describes the visualisation of voronoi regions in MATLAB.
the documentation says the following:
You can plot individual bounded cells of an N-D Voronoi diagram. To do this, use the convhulln function to compute the vertices of the facets that make up the Voronoi cell. Then, use patch or other plotting functions to generate the figure.
I have a set of 3D points (P) that I calculated voronoin for using [v,c]=voronoin(P)
What do I do next to visualise this ?
voronoin always generates a row of inf values in v. So how can I use v to generate/visualise the voronoi regions/diagram?
Thanks

Triangulated surface into 2D matrix - MATLAB

I have a 3D reconstruction that is of the format: vertices and faces.
It was read in by an STL, or an OBJ file, and I believe the terminology of this surface format is triangulated.
This is nice to visualise using trisurf, however I need the representation of my surface to be a 2D matrix.
Specifically: I have a 3 column matrix named vertices, and another 3 column matrix named faces. They do not have the same number of rows. I want a 2D matrix, where every cell in the matrix is the height of the surface.
Is this possible? How can this be done?

Embedding 2d plot into a 3d plot in matlab?

I have a set of data vectors z that has this 2d plot
How would I go about embed this set of data into a 3d plot like this in matlab? I'm asking for advice and suggestions. The theory I'm trying to employ is "for each data vector~zj, “copies” the data vector intothe first two entries of a 3D data vector~yjand then computes the squared length of~zj as the third entry of~yj. " or kernel trick.
Your 2d data will somehow be in the form, that you have x-coordinates and y-coordinates. Let's say you have a vector x and a vector y for simplification.
As you found out the plot3-function proivdes functionality to plot arbitrary points in 3d without the need of generating a mesh. What you need additionally is a third vector z with data for the 3rd dimension.
So what else can you do? The thing I am thinking about is rotating the plane you are plotting you "2d" data:
Rotational matrices can be seen here:
https://en.wikipedia.org/wiki/Rotation_matrix

MATLAB: converting 3d plane into 3d matrix pixel locations

I am trying to get a slice of an elongated object in a 3d matrix (227x297x187 binary) that is orthogonal to its orientation..i.e. output image would be a 2d cross-section.
I was thinking the best way to do this would be to find a vector giving the orientation at some point on the object (so for a cross-section at the 40th slice I get the location of centroids at the 30th and 50th slices and find the vector between them), then get a list of pixels corresponding to a plane orthogonal to that vector at the desired slice (along centroid of object at 40th slice), and then retrieve the values in the matrix corresponding to those locations. Assuming the code I have attached finds the plane, I can plot it with surf() but don't know how to translate that into pixel locations in the matrix to generate the values for the 2d cross-section.
startslice=30;
endslice=50;
startnums=bwconncomp(binMATRIX(:,:,startslice));
startnums=regionprops(startnums,'Centroid');
endnums=bwconncomp(binMATRIX(:,:,endslice));
endnums=regionprops(endnums2,'Centroid');
midnums3=bwconncomp(binMATRIX(:,:,(startslice+(endslice-startslice)/2)));
midnums3=regionprops(midnums,'Centroid');
startstuff=[startslice, startnums.Centroid];
endstuff=[endslice, endnums.Centroid];
midstuff=[(startslice+(endslice-startslice)/2), midnums.Centroid];
nullstuff=null(endstuff-startstuff);
A=nullstuff(:,1);
B=nullstuff(:,2);
[x,y]=meshgrid(A,B);
z=1-x-y;
surf(x+midstuff(1),y+midstuff(2),z+midstuff(3))

Compute multiple faces connected at vertices from normal vectors

I have a set of 8 normal vectors in 3D space. I need to plot a cuboid with lateral wings from these vectors:
whereas vectors 4 to 6 are just the negatives (opposite sides) of the first three and the last two vectors are identical to the first one and make up the wings.
The goal is to plot this object with each surface having a different color so that I can count the pixels of each color afterward for different sets of normal vectors (i.e. determining the visibility of partially obstructed surfaces).
I have found the patch function which can plot polygons with individual colors and takes the coordinates of the vertices for input. However, I do know the dimension of each surface, but the coordinates of the vertices need to be somehow calculated for each set of normals vectors. Any suggestions on how to approach this task?
EDIT
I may have found a solution: I just noticed that view allows defined azimuth and elevation angles and thus "rotation" of the object. With the compution of azimuth and elevation from the normal vectors, the calculation of the vertices becomes unnecessary.