- Este código em python gera as coordenadas dos vértices de um icosaedro truncado (não regular).
- Um icosaedro truncado regular possui 90 arestas, 60 vértices e 32 faces, sendo 12 pentágonos e 20 hexágonos.
import numpy as np
def format_coordinate(value):
rounded_value = round(value, 1)
if rounded_value.is_integer():
return str(int(rounded_value))
else:
return str(rounded_value)
# Definindo os pontos de referência para um icosaedro
phi = (1 + np.sqrt(5)) / 2
icosahedron_vertices = np.array([
[0, 1, phi],
[0, 1, -phi],
[0, -1, phi],
[0, -1, -phi],
[1, phi, 0],
[1, -phi, 0],
[-1, phi, 0],
[-1, -phi, 0],
[phi, 0, 1],
[phi, 0, -1],
[-phi, 0, 1],
[-phi, 0, -1]
])
# Definindo a matriz de truncamento
truncation_matrix = np.array([
[1, 0, 1],
[0, 1, 1],
[-1, 0, 1],
[0, -1, 1],
[1, 1, 0],
[-1, 1, 0],
[1, -1, 0],
[-1, -1, 0],
[1, 0, -1],
[0, 1, -1],
[-1, 0, -1],
[0, -1, -1]
])
# Calculando o centro do icosaedro truncado
center = np.mean(icosahedron_vertices, axis=0)
# Calculando as coordenadas dos vértices dos pentágonos
unique_vertices = []
for i in range(12):
pentagon_vertices = icosahedron_vertices + truncation_matrix[i]
pentagon_vertices_center = np.mean(pentagon_vertices, axis=0)
pentagon_vertices = [
vertex for vertex in pentagon_vertices if
np.count_nonzero(vertex == 0) != 2 and
not (np.all(vertex > 0) and np.all(vertex < 1)) and
not np.all((np.abs(vertex[0]) > 0 and np.abs(vertex[0]) < 1) or
(np.abs(vertex[1]) > 0 and np.abs(vertex[1]) < 1) or
(np.abs(vertex[2]) > 0 and np.abs(vertex[2]) < 1))
]
pentagon_vertices = np.unique(pentagon_vertices, axis=0)
unique_vertices.extend(pentagon_vertices)
# Convertendo para um array numpy para eliminar duplicatas
unique_vertices = np.array(unique_vertices)
# Calculando as distâncias entre os vértices e o centro
distances_to_center = np.linalg.norm(unique_vertices - center, axis=1)
# Encontrando a distância máxima entre os vértices dos pentágonos
max_distance_pentagon = np.max(np.linalg.norm(icosahedron_vertices, axis=1))
# Eliminando os vértices mais próximos do centro do que qualquer vértice dos pentágonos
filtered_vertices = unique_vertices[distances_to_center > max_distance_pentagon]
# Imprimindo as coordenadas dos vértices formatadas com duas vírgulas entre cada valor
for i, vertex in enumerate(filtered_vertices):
formatted_coords = [format_coordinate(coord) for coord in vertex]
formatted_coords_str = ', '.join(formatted_coords)
#print(f"Vértice {i + 1}: [{formatted_coords_str}]")
print(f"translate ([{formatted_coords_str}]) pnt(0.1);")
-Para visualizar a forma aproximada deste sólido geométrico no OpenScad use o código abaixo:
IcosaedroVertices = [
[10, -10, 26], //0
[10, 10, 26], //1
[0, 20, 26], //2
[-10, 10, 26], //3
[-10, -10, 26], //4
[0, -20, 26], //5
[26, -10, -10], //6
[26, -10, 10], //7
[26, 0, 20], //8
[26, 10, -10], //10
[26, 10, 10], //9
[26, 0, -20], //11
[10, -10, -26], //12
[10, 10, -26], //13
[0, 20, -26], //14
[-10, -10, -26], //16
[-10, 10, -26], //15
[0, -20, -26], //17
[-26, -10, -10], //18
[-26, -10, 10], //19
[-26, 0, 20], //20
[-26, 10, -10], //22
[-26, 10, 10], //21
[-26, 0, -20], //23
[-20, -26, 0], //24
[-10, -26, 10], //25
[10, -26, 10], //26
[20, -26, 0], //27
[10, -26, -10], //28
[-10, -26, -10], //29
[20, 26, 0], //30
[10, 26, 10], //31
[-10, 26, 10], //33
[-20, 26, 0], //32
[-10, 26, -10], //34
[10, 26, -10], //35
/*[-20, 16, 10], //36 triângulos internos
[-10, 20, 16], //37
[-16, 10, 20], //38
[20, -16, 10], //39
[10, -20, 16], //40
[16, -10, 20], //41
[20, 16, -10], //42
[10, 20, -16], //43
[16, 10, -20], //44
[20, 16, 10], //45
[10, 20, 16], //46
[16, 10, 20], //47
[-20, -16, 10], //48
[-10, -20, 16], //49
[-16, -10, 20], //50
[20, -16, -10], //51
[10, -20, -16], //52
[16, -10, -20], //53
[-20, -16, -10], //54
[-10, -20, -16], //55
[-16, -10, -20], //56
[-20, 16, -10], //57
[-10, 20, -16], //58
[-16, 10, -20]]; //59 */
];
IcosaedroFaces = [
[0,1,2,3,4,5], // hexágonos centrais
[6,7,8,10,9,11],
[12,13,14,16,15,17],
[18,19,20,22,21,23],
[24,25,26,27,28,29],
[31,32,33,34,35,30],
/* [36,37,38], // triângulos internos
[39,40,41],
[42,43,44],
[45,46,47],
[48,49,50],
[51,52,53],
[54,55,56],
[57,58,59],
[2,37,46],
[5,40,49],
[14,43,58],
[17,52,55],
[24,48,54],
[27,39,51],
[11,44,53],
[23,56,59],
[8,41,47],
[20,50,38],
[30,42,45],
[33,36,57]];*/
[2,31,32], // triângulos externos
[5,25,26],
[8,0,1],
[11,12,13],
[14,34,35],
[17,28,29],
[20,3,4],
[23,15,16],
[24,18,19],
[27,6,7],
[30,9,10],
[33,21,22],
[2,33,20], // hexágonos laterais abertos
[2,30,8],
[5,8,27],
[5,20,24],
[11,14,30],
[11,17,27],
[17,23,24],
[14,23,33],
//[5,26,27,7,20,4],
];
polyhedron( IcosaedroVertices, IcosaedroFaces );
color ("blue") {
translate ([10, -10, 26]) linear_extrude(8) text("0", 5); //0
translate ([10, 10, 26]) linear_extrude(8) text("1", 5); //1
translate ([0, 20, 26]) linear_extrude(8) text("2", 5); //2
translate ([-10, 10, 26]) linear_extrude(8) text("3", 5); //3
translate ([-10, -10, 26]) linear_extrude(8) text("4", 5); //4
translate ([0, -20, 26]) linear_extrude(8) text("5", 5); //5
translate ([26, -10, -10]) linear_extrude(8) text("6", 5); //6
translate ([26, -10, 10]) linear_extrude(8) text("7", 5); //7
translate ([26, 0, 20]) linear_extrude(8) text("8", 5); //8
translate ([26, 10, -10]) linear_extrude(8) text("10", 5); //10
translate ([26, 10, 10]) linear_extrude(8) text("9", 5); //9
translate ([26, 0, -20]) linear_extrude(8) text("11", 5); //11
translate ([10, -10, -26]) linear_extrude(8) text("12", 5); //12
translate ([10, 10, -26]) linear_extrude(8) text("13", 5); //13
translate ([0, 20, -26]) linear_extrude(8) text("14", 5); //14
translate ([-10, -10, -26]) linear_extrude(8) text("16", 5); //16
translate ([-10, 10, -26]) linear_extrude(8) text("15", 5); //15
translate ([0, -20, -26]) linear_extrude(12) text("17", 8); //17
translate ([-26, -10, -10]) linear_extrude(8) text("18", 5); //18
translate ([-26, -10, 10]) linear_extrude(8) text("19", 5); //19
translate ([-26, 0, 20]) linear_extrude(8) text("20", 5); //20
translate ([-26, 10, -10]) linear_extrude(8) text("22", 5); //22
translate ([-26, 10, 10]) linear_extrude(8) text("21", 5); //21
translate ([-26, 0, -20]) linear_extrude(12) text("23", 8); //23
translate ([-20, -26, 0]) linear_extrude(8) text("24", 5); //24
translate ([-10, -26, 10]) linear_extrude(8) text("25", 5); //25
translate ([10, -26, 10]) linear_extrude(8) text("26", 5); //26
translate ([20, -26, 0]) linear_extrude(8) text("27", 5); //27
translate ([10, -26, -10]) linear_extrude(8) text("28", 5); //28
translate ([-10, -26, -10]) linear_extrude(8) text("29", 5); //29
translate ([20, 26, 0]) linear_extrude(8) text("30", 5); //30
translate ([10, 26, 10]) linear_extrude(8) text("31", 5); //31
translate ([-10, 26, 10]) linear_extrude(8) text("32", 5); //32
translate ([-20, 26, 0]) linear_extrude(8) text("33", 5); //33
translate ([-10, 26, -10]) linear_extrude(8) text("34", 5); //34
translate ([10, 26, -10]) linear_extrude(8) text("35", 5); //35
}
Nenhum comentário:
Postar um comentário