Seems to render to icosahedron.
Not the only one - here (using most recent version of OS):
(Engrave)
http://kitwallace.co.uk/3d/solid-to-scad.xq?id=SmallDitrigonalDodecacronicHexecontahedron&scad=wire
Code:
// Small Ditrigonal Dodecacronic Hexecontahedron
// base coordinates
// source:
http://dmccooey.com/polyhedra/SmallDitrigonalDodecacronicHexecontahedron.txt
// generated by http://kitwallace.co.uk/3d/solid-to-scad.xq
Name = "Small Ditrigonal Dodecacronic Hexecontahedron";
// 4 sided faces = 60
C0 = 0.597024149901241076355890645470;
C1 = 0.870268092443196157063010886223;
C2 = 0.966005366644720239190197921216;
C3 = 1.40812335289762690055892379644;
C4 = 1.56302951654596131554608856669;
C5 = 2.427050983124842272306880251548;
C6 = 3.927050983124842272306880251548;
points = [
[ C5, 0.0, C6],
[ C5, 0.0, -C6],
[-C5, 0.0, C6],
[-C5, 0.0, -C6],
[ C6, C5, 0.0],
[ C6, -C5, 0.0],
[-C6, C5, 0.0],
[-C6, -C5, 0.0],
[0.0, C6, C5],
[0.0, C6, -C5],
[0.0, -C6, C5],
[0.0, -C6, -C5],
[0.0, C0, C4],
[0.0, C0, -C4],
[0.0, -C0, C4],
[0.0, -C0, -C4],
[ C4, 0.0, C0],
[ C4, 0.0, -C0],
[-C4, 0.0, C0],
[-C4, 0.0, -C0],
[ C0, C4, 0.0],
[ C0, -C4, 0.0],
[-C0, C4, 0.0],
[-C0, -C4, 0.0],
[ C1, 0.0, C3],
[ C1, 0.0, -C3],
[-C1, 0.0, C3],
[-C1, 0.0, -C3],
[ C3, C1, 0.0],
[ C3, -C1, 0.0],
[-C3, C1, 0.0],
[-C3, -C1, 0.0],
[0.0, C3, C1],
[0.0, C3, -C1],
[0.0, -C3, C1],
[0.0, -C3, -C1],
[ C2, C2, C2],
[ C2, C2, -C2],
[ C2, -C2, C2],
[ C2, -C2, -C2],
[-C2, C2, C2],
[-C2, C2, -C2],
[-C2, -C2, C2],
[-C2, -C2, -C2]];
faces = [
[ 4 , 38, 2, 24],
[ 10 , 12, 4, 24],
[ 8 , 16, 10, 24],
[ 5 , 14, 8, 24],
[ 2 , 36, 5, 24],
[ 3 , 39, 4, 25],
[ 5 , 37, 3, 25],
[ 9 , 15, 5, 25],
[ 11 , 17, 9, 25],
[ 4 , 13, 11, 25],
[ 7 , 40, 0, 26],
[ 8 , 14, 7, 26],
[ 10 , 18, 8, 26],
[ 6 , 12, 10, 26],
[ 0 , 42, 6, 26],
[ 6 , 43, 1, 27],
[ 11 , 13, 6, 27],
[ 9 , 19, 11, 27],
[ 7 , 15, 9, 27],
[ 1 , 41, 7, 27],
[ 9 , 17, 0, 28],
[ 5 , 36, 9, 28],
[ 8 , 37, 5, 28],
[ 1 , 16, 8, 28],
[ 0 , 20, 1, 28],
[ 1 , 21, 0, 29],
[ 10 , 16, 1, 29],
[ 4 , 39, 10, 29],
[ 11 , 38, 4, 29],
[ 0 , 17, 11, 29],
[ 3 , 22, 2, 30],
[ 8 , 18, 3, 30],
[ 7 , 41, 8, 30],
[ 9 , 40, 7, 30],
[ 2 , 19, 9, 30],
[ 11 , 19, 2, 31],
[ 6 , 42, 11, 31],
[ 10 , 43, 6, 31],
[ 3 , 18, 10, 31],
[ 2 , 23, 3, 31],
[ 6 , 20, 0, 32],
[ 4 , 12, 6, 32],
[ 2 , 22, 4, 32],
[ 9 , 36, 2, 32],
[ 0 , 40, 9, 32],
[ 8 , 41, 1, 33],
[ 3 , 37, 8, 33],
[ 4 , 22, 3, 33],
[ 6 , 13, 4, 33],
[ 1 , 20, 6, 33],
[ 11 , 42, 0, 34],
[ 2 , 38, 11, 34],
[ 5 , 23, 2, 34],
[ 7 , 14, 5, 34],
[ 0 , 21, 7, 34],
[ 7 , 21, 1, 35],
[ 5 , 15, 7, 35],
[ 3 , 23, 5, 35],
[ 10 , 39, 3, 35],
[ 1 , 43, 10, 35]];
edges = [
[4,38],
[2,38],
[2,24],
[4,24],
[10,12],
[4,12],
[10,24],
[8,16],
[10,16],
[8,24],
[5,14],
[8,14],
[5,24],
[2,36],
[5,36],
[3,39],
[4,39],
[4,25],
[3,25],
[5,37],
[3,37],
[5,25],
[9,15],
[5,15],
[9,25],
[11,17],
[9,17],
[11,25],
[4,13],
[11,13],
[7,40],
[0,40],
[0,26],
[7,26],
[7,14],
[8,26],
[10,18],
[8,18],
[10,26],
[6,12],
[6,26],
[0,42],
[6,42],
[6,43],
[1,43],
[1,27],
[6,27],
[6,13],
[11,27],
[9,19],
[11,19],
[9,27],
[7,15],
[7,27],
[1,41],
[7,41],
[0,17],
[0,28],
[9,28],
[9,36],
[5,28],
[8,37],
[8,28],
[1,16],
[1,28],
[0,20],
[1,20],
[1,21],
[0,21],
[0,29],
[1,29],
[10,29],
[10,39],
[4,29],
[11,38],
[11,29],
[3,22],
[2,22],
[2,30],
[3,30],
[3,18],
[8,30],
[8,41],
[7,30],
[9,40],
[9,30],
[2,19],
[2,31],
[11,31],
[11,42],
[6,31],
[10,43],
[10,31],
[3,31],
[2,23],
[3,23],
[6,20],
[0,32],
[6,32],
[4,32],
[4,22],
[2,32],
[9,32],
[1,33],
[8,33],
[3,33],
[4,33],
[6,33],
[0,34],
[11,34],
[2,34],
[5,23],
[5,34],
[7,34],
[7,21],
[1,35],
[7,35],
[5,35],
[3,35],
[10,35]];
// ---------------------------------
eps=0.01;
scale=20;
spoints = scale * points;
face_sides=[];
//insert
font="orbitron";
word="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ratio=1;
thickness=3;
sfaces = lhs_faces(faces,spoints);
cfaces = select_nsided_faces(sfaces, face_sides);
place_on_largest_face(sfaces,spoints)
difference() {
polyhedron(spoints,sfaces);
engrave_face_word(cfaces,spoints,word,font,ratio,thickness);
}
// ruler(10);
// functions for the construction of polyhedra
// chris wallace
// see http://kitwallace.tumblr.com/tagged/polyhedra for info
// functions for creating the matrices for transforming a single point
// 19-10-2016 - updated to conform with version 2015.03-1 and later
function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1 ] ];
function m_rotate(v) = [ [1, 0, 0, 0],
[0, cos(v.x), sin(v.x), 0],
[0, -sin(v.x), cos(v.x), 0],
[0, 0, 0, 1] ]
* [ [ cos(v.y), 0, -sin(v.y), 0],
[0, 1, 0, 0],
[ sin(v.y), 0, cos(v.y), 0],
[0, 0, 0, 1] ]
* [ [ cos(v.z), sin(v.z), 0, 0],
[-sin(v.z), cos(v.z), 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1] ];
function vec3(v) = [v.x, v.y, v.z];
function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m);
function matrix_to(p0, p) =
m_rotate([0, atan2(sqrt(pow(p[0], 2) + pow(p[1], 2)),
p[2]), 0])
* m_rotate([0, 0, atan2(p[1], p[0])])
* m_translate(p0);
function matrix_from(p0, p) =
m_translate(-p0)
* m_rotate([0, 0, -atan2(p[1], p[0])])
* m_rotate([0, -atan2(sqrt(pow(p[0], 2) + pow(p[1],
2)), p[2]), 0]);
function transform_points(list, matrix, i = 0) =
i < len(list)
? concat([ transform(list[i], matrix) ], transform_points(list,
matrix, i + 1))
: [];
// convert from point indexes to point coordinates
function as_points(indexes,points,i=0) =
i < len(indexes)
? concat([points[indexes[i]]], as_points(indexes,points,i+1))
: [];
// basic vector functions
function normal_r(face) =
cross(face[1]-face[0],face[2]-face[0]);
function normal(face) =
- normal_r(face) / norm(normal_r(face));
function centre(points) =
vsum(points) / len(points);
// sum a list of vectors
function vsum(points,i=0) =
i < len(points)
? (points[i] + vsum(points,i+1))
: [0,0,0];
function ssum(list,i=0) =
i < len(list)
? (list[i] + ssum(list,i+1))
: 0;
// add a vector to a list of vectors
function vadd(points,v,i=0) =
i < len(points)
? concat([points[i] + v], vadd(points,v,i+1))
: [];
function reverse_r(v,n) =
n == 0
? [v[0]]
: concat([v[n]],reverse_r(v,n-1));
function reverse(v) = reverse_r(v, len(v)-1);
function sum_norm(points,i=0) =
i < len(points)
? norm(points[i]) + sum_norm(points,i+1)
: 0 ;
function average_radius(points) =
sum_norm(points) / len(points);
// select one dimension of a list of vectors
function slice(v,k,i=0) =
i <len(v)
? concat([v[i][k]], slice(v,k,i+1))
: [];
function max(v, max=-9999999999999999,i=0) =
i < len(v)
? v[i] > max
? max(v, v[i], i+1 )
: max(v, max, i+1 )
: max;
function min(v, min=9999999999999999,i=0) =
i < len(v)
? v[i] < min
? min(v, v[i], i+1 )
: min(v, min, i+1 )
: min;
function project(pts,i=0) =
i < len(pts)
? concat([[pts[i][0],pts[i][1]]], project(pts,i+1))
: [];
function contains(n, list, i=0) =
i < len(list)
? n == list[i]
? true
: contains(n,list,i+1)
: false;
// normalize the points to have origin at 0,0,0
function centre_points(points) =
vadd(points, - centre(points));
//scale to average radius = radius
function normalize(points,radius) =
points * radius /average_radius(points);
function select_nsided_faces(faces,nsides,i=0) =
len(nsides) == 0
? faces
: i < len(faces)
? contains(len(faces[i]), nsides)
? concat([faces[i]], select_nsided_faces(faces,nsides,i+1))
: select_nsided_faces(faces,nsides,i+1)
: [];
function longest_edge(face,max=-1,i=0) =
i < len(face)
? norm(face[i] - face[(i+1)% len(face)]) > max
? longest_edge(face, norm(face[i] - face[(i+1)%
len(face)]),i+1)
: longest_edge(face, max,i+1)
: max ;
function point_edges(point,edges,i=0) =
i < len(edges)
? point == edges[i][0] || point == edges[i][1]
? concat([edges[i]], point_edges(point,edges,i+1))
: point_edges(point,edges,i+1)
: [];
function select_nedged_points(points,edges,nedges,i=0) =
i < len(points)
? len(point_edges(i,edges)) == nedges
? concat([i], select_nedged_points(points,edges,nedges,i+1))
: select_nedged_points(points,edges,nedges,i+1)
: [];
function triangle(a,b) = norm(cross(a,b))/2;
function face_area_centre(face,centre,i=0) =
i < len(face)
? triangle(
face[i] - centre,
face[(i+1) % len(face)] - centre)
+ face_area_centre(face,centre,i+1)
: 0 ;
function face_area(face) = face_area_centre(face,centre(face));
function face_areas(faces,points,i=0) =
i < len(faces)
? concat([[i, face_area(as_points(faces[i],points))]] ,
face_areas(faces,points,i+1))
: [] ;
function max_area(areas, max=[-1,-1], i=0) =
i <len(areas)
? areas[i][1] > max[1]
? max_area(areas,areas[i],i+1)
: max_area(areas,max,i+1)
: max;
function bbox(v) = [
[min(slice(spoints,0)), max(slice(spoints,0))],
[min(slice(spoints,1)), max(slice(spoints,1))],
[min(slice(spoints,2)), max(slice(spoints,2))]
];
// check that all faces have a lhs orientation
function cosine_between(u, v) =(u * v) / (norm(u) * norm(v));
function lhs_faces(faces,points,i=0) =
i < len(faces)
? cosine_between(normal(as_points(faces[i],points)),
centre(as_points(faces[i],points))) < 0
? concat([reverse(faces[i])],lhs_faces(faces,points,i+1))
: concat([faces[i]],lhs_faces(faces,points,i+1))
: [] ;
function fs(p) = f(p[0],p[1],p[2]);
function modulate_point(p) =
spherical_to_xyz(fs(xyz_to_spherical(p)));
function modulate_points(points,i=0) =
i < len(points)
? concat([modulate_point(points[i])],modulate_points(points,i+1))
: [];
function xyz_to_spherical(p) =
[ norm(p), acos(p.z/ norm(p)), atan2(p.x,p.y)] ;
function spherical_to_xyz_full(r,theta,phi) =
[ r * sin(theta) * cos(phi),
r * sin(theta) * sin(phi),
r * cos(theta)];
function spherical_to_xyz(s) =
spherical_to_xyz_full(s[0],s[1],s[2]);
function select_large_faces(faces,points, min,i=0) =
i < len(faces)
? face_area(as_points(faces[i],points)) > min
? concat([faces[i]], select_large_faces(faces,points,min,i+1))
:select_large_faces(faces,points,min,i+1)
: [];
function lower(char) =
contains(char,"abcdefghijklmnopqrstuvwxyz") ;
function char_layer(char) =
lower(char)
? str(char,"_")
: char;
module write_char(font,char) {
linear_extrude(height=1,convexity=10)
import(file=str("write/",font,".dxf"),layer=char_layer(char));
};
module write_centred_char(font,char) {
linear_extrude(height=1,convexity=10)
translate([-2.5,-4,0])
import(file=str("write/",font,".dxf"),layer=char_layer(char));
};
module engrave_face_word(faces,points,word,font,ratio,thickness) {
for (i=[0:len(faces) - 1])
if (i <len(word)) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
s = longest_edge(f) / 20* ratio;
orient_to(c,n)
translate([0,0,-thickness+eps])
scale([s,s,thickness])
write_centred_char(font,word[i]);
}
}
module orient_to(centre, normal) {
translate(centre)
rotate([0, 0, atan2(normal[1], normal[0])]) //rotation
rotate([0, atan2(sqrt(pow(normal[0], 2)+pow(normal[1], 2)),normal[2]),
0])
children();
}
module orient_from(centre, normal) {
rotate([0, -atan2(sqrt(pow(normal[0], 2)+pow(normal[1],
2)),normal[2]), 0])
rotate([0, 0, -atan2(normal[1], normal[0])]) //rotation
translate(-centre)
children();
}
module place_on_largest_face(faces,points) {
largest = max_area(face_areas(faces,points));
lpoints = as_points(faces[largest[0]],points);
n = normal(lpoints);c = centre(lpoints);
orient_from(c,-n)
children();
}
module make_edge(edge, points, r) {
p0 = points[edge[0]]; p1 = points[edge[1]];
v = p1 -p0 ;
orient_to(p0,v)
cylinder(r=r, h=norm(v));
}
module make_edges(points, edges, r) {
for (i =[0:len(edges)-1])
make_edge(edges[i],points, r);
}
module make_vertices(points,r) {
for (i = [0:len(points)-1])
translate(points[i]) sphere(r);
}
module face_prism (face,prism_base_ratio,prism_scale,prism_height_ratio) {
n = normal(face); c= centre(face);
m = matrix_from(c,n);
tpts = prism_base_ratio * transform_points(face,m);
max_length = longest_edge(face);
xy = project(tpts);
linear_extrude(height=prism_height_ratio * max_length,
scale=prism_scale)
polygon(points=xy);
}
module
face_prisms_in(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,eps])
mirror() rotate([0,180,0])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module
face_prisms_out(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,-eps])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module
face_prisms_through(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,prism_height_ratio*longest_edge(f)/2])
mirror() rotate([0,180,0])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module ruler(n) {
for (i=[0:n-1])
translate([(i-n/2 +0.5)* 10,0,0]) cube([9.8,5,2], center=true);
}
module ground(size=50) {
translate([0,0,-size]) cube(2*size,center=true);
}
module cross_section(size=50) {
translate([0,0,-size]) cube(2*size);
}
module ring(radius,thickness,height) {
difference() {
cylinder(h=height,r=radius);
translate([0,0,-eps]) cylinder(h=height+2*eps,r=radius - thickness);
}
}
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
The preview spits out messages:
WARNING: Can't open DXF file '/Users/doug/Documents/write/orbitron.dxf'.
WARNING: Can't open DXF file '/Users/doug/Documents/write/orbitron.dxf'.
WARNING: Can't open DXF file '/Users/doug/Documents/write/orbitron.dxf'.
WARNING: Can't open DXF file '/Users/doug/Documents/write/orbitron.dxf'.
WARNING: Can't open DXF file '/Users/doug/Documents/write/orbitron.dxf'.
These are actually error messages, even though they say WARNING. My
experience is that when OpenSCAD reports warnings, all bets are off, and
you need to fix the problem before you will get any sensible behaviour.
I notice that OpenSCAD only prints these error messages once, then never
again on further F5 or F6s. The only way I got the messages to be produced
a second time was by quitting OpenSCAD, restarting it, reopening the model
file and previewing. Flushing the caches does not bring the error
messages back in this particular case. Maybe there is a DXF cache that
doesn't get flushed.
This is part of a general problem with OpenSCAD, where it either refuses to
tell you that there is an error in the model, or it tells you once then
hides the message on future previews and renders. Either way, it always
tries to display something in the graphics pane, even if it doesn't make
sense. I would actually prefer to get an error message in the graphics pane
when there is an error in the model, rather than nonsense.
write/orbitron.dxf comes from here, I think, but I didn't try downloading
it:
http://www.thingiverse.com/thing:16193
On 17 March 2016 at 10:38, unkerjay unkerjay@centurylink.net wrote:
Seems to render to icosahedron.
Not the only one - here (using most recent version of OS):
(Engrave)
http://kitwallace.co.uk/3d/solid-to-scad.xq?id=SmallDitrigonalDodecacronicHexecontahedron&scad=wire
Code:
// Small Ditrigonal Dodecacronic Hexecontahedron
// base coordinates
// source:
http://dmccooey.com/polyhedra/SmallDitrigonalDodecacronicHexecontahedron.txt
// generated by http://kitwallace.co.uk/3d/solid-to-scad.xq
Name = "Small Ditrigonal Dodecacronic Hexecontahedron";
// 4 sided faces = 60
C0 = 0.597024149901241076355890645470;
C1 = 0.870268092443196157063010886223;
C2 = 0.966005366644720239190197921216;
C3 = 1.40812335289762690055892379644;
C4 = 1.56302951654596131554608856669;
C5 = 2.427050983124842272306880251548;
C6 = 3.927050983124842272306880251548;
points = [
[ C5, 0.0, C6],
[ C5, 0.0, -C6],
[-C5, 0.0, C6],
[-C5, 0.0, -C6],
[ C6, C5, 0.0],
[ C6, -C5, 0.0],
[-C6, C5, 0.0],
[-C6, -C5, 0.0],
[0.0, C6, C5],
[0.0, C6, -C5],
[0.0, -C6, C5],
[0.0, -C6, -C5],
[0.0, C0, C4],
[0.0, C0, -C4],
[0.0, -C0, C4],
[0.0, -C0, -C4],
[ C4, 0.0, C0],
[ C4, 0.0, -C0],
[-C4, 0.0, C0],
[-C4, 0.0, -C0],
[ C0, C4, 0.0],
[ C0, -C4, 0.0],
[-C0, C4, 0.0],
[-C0, -C4, 0.0],
[ C1, 0.0, C3],
[ C1, 0.0, -C3],
[-C1, 0.0, C3],
[-C1, 0.0, -C3],
[ C3, C1, 0.0],
[ C3, -C1, 0.0],
[-C3, C1, 0.0],
[-C3, -C1, 0.0],
[0.0, C3, C1],
[0.0, C3, -C1],
[0.0, -C3, C1],
[0.0, -C3, -C1],
[ C2, C2, C2],
[ C2, C2, -C2],
[ C2, -C2, C2],
[ C2, -C2, -C2],
[-C2, C2, C2],
[-C2, C2, -C2],
[-C2, -C2, C2],
[-C2, -C2, -C2]];
faces = [
[ 4 , 38, 2, 24],
[ 10 , 12, 4, 24],
[ 8 , 16, 10, 24],
[ 5 , 14, 8, 24],
[ 2 , 36, 5, 24],
[ 3 , 39, 4, 25],
[ 5 , 37, 3, 25],
[ 9 , 15, 5, 25],
[ 11 , 17, 9, 25],
[ 4 , 13, 11, 25],
[ 7 , 40, 0, 26],
[ 8 , 14, 7, 26],
[ 10 , 18, 8, 26],
[ 6 , 12, 10, 26],
[ 0 , 42, 6, 26],
[ 6 , 43, 1, 27],
[ 11 , 13, 6, 27],
[ 9 , 19, 11, 27],
[ 7 , 15, 9, 27],
[ 1 , 41, 7, 27],
[ 9 , 17, 0, 28],
[ 5 , 36, 9, 28],
[ 8 , 37, 5, 28],
[ 1 , 16, 8, 28],
[ 0 , 20, 1, 28],
[ 1 , 21, 0, 29],
[ 10 , 16, 1, 29],
[ 4 , 39, 10, 29],
[ 11 , 38, 4, 29],
[ 0 , 17, 11, 29],
[ 3 , 22, 2, 30],
[ 8 , 18, 3, 30],
[ 7 , 41, 8, 30],
[ 9 , 40, 7, 30],
[ 2 , 19, 9, 30],
[ 11 , 19, 2, 31],
[ 6 , 42, 11, 31],
[ 10 , 43, 6, 31],
[ 3 , 18, 10, 31],
[ 2 , 23, 3, 31],
[ 6 , 20, 0, 32],
[ 4 , 12, 6, 32],
[ 2 , 22, 4, 32],
[ 9 , 36, 2, 32],
[ 0 , 40, 9, 32],
[ 8 , 41, 1, 33],
[ 3 , 37, 8, 33],
[ 4 , 22, 3, 33],
[ 6 , 13, 4, 33],
[ 1 , 20, 6, 33],
[ 11 , 42, 0, 34],
[ 2 , 38, 11, 34],
[ 5 , 23, 2, 34],
[ 7 , 14, 5, 34],
[ 0 , 21, 7, 34],
[ 7 , 21, 1, 35],
[ 5 , 15, 7, 35],
[ 3 , 23, 5, 35],
[ 10 , 39, 3, 35],
[ 1 , 43, 10, 35]];
edges = [
[4,38],
[2,38],
[2,24],
[4,24],
[10,12],
[4,12],
[10,24],
[8,16],
[10,16],
[8,24],
[5,14],
[8,14],
[5,24],
[2,36],
[5,36],
[3,39],
[4,39],
[4,25],
[3,25],
[5,37],
[3,37],
[5,25],
[9,15],
[5,15],
[9,25],
[11,17],
[9,17],
[11,25],
[4,13],
[11,13],
[7,40],
[0,40],
[0,26],
[7,26],
[7,14],
[8,26],
[10,18],
[8,18],
[10,26],
[6,12],
[6,26],
[0,42],
[6,42],
[6,43],
[1,43],
[1,27],
[6,27],
[6,13],
[11,27],
[9,19],
[11,19],
[9,27],
[7,15],
[7,27],
[1,41],
[7,41],
[0,17],
[0,28],
[9,28],
[9,36],
[5,28],
[8,37],
[8,28],
[1,16],
[1,28],
[0,20],
[1,20],
[1,21],
[0,21],
[0,29],
[1,29],
[10,29],
[10,39],
[4,29],
[11,38],
[11,29],
[3,22],
[2,22],
[2,30],
[3,30],
[3,18],
[8,30],
[8,41],
[7,30],
[9,40],
[9,30],
[2,19],
[2,31],
[11,31],
[11,42],
[6,31],
[10,43],
[10,31],
[3,31],
[2,23],
[3,23],
[6,20],
[0,32],
[6,32],
[4,32],
[4,22],
[2,32],
[9,32],
[1,33],
[8,33],
[3,33],
[4,33],
[6,33],
[0,34],
[11,34],
[2,34],
[5,23],
[5,34],
[7,34],
[7,21],
[1,35],
[7,35],
[5,35],
[3,35],
[10,35]];
// ---------------------------------
eps=0.01;
scale=20;
spoints = scale * points;
face_sides=[];
//insert
font="orbitron";
word="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ratio=1;
thickness=3;
sfaces = lhs_faces(faces,spoints);
cfaces = select_nsided_faces(sfaces, face_sides);
place_on_largest_face(sfaces,spoints)
difference() {
polyhedron(spoints,sfaces);
engrave_face_word(cfaces,spoints,word,font,ratio,thickness);
}
// ruler(10);
// functions for the construction of polyhedra
// chris wallace
// see http://kitwallace.tumblr.com/tagged/polyhedra for info
// functions for creating the matrices for transforming a single point
// 19-10-2016 - updated to conform with version 2015.03-1 and later
function m_translate(v) = [ [1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[v.x, v.y, v.z, 1 ] ];
function m_rotate(v) = [ [1, 0, 0, 0],
[0, cos(v.x), sin(v.x), 0],
[0, -sin(v.x), cos(v.x), 0],
[0, 0, 0, 1] ]
* [ [ cos(v.y), 0, -sin(v.y), 0],
[0, 1, 0, 0],
[ sin(v.y), 0, cos(v.y), 0],
[0, 0, 0, 1] ]
* [ [ cos(v.z), sin(v.z), 0, 0],
[-sin(v.z), cos(v.z), 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1] ];
function vec3(v) = [v.x, v.y, v.z];
function transform(v, m) = vec3([v.x, v.y, v.z, 1] * m);
function matrix_to(p0, p) =
m_rotate([0, atan2(sqrt(pow(p[0], 2) + pow(p[1],
2)),
p[2]), 0])
* m_rotate([0, 0, atan2(p[1], p[0])])
* m_translate(p0);
function matrix_from(p0, p) =
m_translate(-p0)
* m_rotate([0, 0, -atan2(p[1], p[0])])
* m_rotate([0, -atan2(sqrt(pow(p[0], 2) + pow(p[1],
2)), p[2]), 0]);
function transform_points(list, matrix, i = 0) =
i < len(list)
? concat([ transform(list[i], matrix) ], transform_points(list,
matrix, i + 1))
: [];
// convert from point indexes to point coordinates
function as_points(indexes,points,i=0) =
i < len(indexes)
? concat([points[indexes[i]]], as_points(indexes,points,i+1))
: [];
// basic vector functions
function normal_r(face) =
cross(face[1]-face[0],face[2]-face[0]);
function normal(face) =
- normal_r(face) / norm(normal_r(face));
function centre(points) =
vsum(points) / len(points);
// sum a list of vectors
function vsum(points,i=0) =
i < len(points)
? (points[i] + vsum(points,i+1))
: [0,0,0];
function ssum(list,i=0) =
i < len(list)
? (list[i] + ssum(list,i+1))
: 0;
// add a vector to a list of vectors
function vadd(points,v,i=0) =
i < len(points)
? concat([points[i] + v], vadd(points,v,i+1))
: [];
function reverse_r(v,n) =
n == 0
? [v[0]]
: concat([v[n]],reverse_r(v,n-1));
function reverse(v) = reverse_r(v, len(v)-1);
function sum_norm(points,i=0) =
i < len(points)
? norm(points[i]) + sum_norm(points,i+1)
: 0 ;
function average_radius(points) =
sum_norm(points) / len(points);
// select one dimension of a list of vectors
function slice(v,k,i=0) =
i <len(v)
? concat([v[i][k]], slice(v,k,i+1))
: [];
function max(v, max=-9999999999999999,i=0) =
i < len(v)
? v[i] > max
? max(v, v[i], i+1 )
: max(v, max, i+1 )
: max;
function min(v, min=9999999999999999,i=0) =
i < len(v)
? v[i] < min
? min(v, v[i], i+1 )
: min(v, min, i+1 )
: min;
function project(pts,i=0) =
i < len(pts)
? concat([[pts[i][0],pts[i][1]]], project(pts,i+1))
: [];
function contains(n, list, i=0) =
i < len(list)
? n == list[i]
? true
: contains(n,list,i+1)
: false;
// normalize the points to have origin at 0,0,0
function centre_points(points) =
vadd(points, - centre(points));
//scale to average radius = radius
function normalize(points,radius) =
points * radius /average_radius(points);
function select_nsided_faces(faces,nsides,i=0) =
len(nsides) == 0
? faces
: i < len(faces)
? contains(len(faces[i]), nsides)
? concat([faces[i]], select_nsided_faces(faces,nsides,i+1))
: select_nsided_faces(faces,nsides,i+1)
: [];
function longest_edge(face,max=-1,i=0) =
i < len(face)
? norm(face[i] - face[(i+1)% len(face)]) > max
? longest_edge(face, norm(face[i] - face[(i+1)%
len(face)]),i+1)
: longest_edge(face, max,i+1)
: max ;
function point_edges(point,edges,i=0) =
i < len(edges)
? point == edges[i][0] || point == edges[i][1]
? concat([edges[i]], point_edges(point,edges,i+1))
: point_edges(point,edges,i+1)
: [];
function select_nedged_points(points,edges,nedges,i=0) =
i < len(points)
? len(point_edges(i,edges)) == nedges
? concat([i], select_nedged_points(points,edges,nedges,i+1))
: select_nedged_points(points,edges,nedges,i+1)
: [];
function triangle(a,b) = norm(cross(a,b))/2;
function face_area_centre(face,centre,i=0) =
i < len(face)
? triangle(
face[i] - centre,
face[(i+1) % len(face)] - centre)
+ face_area_centre(face,centre,i+1)
: 0 ;
function face_area(face) = face_area_centre(face,centre(face));
function face_areas(faces,points,i=0) =
i < len(faces)
? concat([[i, face_area(as_points(faces[i],points))]] ,
face_areas(faces,points,i+1))
: [] ;
function max_area(areas, max=[-1,-1], i=0) =
i <len(areas)
? areas[i][1] > max[1]
? max_area(areas,areas[i],i+1)
: max_area(areas,max,i+1)
: max;
function bbox(v) = [
[min(slice(spoints,0)), max(slice(spoints,0))],
[min(slice(spoints,1)), max(slice(spoints,1))],
[min(slice(spoints,2)), max(slice(spoints,2))]
];
// check that all faces have a lhs orientation
function cosine_between(u, v) =(u * v) / (norm(u) * norm(v));
function lhs_faces(faces,points,i=0) =
i < len(faces)
? cosine_between(normal(as_points(faces[i],points)),
centre(as_points(faces[i],points))) < 0
? concat([reverse(faces[i])],lhs_faces(faces,points,i+1))
: concat([faces[i]],lhs_faces(faces,points,i+1))
: [] ;
function fs(p) = f(p[0],p[1],p[2]);
function modulate_point(p) =
spherical_to_xyz(fs(xyz_to_spherical(p)));
function modulate_points(points,i=0) =
i < len(points)
? concat([modulate_point(points[i])],modulate_points(points,i+1))
: [];
function xyz_to_spherical(p) =
[ norm(p), acos(p.z/ norm(p)), atan2(p.x,p.y)] ;
function spherical_to_xyz_full(r,theta,phi) =
[ r * sin(theta) * cos(phi),
r * sin(theta) * sin(phi),
r * cos(theta)];
function spherical_to_xyz(s) =
spherical_to_xyz_full(s[0],s[1],s[2]);
function select_large_faces(faces,points, min,i=0) =
i < len(faces)
? face_area(as_points(faces[i],points)) > min
? concat([faces[i]], select_large_faces(faces,points,min,i+1))
:select_large_faces(faces,points,min,i+1)
: [];
function lower(char) =
contains(char,"abcdefghijklmnopqrstuvwxyz") ;
function char_layer(char) =
lower(char)
? str(char,"_")
: char;
module write_char(font,char) {
linear_extrude(height=1,convexity=10)
import(file=str("write/",font,".dxf"),layer=char_layer(char));
};
module write_centred_char(font,char) {
linear_extrude(height=1,convexity=10)
translate([-2.5,-4,0])
import(file=str("write/",font,".dxf"),layer=char_layer(char));
};
module engrave_face_word(faces,points,word,font,ratio,thickness) {
for (i=[0:len(faces) - 1])
if (i <len(word)) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
s = longest_edge(f) / 20* ratio;
orient_to(c,n)
translate([0,0,-thickness+eps])
scale([s,s,thickness])
write_centred_char(font,word[i]);
}
}
module orient_to(centre, normal) {
translate(centre)
rotate([0, 0, atan2(normal[1], normal[0])]) //rotation
rotate([0, atan2(sqrt(pow(normal[0], 2)+pow(normal[1],
2)),normal[2]),
0])
children();
}
module orient_from(centre, normal) {
rotate([0, -atan2(sqrt(pow(normal[0], 2)+pow(normal[1],
2)),normal[2]), 0])
rotate([0, 0, -atan2(normal[1], normal[0])]) //rotation
translate(-centre)
children();
}
module place_on_largest_face(faces,points) {
largest = max_area(face_areas(faces,points));
lpoints = as_points(faces[largest[0]],points);
n = normal(lpoints);c = centre(lpoints);
orient_from(c,-n)
children();
}
module make_edge(edge, points, r) {
p0 = points[edge[0]]; p1 = points[edge[1]];
v = p1 -p0 ;
orient_to(p0,v)
cylinder(r=r, h=norm(v));
}
module make_edges(points, edges, r) {
for (i =[0:len(edges)-1])
make_edge(edges[i],points, r);
}
module make_vertices(points,r) {
for (i = [0:len(points)-1])
translate(points[i]) sphere(r);
}
module face_prism (face,prism_base_ratio,prism_scale,prism_height_ratio) {
n = normal(face); c= centre(face);
m = matrix_from(c,n);
tpts = prism_base_ratio * transform_points(face,m);
max_length = longest_edge(face);
xy = project(tpts);
linear_extrude(height=prism_height_ratio * max_length,
scale=prism_scale)
polygon(points=xy);
}
module
face_prisms_in(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,eps])
mirror() rotate([0,180,0])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module
face_prisms_out(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,-eps])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module
face_prisms_through(faces,points,prism_base_ratio,prism_scale,prism_height_ratio)
{
for (i=[0:len(faces) - 1]) {
f = as_points(faces[i],points);
n = normal(f); c = centre(f);
orient_to(c,n)
translate([0,0,prism_height_ratio*longest_edge(f)/2])
mirror() rotate([0,180,0])
face_prism(f,prism_base_ratio,prism_scale,prism_height_ratio);
}
}
module ruler(n) {
for (i=[0:n-1])
translate([(i-n/2 +0.5)* 10,0,0]) cube([9.8,5,2], center=true);
}
module ground(size=50) {
translate([0,0,-size]) cube(2*size,center=true);
}
module cross_section(size=50) {
translate([0,0,-size]) cube(2*size);
}
module ring(radius,thickness,height) {
difference() {
cylinder(h=height,r=radius);
translate([0,0,-eps]) cylinder(h=height+2*eps,r=radius - thickness);
}
}
--
View this message in context:
http://forum.openscad.org/Previews-but-doesn-t-render-tp16511.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Good news.
No error message.
Bad news.
Still looks like an icosahedron.
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16517.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Correction: No "WARNING"'s.
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16518.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Preview (with the "write" folder in place:
http://forum.openscad.org/file/n16519/Mangled_Preview_PNG.png
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16519.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Render image: (Note the text)
http://forum.openscad.org/file/n16520/Icosa_render_PNG.png
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16520.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
If I comment out the bodies of write_char() and write_centered_char(),
which contain the import statements, then it works fine. Preview and render
produce the same stellated polyhedron.
So that narrows down where the bug is. The import statements are messing up
in some way which leads to all the bad behaviour.
On 17 March 2016 at 16:19, unkerjay unkerjay@centurylink.net wrote:
Good news.
No error message.
Bad news.
Still looks like an icosahedron.
--
View this message in context:
http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16517.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Two things:
Curious what led to the two functions you refer to as the problem
Trial and error? Or something more methodical?
Kit Wallace has got a LOT of stuff at his site. MOST of it renders
without
problem. It looks like (the "assign" command being just one example that
often
comes up in older code), there may be some incompatibilities (not exactly
uncommon)
between the code he's using and changes in the code of the most recent
version of
OpenSCAD.
Not exactly sure how much of the code is standardized to make making the
changes
you suggest going forward. Certainly useful to be aware of. Not just for
me but a lot
of others who make use of his site and his code.
Pretty much the main reason I bring it up.
Knowing how you arrived at those two functions may prove useful to know even
if it's
a process of elimination method.
Just tried it and, yep, that made a difference.
It could be on some of the other polyhedra where there's a rendering
problem, might be
for the same reason.
Thanks.
--
View this message in context: http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16524.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 03/18/2016 12:32 AM, unkerjay wrote:
The import() statements cause the issue because those are the
only thing that force actual mesh calculation by the difference().
Without, there is no CGAL call at all. Even just placing a cube()
into the write functions produces the same effect.
I think the reason is that the model (the polyhedron) is not
a solid object but just an illusion and so it only works in
preview mode.
ciao,
Torsten.
What lead me to those modules is the fact that they contain the "import"
statements that were causing warning messages the first time I rendered the
model. I was just looking for the smallest change that would eliminate the
import statements.
There's a weird bug in OpenSCAD that this model demonstrates. I'm not sure
we can generalize and assume that Kit's other models trigger the same bug.
Don't worry about "assign", it's just deprecated, it should still work fine.
Here's the code that generates the model. Everything else is definitions:
place_on_largest_face(sfaces,spoints)
difference() {
polyhedron(spoints,sfaces);
engrave_face_word(cfaces,spoints,word,font,ratio,thickness);
}
If you disable the call to engrave_face_word() by putting "*" in front of
it, then the bug goes away, and you get the stellated polyhedron.
If you disable everything except the call to engrave_face_word() by putting
! in front of it, then you get a cloud of letters, and the bug goes away:
you get the same results in both preview and render.
But if you take the difference between the polyhedron and the
engrave_face_word, then the bug is triggered.
On 17 March 2016 at 19:32, unkerjay unkerjay@centurylink.net wrote:
Two things:
Curious what led to the two functions you refer to as the problem
Trial and error? Or something more methodical?
Kit Wallace has got a LOT of stuff at his site. MOST of it renders
without
problem. It looks like (the "assign" command being just one example that
often
comes up in older code), there may be some incompatibilities (not exactly
uncommon)
between the code he's using and changes in the code of the most recent
version of
OpenSCAD.
Not exactly sure how much of the code is standardized to make making the
changes
you suggest going forward. Certainly useful to be aware of. Not just for
me but a lot
of others who make use of his site and his code.
Pretty much the main reason I bring it up.
Knowing how you arrived at those two functions may prove useful to know
even
if it's
a process of elimination method.
Just tried it and, yep, that made a difference.
It could be on some of the other polyhedra where there's a rendering
problem, might be
for the same reason.
Thanks.
--
View this message in context:
http://forum.openscad.org/Previews-but-doesn-t-render-tp16511p16524.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org