Mesh module

This module contains the mesh class. This class is the triangular surface where the fractal tree is grown.

class Mesh.Mesh(filename)[source]

Class that contains the mesh where fractal tree is grown. It must be Wavefront .obj file. Be careful on how the normals are defined. It can change where an specified angle will go.

Parameters:filename (str) – the path and filename of the .obj file with the mesh.
verts

array – a numpy array that contains all the nodes of the mesh. verts[i,j], where i is the node index and j=[0,1,2] is the coordinate (x,y,z).

connectivity

array – a numpy array that contains all the connectivity of the triangles of the mesh. connectivity[i,j], where i is the triangle index and j=[0,1,2] is node index.

normals

array – a numpy array that contains all the normals of the triangles of the mesh. normals[i,j], where i is the triangle index and j=[0,1,2] is normal coordinate (x,y,z).

node_to_tri

dict – a dictionary that relates a node to the triangles that it is connected. It is the inverse relation of connectivity. The triangles are stored as a list for each node.

tree

scipy.spatial.cKDTree – a k-d tree to compute the distance from any point to the closest node in the mesh.

loadOBJ(filename)[source]

This function reads a .obj mesh file

Parameters:filename (str) – the path and filename of the .obj file.
Returns:a numpy array that contains all the nodes of the mesh. verts[i,j], where i is the node index and j=[0,1,2] is the coordinate (x,y,z). connectivity (array): a numpy array that contains all the connectivity of the triangles of the mesh. connectivity[i,j], where i is the triangle index and j=[0,1,2] is node index.
Return type:verts (array)
project_new_point(point)[source]

This function projects any point to the surface defined by the mesh.

Parameters:point (array) – coordinates of the point to project.
Returns:the coordinates of the projected point that lies in the surface. intriangle (int): the index of the triangle where the projected point lies. If the point is outside surface, intriangle=-1.
Return type:projected_point (array)