Skip to content
Snippets Groups Projects
Commit 7a61f23d authored by Djalim Simaila's avatar Djalim Simaila
Browse files

Docstrings, translations and other metadata fixes

parent fb884b82
No related branches found
No related tags found
1 merge request!8General improvement
......@@ -20,10 +20,10 @@ def get_raw_data(obj:ScannedObject, ndigits:int, delta_z:int = 1)->dict:
- Xi-Xmoy : list of Xi-Xmoy values
- Yi-Ymoy : list of Yi-Ymoy values
"""
colones = ["X (en mm)", "Y (en mm)", "Z (en mm)", "teta (en rad)", "rayon (en mm)","Xi-Xmoy","Yi-Ymoy"]
columns = ["X (en mm)", "Y (en mm)", "Z (en mm)", "teta (en rad)", "rayon (en mm)","Xi-Xmoy","Yi-Ymoy"]
data = {}
for colone in colones:
data[colone] = []
for column in columns:
data[column] = []
for discrete_values in obj.get_discrete_vertices(delta_z):
mean_x ,mean_y, mean_z = data_extraction.get_x_y_z_mean(discrete_values)
for x,y,z in discrete_values:
......@@ -49,10 +49,10 @@ def get_discrete_data(obj:ScannedObject, ndigits:int,delta_z:int= 1)->dict:
- Rayon moyen (en mm) : list of mean radius values
- Rayon ecart type (en mm) : list of radius standard deviation values
"""
colones = ["X moy (en mm)", "Y moy (en mm)", "Z moy (en mm)","Delta z(en mm)","Rayon moyen (en mm)","Rayon ecart type (en mm)"]
columns = ["X moy (en mm)", "Y moy (en mm)", "Z moy (en mm)","Delta z(en mm)","Rayon moyen (en mm)","Rayon ecart type (en mm)"]
data = {}
for colone in colones:
data[colone] = []
for column in columns:
data[column] = []
for discrete_values in obj.get_discrete_vertices(delta_z):
x,y,z = data_extraction.get_x_y_z_mean(discrete_values)
data["X moy (en mm)"].append(round(x, ndigits))
......
......@@ -19,9 +19,16 @@ class ScannedObject:
"""
This class is used to manage the data of the 3D object.
:param vertices: List of vertices
:param faces: List of faces
:param vertices: List of verticesm Ndarray of shape (n,2)
:param faces: List of faces, Ndarray of shape (n,2)
:param result_file_path: Path to the result file (deprecated, used for the bruteforce discretization)
:ivar vertices: List of vertices, Ndarray of shape (n,2)
:ivar faces: List of faces, Ndarray of shape (n,2)
:ivar result_file_path: Path to the result file (deprecated, used for the bruteforce discretization)
:ivar x: List of x values of the vertices
:ivar y: List of y values of the vertices
:ivar z: List of z values of the vertices
:static method from_xyz_file(): Creates a ScannedObject from a .xyz file
:static method from_obj_file(): Creates a ScannedObject from a .obj file
......
......@@ -10,12 +10,13 @@ def render2D(values:list):
ax.plot(values)
plt.show()
def cross_section(x:list,y:list):
def cross_section(x_values:list, y_values:list):
"""
Render a 2D model using matplotlib
:param values: A list with the values
Render a 2D cross section using matplotlib
:param x: A list with the x values
:param y: A list with the y values
"""
fig = plt.figure()
ax = fig.add_subplot()
ax.scatter(x,y)
ax.scatter(x_values,y_values)
plt.show()
\ No newline at end of file
......@@ -2,6 +2,10 @@ import vispy.plot as vp
import numpy as np
def render2D(values:list):
"""
Render a 2D plot using vispy
:param values: A list with the values
"""
fig = vp.Fig(size=(600, 500), show=False)
plotwidget = fig[0, 0]
fig.title = "bollu"
......@@ -9,10 +13,15 @@ def render2D(values:list):
plotwidget.colorbar(position="top", cmap="autumn")
fig.show(run=True)
def cross_section(x:list,y:list):
def cross_section(x_values:list, y_values:list):
"""
Render a 2D cross section using vispy
:param x: A list with the x values
:param y: A list with the y values
"""
color = (0.3, 0.5, 0.8)
fig = vp.Fig(show=False)
line = fig[0:4, 0:4].plot(np.column_stack((x,y)), symbol='o', width=0,
line = fig[0:4, 0:4].plot(np.column_stack((x_values,y_values)), symbol='o', width=0,
face_color=color + (0.02,), edge_color=None,
marker_size=8)
line.set_gl_state(depth_test=False)
......
......@@ -5,8 +5,8 @@ from utils.files.input import ScannedObject
def render3D(obj:ScannedObject):
"""
Render a 3D model using matplotlib poly3dcollection
:param data: A dict with the vertices and faces
Render a 3D model using matplotlib's Poly3dcollection
:param obj: A ScannedObject to be rendered
"""
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
......
......@@ -6,6 +6,10 @@ from utils.files.input import ScannedObject
def render3D(obj:ScannedObject):
"""
Render a 3D model using vispy
:param obj: A ScannedObject to be rendered
"""
vertices = np.asarray(obj.get_vertices())
faces = np.asarray(obj.get_faces())
canvas = scene.SceneCanvas(keys='interactive', bgcolor='white')
......
......@@ -3,15 +3,19 @@ from utils.files.input import ScannedObject
from utils.math.data_extraction import get_mean
def get_mass_properties(obj:ScannedObject):
def get_mass_properties(obj:ScannedObject)->tuple:
'''
Evaluate and return a tuple with the following elements:
- the volume
- the position of the center of gravity (COG)
- the inertia matrix expressed at the COG
:param obj: Object to analyse
:return: tuple(float, numpy.array, numpy.array)
From numpy-stl:(https://pypi.org/project/numpy-stl/)
Documentation can be found here:
http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf
Documentation can be found here:
http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf
'''
verts = np.asarray(obj.get_vertices())
......@@ -66,6 +70,10 @@ def get_mass_properties(obj:ScannedObject):
return volume, cog, inertia
def verticalise(obj:ScannedObject):
"""
Rotate the object so that the principal axis of inertia is vertical
:param obj: Object to analyse
"""
cog = get_mass_properties(obj)
cog, inertia = get_mass_properties(obj)[1:]
[val,vect] = np.linalg.eig(inertia)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment