Search Comments and Ratings

go

   
Date File Comment by Comment Rating
26 Jan 2015 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Ajay

Ajay (view profile)

Very dependable code, thanks.

Any recommendations for a 3-D point-in-polygon test, including non-convex cases?

5
30 Dec 2014 DUALMESH - Polygonal mesh construction. Construct polygonal "dual" meshes from 2-simplex triangulations embedded in R^3. Author: Darren Engwirda

Darren Engwirda (view profile)

liu

liu (view profile)

5
23 Dec 2014 DUALMESH - Polygonal mesh construction. Construct polygonal "dual" meshes from 2-simplex triangulations embedded in R^3. Author: Darren Engwirda

Darren Engwirda (view profile)

Ivan Trenchev

5
17 Dec 2014 DUALMESH - Polygonal mesh construction. Construct polygonal "dual" meshes from 2-simplex triangulations embedded in R^3. Author: Darren Engwirda

Darren Engwirda (view profile)

Darren Engwirda

Darren Engwirda (view profile)

@Peter: Thanks for pointing that out. It seems that the behaviour of ISMEMBER has been changed in recent MATLAB releases and will no longer accept empty input arrays. DUALMESH has been updated to workaround this issue and should now run for both new and old MATLAB releases.

Comment only
16 Dec 2014 DUALMESH - Polygonal mesh construction. Construct polygonal "dual" meshes from 2-simplex triangulations embedded in R^3. Author: Darren Engwirda

Darren Engwirda (view profile)

Peter

Peter (view profile)

I get an error (below). I was doing the bunny demo, using R2013b

Error using ismember>ismemberR2012a (line 506)
Inputs A and B must be matrices with the same number of columns in the 'rows' case.

Error in ismember (line 103)
[varargout{1:max(1,nargout)}] = ismemberR2012a(A,B,logical(flaginds(1)));

Error in makedual2>markedge (line 147)
ke = ismember(ee,sort(ec,2),'rows') ;

Comment only
27 Oct 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

henripes

Hi,
does anyone know why this hit me with this problem:
"Checking Geometry
Undefined function or variable 'wbar'.
Error in meshfaces (line 127)
close(wbar);
Error in facedemo (line 39)
meshfaces(node,edge,face,hdata); "

Im trying to run this:

node = [0.0, 0.0; .4,0.0;0.2,0.5;0.4,0.5;0.2,1; 0.0,1; ...
0.5,0;0.5,1;...
1,0;1,1];

edge = [1,2; 2,3; 3,4; 4,5;5,6;6,1;...
2,7;7,8;8,5;...
9,10;10,11;11,8];

face{1} = [1,2,3,4,5,6];
face{2} = [7,8,9,4,3,2];
face{3} = [10,11,12,8];

hdata.hmax = 0.05;

which should be a sawtooth grating between air layers.

Comment only
23 Oct 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

henripes

Hi, finally some clear meshing program also for beginners! Thanks! There is anyhow a problem with "DSEARCH" in mesh_collection(6). Is it anyhow possible to repair it?

Comment only
15 Oct 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Seth

Seth (view profile)

We have been using this function since early 2010 and has proved very valuable for creating basic 2D meshes for finite element analysis.

The only issue is that with newer releases (since R2012?) the "tsearch" function is no longer supported by Matlab.

We have used the fix proposed by Mike (23 Sep 2013) and it has worked reasonably well for our problems and was fairly simple to fix in the source code.

Thanks again Darren & Mike for the quick fix.

This type of submission is one reason the File Exchange is simply awesome.

Comment only
29 Sep 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Tanvir Faisal

there are few functions seem to be missing such as tsearch, pointLocation. any idea??

Comment only
10 Sep 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Martin

Martin (view profile)

5
01 Sep 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

hust

hust (view profile)

unstructured mesh generator

Comment only
20 Aug 2014 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Luca

Luca (view profile)

Hi,

running the following code, with N = 1000000, never gives inpoly faster than inpolygon.For "small" N (N=100-1000), they alternate.
However, when running the examples provided in polydemo.m, inpoly is consistently faster than inpolygon.

Am I doing anything wrong? A graphical check (commented in the code) gives what seems to be right, so I think I'm using the function as I should. Anyway, I don't see any improvement in speed, the contrary (for large N).

%%% sample code %%%%%%
for k=1:10

small_box = [ 1/3 1/3; 1/3 2/3; 2/3 2/3; 2/3 1/3];
N = 1000000;

A = rand(N,1);
B = rand(N,1);

% figure; hold on;
% plot(A,B,'.')
% patch([small_box(:,1); nan],[small_box(:,2); nan],ones(5,1))

tic; in = inpolygon(A,B,small_box(:,1),small_box(:,2)); t1=toc;
tic; in2 = inpoly([A B],small_box); t2=toc;

time_in_sec = struct('inpolygon',t1,'inpoly',t2);
if t2<t1
fprintf('inpoly is %f seconds faster\n',t1-t2)
else
fprintf('inpolygon is %f seconds faster\n',t2-t1)
end

% plot(A(in),B(in),'.r')
% plot(A(in2),B(in2),'.g')

end
%%%%%%%%%

Comment only
04 Aug 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Ademiloye Adesola

5
04 Aug 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Ademiloye Adesola

Excellent work! I suggest Prof Darren should try to implement some of the bugs fixed in the comments below when preparing the newer version.

4
06 Jul 2014 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

Manuel Diaz

5
02 Jul 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Siva Srinivas Kolukula

Excellent ...code..very useful for FEA..

5
23 Jun 2014 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

MARIO CASTRO GAMA

Nice, used it in a problem with an unstructured grid and worked perfect.

5
17 Jun 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Putra Arri Sandhi

5
22 May 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

liron

liron (view profile)

you are a genius!!!! awesome addition... thanks very helpful....

5
10 Apr 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Thomas Benson

Thomas Benson (view profile)

This is a great submission! A minor change was required for my application. Reason: The triangulation tends to be slightly over-refined on complex boundaries. For some applications this is a bonus, but for hydrodymanic modelling it is not really necessary. I therefore replaced the line in 'quadtree.m' (about line 64) which reads:

L = 2.0*dist2poly(wm,edgexy,2.0*len);

with the following:

L=len;

This helps prevent over refinement and a nice mesh. Excellent work Darren!

5
26 Feb 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Abdulrahman

5
03 Feb 2014 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Abdulrahman

Great work thank you very much.

I've got a question I appreciate if any one could help, where exactly the changes can take place ? I know it would be most about the geometry but I wasn't able to play with it.

5
19 Dec 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Marcus

Marcus (view profile)

I'm doing something that must be pretty standard. I'm needing to mesh a 2d domain with an internal boundary. My approach has been to create 'holes' with zero area, which imposes duplicate nodes. Mesh2d seems able to remove these and gives e.g., the message 'WARNING: 2 duplicate node(s) removed'. However, with some of my examples I get the message: 'Warning: Duplicate data points have been detected. Some data points do not map to vertices in the triangulation. To avoid this behavior, call UNIQUE on the data points prior to calling DELAUNAY.' Now what I would like to know is whether this problem in the geometry is fixed by Mesh2d? I include a simple example of the sort of problem I'm interested in.
PS. Mesh2d has proved invaluable - Thank you!
***********************************
p1 = [0 0; ...
3 0; ...
3 3; ...
0 3];
p2 = [0.5 1.5; ...
1.5 1.5; ...
1.5 2.5; ...
1.5 1.5; ...
0.5 1.5];
n1 = size(p1,1);
n2 = size(p2,1);
c1 = [(1:n1-1)', (2:n1)'; n1, 1];
c2 = [(1:n2-1)', (2:n2)'; n2, 1];
node = [p1; p2];
cnect = [c1;c2+n1];
hdata.hmax = 1;
[p,t] = mesh2d(node,cnect,hdata,[]);
*****************************************

Comment only
22 Oct 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Richard Clarke

Great routine, although I was having some issues removing redundant nodes until I changed the following in line 66 of changegeometry.m

del = nNode-i(end);

-->

del = nNode-length(i);

Comment only
23 Sep 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Mike

Mike (view profile)

This is a powerful and useful tool. It is well written and documented.

Since Mathworks abandoned tsearch, simply calling tsearchn instead works for me. Moving to tsearchn requires two changes that I am aware of:

mytesearch.m Line 68:
i(j)=tsearchn([x y],t,[xi(j) yi(j)]);

meshfaces.m Line 199:
i = tsearchn(ph,th,p);

I do not agree with the solution proposed by Chen and Barnhart. Delaunay triangulations are not unique. Their approach effectively generates a separate triangulation and searches over it. Mapping such results into the original Mesh2D triangulation is ill-advised.

5
22 Jun 2013 Fast Sparse LU substitution A dedicated mex-file for use with UMFPACK to complete the forward and back substitution quickly Author: Darren Engwirda

Darren Engwirda (view profile)

Sergeech

1
08 May 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Elias Pirayesh

There are some useful examples on meshing a 3D surface on: http://persson.berkeley.edu/distmesh/

Comment only
07 May 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Evgeny

Evgeny (view profile)

How can I use it on 3D surface?
Is there some algorithm to create unstructured triangular meshes for 3D geometry?

5
03 Apr 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

William Barnhart

One more fix. In quadtree.m, near line 528 (right before %Undo rotation, p=rotate(p,-theta)), add:

% remove duplicate nodes
goodid=find(h~=0);
p=p(goodid,:);
h=h(goodid);
for i=1:length(goodid)
t(t==goodid(i))=i;
end

So that's three places to fix with the comments below:
meshfaces.m, line 203
mytsearch.m, line 69
quadtree.m, line 528 (or thereabouts)

Comment only
02 Apr 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

William Barnhart

**Correction**

In my tsearch, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));

with:
for k=1:size(t,1)
temp=inpolygon(xi,yi,x(t(k,:)),y(t(k,:)));
i(temp)=k;
end

Then, no need to worry about delaunay triangulations

Comment only
02 Apr 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

William Barnhart

Tsearch fix courtesy of Rowena Lohman.
tsearch.m needs to be replaced in two locations. First:

in meshfaces.m, line 203 replace:
i=tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));

with:

for j=1:size(th,1)
temp=inpolygon(p(:,1),p(:,2),ph(th(j,:),1),ph(th(j,:),2));
i(temp)=j;
end

In mytsearch.m line 69, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));

with

t = DelaunayTri([x y]);
i(j)= pointLocation(t,[xi(j) yi(j)]);

This uses DelaunayTri which is being fazed out, but delaunayTriangulation can be equally used

Comment only
20 Mar 2013 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Thomas Benson

Thomas Benson (view profile)

Hi Darren, thanks for this submission. Is there a version of Mesh2d that works with V2012b ? (TSEARCH.m no longer works and requires the use of DelaunayTri.m). Cheers.

Comment only
05 Mar 2013 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Joseph

Joseph (view profile)

Not sure when matlab changed this but in matlab 2012b the inpolygon function works just slightly faster than this one. Still great work!

5
04 Feb 2013 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

Michael

Great! any plans to make a version with filled contours? (like contourf) that'd be even better!

5
30 Jan 2013 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

Kim Nguyen

could somone please help, ive tried following the examples but it keeps telling me i dont put in enough arguments.
i have x,y, and dz as my coords

Comment only
04 Oct 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Elliot

Elliot (view profile)

I too need an update to replace tsearch function. The suggested replacement is not appropriate for me as performing 'DelaunayTri' within your routine can alter the triangulation depending on initial inputs i.e. I have specified internal boundaries, DelaunayTri does not respect these boundaries when implemented in the suggested way.

Is a modified/updated version in consideration?

thanks

Comment only
26 Sep 2012 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

Nachiket Patil

5
21 Aug 2012 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

David

David (view profile)

Thank you Darren. I appreciate your superb contribution.

5
21 Jul 2012 Fast sparse matrix vector product sparse matrix vector product Author: Darren Engwirda

Darren Engwirda (view profile)

Christopher Kanan

I'm not sure why, but it is much slower on R2012a. I ran the example and the inbuilt required 0.01 s and this version required 10 seconds.

I doubt MATLAB could improve that much, so I'm guessing some sort of optimization used in the mex code is no longer functional.

3
17 Jul 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Song Chen

Find the following line:

p = node;
e = edge;
i = tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));
Change it to

p = node;
e = edge;
dt = DelaunayTri(ph);
i = pointLocation(dt,p);

These two codes should be equivalent.

Comment only
17 Jul 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Jody Klymak

Jody Klymak (view profile)

tsearch is gone as of 2012a. Any hope of a modification to use DelaunyTri?

Comment only
28 Jun 2012 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Edison Lee

Hi was wondering could you tell me from which conference/journal paper this function algorithm is based from?

Thanks.

Comment only
17 Jun 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

cleidinei

5
15 Jun 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Richard Crozier

I think Maxim is right:

>> A = triarea([0,0; 1,0; 0.5,1],[1,2,3])

A =

1.0000e+000

I think the area of that triangle should clearly be 0.5.

Comment only
09 May 2012 tinterp - an alternative to griddata Linear and quadratic interpolation for scattered data Author: Darren Engwirda

Darren Engwirda (view profile)

Jo Williams

Three years later and I'm still using it, but this code falls over in Matlab 2012a because TSEARCH has been removed. The following substitution fixes it:

%i = tsearch(p(:,1),p(:,2),t,pi(:,1),pi(:,2));

becomes
i = tsearchn(p,t,pi);

DelaunayTri and pointLocation are suggested by the error message, and may provide a speed improvement, but since I've saved a load of triangles the old way I don't really want a major rewrite!

Jo

Comment only
09 May 2012 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

l l

l l (view profile)

GOOD

5
16 Apr 2012 MESH2D - Automatic Mesh Generation Generates unstructured triangular meshes for general 2D geometry. Author: Darren Engwirda

Darren Engwirda (view profile)

Maxim

Maxim (view profile)

Hello.
I think, there are a bug in the function "triarea".
I miss a factor 0.5 in row 14.
Thanks
Maxim

Comment only
09 Apr 2012 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Michelle Tadmor

Thanks!!

5
26 Mar 2012 Fast points-in-polygon test Fast test to determine points located inside general polygon regions. Should be significantly faster Author: Darren Engwirda

Darren Engwirda (view profile)

Woody Wong

5
19 Feb 2012 Contours for triangular grids Generate smooth contours for functions defined on unstructured triangular grids Author: Darren Engwirda

Darren Engwirda (view profile)

lekshmi

5

Contact us