Editor, Editors, USER, admin, Bureaucrats, Check users, dev, editor, founder, Interface administrators, member, oversight, Suppressors, Administrators, translator
11,142
edits
Line 213: | Line 213: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
# | # Original data provided | ||
original_center = np.array([11.56, 61.21]) | original_center = np.array([11.56, 61.21]) | ||
radius = 26.38 | radius = 26.38 | ||
Line 222: | Line 222: | ||
]) | ]) | ||
# | # Function to add noise to the points | ||
def add_noise_to_points(points, noise_level): | def add_noise_to_points(points, noise_level): | ||
noisy_points = points + np.random.normal(0, noise_level, points.shape) | noisy_points = points + np.random.normal(0, noise_level, points.shape) | ||
return noisy_points | return noisy_points | ||
# | # Add noise to the points | ||
noise_level = 0.1 # | noise_level = 0.1 # Reduced noise level | ||
noisy_points = add_noise_to_points(points, noise_level) | noisy_points = add_noise_to_points(points, noise_level) | ||
# | # Residual function for non-linear fitting | ||
def residuals(c, points): | def residuals(c, points): | ||
xc, yc, r = c | xc, yc, r = c | ||
Line 237: | Line 237: | ||
return Ri - r | return Ri - r | ||
# | # Calculate the center and radius using noisy points | ||
x_m = np.mean(noisy_points[:, 0]) | x_m = np.mean(noisy_points[:, 0]) | ||
y_m = np.mean(noisy_points[:, 1]) | y_m = np.mean(noisy_points[:, 1]) | ||
Line 243: | Line 243: | ||
initial_guess = [x_m, y_m, r_m] | initial_guess = [x_m, y_m, r_m] | ||
# Fitting | # Fitting the circle using the Levenberg-Marquardt method | ||
result = least_squares(residuals, initial_guess, args=(noisy_points,)) | result = least_squares(residuals, initial_guess, args=(noisy_points,)) | ||
xc, yc, r = result.x | xc, yc, r = result.x | ||
Line 249: | Line 249: | ||
calculated_center = np.array([xc, yc]) | calculated_center = np.array([xc, yc]) | ||
# | # Calculate the error between the centers | ||
error = np.linalg.norm(calculated_center - original_center) | error = np.linalg.norm(calculated_center - original_center) | ||
error_mm = error * 10 # | error_mm = error * 10 # Convert to millimeters (assuming the points might be in centimeters) | ||
# | # Verify the calculated center | ||
print(f'Calculated Center: {calculated_center}') | print(f'Calculated Center: {calculated_center}') | ||
print(f'Radius: {r:.4f}') | print(f'Radius: {r:.4f}') | ||
print(f'Error: {error_mm:.4f} mm') | print(f'Error: {error_mm:.4f} mm') | ||
# | # Visualization of the fitted circle | ||
theta = np.linspace(0, 2 * np.pi, 100) | theta = np.linspace(0, 2 * np.pi, 100) | ||
x_fit = calculated_center[0] + r * np.cos(theta) | x_fit = calculated_center[0] + r * np.cos(theta) | ||
Line 272: | Line 272: | ||
plt.ylabel('Y') | plt.ylabel('Y') | ||
plt.legend() | plt.legend() | ||
plt.title('Fitting | plt.title('Circle Fitting with Noisy Points') | ||
plt.grid(True) | plt.grid(True) | ||
plt.show() | plt.show() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Occlusal Distortions== | ==Occlusal Distortions== | ||
Line 297: | Line 298: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
# | # Definition of the original data | ||
original_center = np.array([11.56, 61.21]) # | original_center = np.array([11.56, 61.21]) # Original center of the circle | ||
r = 26.38 # | r = 26.38 # Radius of the original circle | ||
theta = np.linspace(0, 2 * np.pi, 10) # 10 | theta = np.linspace(0, 2 * np.pi, 10) # 10 points along the circumference | ||
# | # Generation of original points on the circumference | ||
points = np.array([ | points = np.array([ | ||
original_center + r * np.array([np.cos(angle), np.sin(angle)]) | original_center + r * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 308: | Line 309: | ||
]) | ]) | ||
# | # Definition of the radius for the position of dental cusps | ||
cusp_radius = 75.0 # | cusp_radius = 75.0 # Distance of the cusp from the center of rotation | ||
# | # Generation of the positions of the original dental cusps | ||
cusp_positions = np.array([ | cusp_positions = np.array([ | ||
original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 317: | Line 318: | ||
]) | ]) | ||
# | # Simulation of the errors Δ | ||
errors = np.linspace(0, 10, 10) # | errors = np.linspace(0, 10, 10) # Errors Δ from 0 to 10 mm, 10 steps | ||
max_differences_zero_apertura = [] | max_differences_zero_apertura = [] | ||
# | # Cusp error for mandibular opening at 0 mm is zero | ||
for delta in errors: | for delta in errors: | ||
max_differences_zero_apertura.append(0) # | max_differences_zero_apertura.append(0) # Cusp error is zero | ||
plt.plot(errors, max_differences_zero_apertura, 'ro-', label=' | plt.plot(errors, max_differences_zero_apertura, 'ro-', label='Opening 0 mm (Mouth closed)') | ||
plt.xlabel(' | plt.xlabel('Error Δ (mm) in HA localization') | ||
plt.ylabel('Max Difference in Cusp Positions (mm)') | plt.ylabel('Max Difference in Cusp Positions (mm)') | ||
plt.title(' | plt.title('Cusp Error with 0 mm Opening and Flat Cusps') | ||
plt.grid(True) | plt.grid(True) | ||
plt.legend() | plt.legend() | ||
plt.show() | plt.show() | ||
</syntaxhighlight><blockquote> | </syntaxhighlight><blockquote> | ||
===='''Script Pyhton: Errore Cuspidale con Apertura a 3 mm e Cuspidi Piatte'''==== | ===='''Script Pyhton: Errore Cuspidale con Apertura a 3 mm e Cuspidi Piatte'''==== | ||
Line 340: | Line 342: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
# | # Definition of the original data | ||
original_center = np.array([11.56, 61.21]) # | original_center = np.array([11.56, 61.21]) # Original center of the circle | ||
r = 26.38 # | r = 26.38 # Radius of the original circle | ||
theta = np.linspace(0, 2 * np.pi, 10) # 10 | theta = np.linspace(0, 2 * np.pi, 10) # 10 points along the circumference | ||
# | # Generation of original points on the circumference | ||
points = np.array([ | points = np.array([ | ||
original_center + r * np.array([np.cos(angle), np.sin(angle)]) | original_center + r * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 351: | Line 353: | ||
]) | ]) | ||
# | # Definition of the radius for the position of dental cusps | ||
cusp_radius = 75.0 # | cusp_radius = 75.0 # Distance of the cusp from the center of rotation | ||
# | # Generation of the positions of the original dental cusps | ||
cusp_positions = np.array([ | cusp_positions = np.array([ | ||
original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 360: | Line 362: | ||
]) | ]) | ||
# | # Simulation of the errors Δ | ||
errors = np.linspace(0, 10, 10) # | errors = np.linspace(0, 10, 10) # Errors Δ from 0 to 10 mm, 10 steps | ||
max_differences_apertura_3mm = [] | max_differences_apertura_3mm = [] | ||
# | # Calculation of the cusp error for a mandibular opening of 3 mm | ||
for delta in errors: | for delta in errors: | ||
new_center = original_center + np.array([delta, 0]) # | new_center = original_center + np.array([delta, 0]) # Shift along the x-axis | ||
# | # Calculate the new positions of the dental cusps with error Δ | ||
new_cusp_positions = np.array([ | new_cusp_positions = np.array([ | ||
new_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | new_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 374: | Line 376: | ||
]) | ]) | ||
# | # Calculate the spatial differences between the original and calculated positions | ||
differences = np.linalg.norm(cusp_positions - new_cusp_positions, axis=1) | differences = np.linalg.norm(cusp_positions - new_cusp_positions, axis=1) | ||
max_difference = np.max(differences) * (3 / 30) # | max_difference = np.max(differences) * (3 / 30) # Scaling the error for a 3 mm opening out of 18 mm maximum | ||
max_differences_apertura_3mm.append(max_difference) | max_differences_apertura_3mm.append(max_difference) | ||
print(f" | print(f"Error Δ = {delta:.1f} mm: Max Difference in Cusp Positions (3 mm opening) = {max_difference:.2f} mm") | ||
plt.plot(errors, max_differences_apertura_3mm, 'bo-', label=' | plt.plot(errors, max_differences_apertura_3mm, 'bo-', label='Opening 3 mm') | ||
plt.xlabel(' | plt.xlabel('Error Δ (mm) in HA localization') | ||
plt.ylabel('Max Difference in Cusp Positions (mm)') | plt.ylabel('Max Difference in Cusp Positions (mm)') | ||
plt.title(' | plt.title('Cusp Error with 3 mm Opening and Flat Cusps') | ||
plt.grid(True) | plt.grid(True) | ||
plt.legend() | plt.legend() | ||
plt.show() | plt.show() | ||
</syntaxhighlight><blockquote> | </syntaxhighlight><blockquote> | ||
===='''Script Python: Effetto degli Errori di Localizzazione del Centro di Rotazione con on Apertura a 0 mm e Cuspidi Inclinate ''<math>5^\circ</math>'''''==== | ===='''Script Python: Effetto degli Errori di Localizzazione del Centro di Rotazione con on Apertura a 0 mm e Cuspidi Inclinate ''<math>5^\circ</math>'''''==== | ||
Line 394: | Line 397: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
# | # Definition of the original data | ||
original_center = np.array([11.56, 61.21]) # | original_center = np.array([11.56, 61.21]) # Original center of the circle | ||
r = 26.38 # | r = 26.38 # Radius of the original circle | ||
theta = np.linspace(0, 2 * np.pi, 10) # 10 | theta = np.linspace(0, 2 * np.pi, 10) # 10 points along the circumference | ||
# | # Generation of original points on the circumference | ||
points = np.array([ | points = np.array([ | ||
original_center + r * np.array([np.cos(angle), np.sin(angle)]) | original_center + r * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 405: | Line 408: | ||
]) | ]) | ||
# | # Definition of the radius for the position of dental cusps | ||
cusp_radius = 75.0 # | cusp_radius = 75.0 # Distance of the cusp from the center of rotation | ||
# | # Generation of the positions of the original dental cusps | ||
cusp_positions = np.array([ | cusp_positions = np.array([ | ||
original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | original_center + cusp_radius * np.array([np.cos(angle), np.sin(angle)]) | ||
Line 414: | Line 417: | ||
]) | ]) | ||
# | # Simulation of the errors Δ | ||
errors = np.linspace(0, 10, 10) # | errors = np.linspace(0, 10, 10) # Errors Δ from 0 to 10 mm, 10 steps | ||
max_differences_inclined_cusp = [] | max_differences_inclined_cusp = [] | ||
# | # Definition of the angle of the dental cusps (in degrees) | ||
cusp_angle_deg = 5 | cusp_angle_deg = 5 | ||
cusp_angle_rad = np.deg2rad(cusp_angle_deg) # | cusp_angle_rad = np.deg2rad(cusp_angle_deg) # Conversion to radians | ||
# | # Calculation of cusp error for mandibular opening at 0 mm with inclined cusps | ||
for delta in errors: | for delta in errors: | ||
# | # Calculation of vertical error due to cusp inclination | ||
vertical_error_due_to_inclination = delta * np.tan(cusp_angle_rad) | vertical_error_due_to_inclination = delta * np.tan(cusp_angle_rad) | ||
# | # Save the maximum error in this specific case | ||
max_differences_inclined_cusp.append(vertical_error_due_to_inclination) | max_differences_inclined_cusp.append(vertical_error_due_to_inclination) | ||
print(f" | print(f"Error Δ = {delta:.1f} mm: Max Difference in Cusp Positions with inclined cusps = {vertical_error_due_to_inclination:.2f} mm") | ||
plt.plot(errors, max_differences_inclined_cusp, 'ro-', label=f' | plt.plot(errors, max_differences_inclined_cusp, 'ro-', label=f'Inclined Cusps ({cusp_angle_deg}°)') | ||
plt.xlabel(' | plt.xlabel('Error Δ (mm) in HA localization') | ||
plt.ylabel('Max Difference in Cusp Positions (mm)') | plt.ylabel('Max Difference in Cusp Positions (mm)') | ||
plt.title(f' | plt.title(f'Effect of Rotation Center Localization Errors with Inclined Cusps ({cusp_angle_deg}°)') | ||
plt.grid(True) | plt.grid(True) | ||
plt.legend() | plt.legend() | ||
plt.show() | plt.show() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
edits