Triangulation for Cloth Simulation

Hi all, I’m working on porting over my implementation of the seminal cloth simulator designed by Baraff and Witkin.

As first steps, I’m trying to generate a flat plane, triangulated with approximately evenly spaced nodes, that has the capability of deforming in 3 dimensions.

I’ve been unsuccessful in using Triangulate.jl, as its pointslist requires 2D and I haven’t located a 3D implementation in the package.

I have also looked into using MAT.jl to import a ‘mesh.mat’ file, however I have no idea how the arrays for the pointslist and triangelist are stored in this format, and have been unable to access them.

I have tried (rather unsuccessfully and frustratingly) to use Tetgen.jl to create a 3D mesh, and would like to steer clear of that (missed many edges, hard to find good documentation).

I think importing the .mat file and directly accessing the pointslist, etc. would be most ideal, but I’m unsure of how to extract that data using MAT.jl.

Any advice would be greatly appreciated, thanks!

1 Like

MAT.jl reads Matlab cell arrays as Array{Any} and structs as dictionaries. You might encounter issues if the .mat file contains custom objects. Do you have a Matlab license available to inspect the contents of the file?

What is the input? List of points, list of boundary segments?

Ok, thanks for the reply.

When I go to inspect my mesh.mat file (by loading it into a variable), it says it’s a 1x1 struct with 1 field “mesh”, which itself has two properties “Points” and “ConnectivityList”.

So, when MAT.jl reads this file, it will produce a dictionary containing the struct as key, and field as value, or will the field of the struct the key, and the properties the values?

The input to the mesh contained within the mesh.mat file is the triangulation generated from a connectivity list (generated by MATLAB’s delaunayTriangulation() function) and a pointlist of the mesh.

Couple of comments:

  1. If the .mat file is from a newer Matlab, it probably is just an HDF5 file, and you can read it from Julia with HDF5.jl.
  2. Julia has libraries for generating Delaunay triangulations. I think you mentioned Triangle above. Any reason this will not work?
  1. Ok, thanks I’ll look into that!
  2. 2D only for Triangle.jl (as far as I can tell). Tetgen might work, but I’ve tried it in the past and it was unreliable and generally a big hassle.