0

I'm working with MATLAB and I have a finite element mesh, of which I am interested in analysing specific nodes. I have information about the position of each point, how the points are connected to each other, and I know what points belong to which elements.

I need to calculate the approximate distance between a given point and the edge of the mesh in a specific direction (assume I shoot an arrow from a point in a direction, I want to know how much it travels before it exits the whole mesh). It does not need to be exact: for instance, it would be enough to know the distance between the point and the closest node to where the edge is crossed.

I do not have information about which nodes/edges/elements are at the boundary or inside the mesh.

I was thinking of this strategy:

  • a) incrementing the components of the vector of the direction by ∂x ∂y ∂z, , starting from the node of interest.
  • b) at every step check whether there is a node in a given radius (the density of the nodes is relatively high).
  • c) if there isn't, then the edge of the mesh is probably somewhere between this step and the one before. If there is, keep going.

This should work, however I have ~1000 nodes to take into consideration with ~50+ directions, and it seems it would be very time consuming.

As I mentioned, it does NOT need to be an exact value. I want to know how much "mass" there is between a node and the end of the mesh in a direction, but for what I'm analysing small differences do not matter.

Thanks!

agentp
  • 6,849
  • 2
  • 19
  • 37
Michele Tonutti
  • 4,298
  • 1
  • 21
  • 22
  • 1
    One possible approach could be to move to neighboring nodes one after other while keeping the direction vector from the given point to the current node as close to the required direction as possible. This is like a greedy search approach and might not result in accurate distance though. – Prakhar Aug 02 '16 at 12:40
  • I would also be fine with the number of nodes between the node of interest and the edge. Your approach could work, any suggestion/pointers as to how to implement it? Thanks! – Michele Tonutti Aug 02 '16 at 14:32
  • 1
    is this a 3d mesh? When you say "edge" you mean surface I guess? – agentp Aug 02 '16 at 15:31
  • @agentp Yes! I'm mainly working with nodes though, so if there was a way to do this without considering elements, edges and surfaces it would be best. Basically, the mesh has been transformed into a simple collection of 3D points. – Michele Tonutti Aug 02 '16 at 15:39
  • 1
    I don't suppose its convex? That would help. In any case it would be far better to use the mesh info, especially if its not convex you have no way to know if a given node is on the surface. – agentp Aug 02 '16 at 15:51
  • @agentp It is convex! It's actually a simplified brain, some sort of ellipsoid. – Michele Tonutti Aug 02 '16 at 16:55
  • Can you add a visualization to your question? that would help to understand it... – epsi1on Aug 03 '16 at 10:17
  • To implement the approach I suggested: Start at the given point `p`, find all it's neighboring points (other ends of the edges connected to `p`), keep the neighbor `p_1` that makes smallest angle with the required direction `d` (angle between `(p_1-p)` and `d`), now start at `p_1`, find all its neighbors and repeat the same process, this time comparing the angle between `(p_2-p)` and `d`, continue the process until you reach a boundary node or you could also define some threshold to terminate. Threshold like the angle kept increasing in past three iterations. – Prakhar Aug 03 '16 at 12:28
  • how about compute the convex hull and find the point with the smallest angle to the desired direction. You will have a problem with points close to the surface since there likely wont be any point near the correct direction, but you will have that issue no matter what if you don't want to work with surface facets. – agentp Aug 03 '16 at 14:36
  • Thanks all! I came up with a relatively easy method without having to deal with the mesh's geometry. I computed a cylinder that has as centreline a line starting from the desired point and going in the desired direction, with custom radius. I then looped over all the nodes of the mesh to check which ones belonged inside this cylinder (higher radius of the cylinder => more points), and only selected those 'in front' of the node (by using simple trig), as the cylinder is actually infinite. – Michele Tonutti Aug 03 '16 at 14:47
  • [continued] I then calculate the distance between each of those nodes and the desired node, and select the maximum distance. This works pretty well as an approximate value for the position of the surface! By selecting a radius large enough, I seem to be able to always capture one of the points on the edge in that approximate direction. – Michele Tonutti Aug 03 '16 at 14:47

0 Answers0