How to triangulate MATLAB mesh when delaunay failed - matlab-figure

I need to perform a triangulation of matlab mesh format variables. Function surf do it perfectly somewhere internally, but delaunay failed. I think I just did not understand how mesh format works in MATLAB. To clarify below the example of code.
Generate meshes with coordinates:
close all
clear all
N=10;
R=5;
r=1;
u=linspace(0,2*pi,N);
v=linspace(0,2*pi,N);
[u,v]=meshgrid(u,v);
x=(R+r.*cos(v))*cos(u);
y=(R+r.*cos(v))*sin(u);
z=r.*sin(v);
Plot with surf()
surf(x,y,z,'EdgeAlpha',0.1);
view([-52,64])
set(gca,'Color','none','Box','off')
axis off
Plot after triangulation
%% TRIANGULATION
TRI=delaunay(x,y,z);
trisurf(TRI,x,y,z,'EdgeAlpha',0.1)
view([-52,64])
set(gca,'Color','none','Box','off')
axis off
Could You explain what is wrong and how should I obtain correct TRI variable?

Related

Using a homography matrix and decomposing it to find the orientation of a plane fixed in the centre

I currently have two images of a plane in real life from straight above. One to use as a reference image, and another when the plane has undergone a rotation fixed at the centre of the plane thus changing its orientation. The camera stays at a constant position.
I was wondering if I found the homography matrix of this rotation in opencv and then decomposed the homography matrix in order to find the rotation matrix whether this would yield accurate results and I would be able to find the three angles needed to describe the planes rotation in euclidean coordinates to a reasonable degree of accuracy.
Thanks

Triangle pattern GLSL shader

Is there any simple algorithm like Voronoi diagram to divide any rectangular plane to triangles, eventually, using # of pre-defined points.
To be honest, I have to write a very simple fragment shader like this.
Theoretically, this Voronoii shader could be 'upgraded' by Delaunay triangulation
but wanna find the more elegant solution.
The first thing that comes to my mind is to create n random points (with specific seed) to fill a cylinder volume. The triangle points will be intersection of lines between those points and plane going through the axis of cylinder. The animation would be simply done by rotating the plane ...
I see it something like this:
So the neighboring points should be interconnected with each other. Forming tetrahedrons that fills the volume of the cylinder. So create uniform tetrahedron grid and add random noise to the points position (with specific seed).
This whole task is very similar to rendering cross section of 4D mesh see:
4D rendering techniques
As the 4D simplex is also tetrahedron. The only diference is you are in 3D and cutting by 3D plane.
You can reverse-engineer this example shadertoy.com/view/MdfBzl
like I did. Thanks to mattz.

How to avoid adding nodes on a line during delaunay triangulation

I am using the open source program triangle.c (A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator) which can be found here. I have to use this program to mesh a 2d circle and then rotate it to get 3d mesh of a sphere. Once I specify the points on the boundary, the program adds additional nodes inside the region and generates triangular meshes. However I would like to avoid adding nodes on the axis about which I want to rotate. Is there a good way to achieve this?
the 2d geometry i want to mesh

How can we compute the minimum bounding sphere enclosing a 3D mesh object?

I want to plot a sphere unit around a 3D object (.obj format file) with matlab, in order to guarantee a normalization of all the objects in my DB, and so on to achieve the scale invariance. I found in the state of the art that there are some algorithms implemented with C++ like Gartner's algorithm that is the fastest https://www.inf.ethz.ch/personal/gaertner/miniball.html, Fisher's algorithm which is more efficient for high dimensions https://github.com/hbf/miniball or welzl'one, or Mogiddo's algorithm too.
My question is: does the function sphere in matlab do the same thing, so all we have to do is to change the center of the sphere, or there is a specific matlab implementation for one of those algorithms above?

Mesh vertex rotation in Matlab

I have a 3D matrix in Matlab that was created using a volume MRI scan. I then use matlab toolbox iso2mesh (vol2surf) to convert this volume to a surface mesh and then extract the nodes/vertex coordinates and faces of this mesh.
However I find that this mesh is in the wrong coordinate system. I have tried to use the imrotate to rotate the matrix as well as rot90 to rotate the nodes matrix but it rotates the image only around the y-axis while I need rotation around both x and y axes.
Does anyone have any advice on what function I can use for this?
Thanks!

Resources