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!