# how does OpenSCAD represent edges and how are spheres constructed?

11 messages
Open this post in threaded view
|

## how does OpenSCAD represent edges and how are spheres constructed?

 I am fooling around with creating my own spheres from a points array, so I took a look at the performance of sphere() with "show edges" turned on. I noticed that it doesn't show edges for the top and bottom of the sphere... so then I took a look at the output of cylinder() and cube() modules. However if you create the same object with linear_extrude() using either circle() or square() as the primitive, the display in F5 shows all the triangles of the mesh. This inconsistency isn't really a big thing to me, but it doesn't give me much insight into how a sphere is formed... specifically how is the diameter for the top and bottom of the sphere determined? I had thought that a sphere might be topped and bottomed by a cone construction, but that doesn't seem to be the case. If you superimpose a cube over a sphere of the same size, you can also see that there is inaccuracy at the top and bottom of the sphere which only becomes more pronounced if you scale a sphere (i.e. construct spheres at the size you ultimately require, don't scale). So I'm thinking that the sphere generator I create should go for the cone top and bottom so that the tip of the cone lies exactly on the measurement specified, or do you folks think that's being overly picky? If I don't go for the cone, then where should the truncation of the height dimension fall? Just wanted the thoughts of the community on this. Here's some code that displays the behaviour I've been talking about (just remember to turn on "show edges") \$fn = 30; cylinder(r = 5, h = 5); translate([15,0,0])         linear_extrude(5)                 circle(5); translate([0,15,0]) {         cube([10,10,10], center = true);                 translate([15,0,0])                 linear_extrude(10)                         square([10,10], center = true); } translate([35,10,0]) {         sphere(10);         #cube([20,20,20], center = true); } -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 You can look at: https://github.com/thehans/FunctionalOpenSCAD/blob/master/functional.scadFor a sphere construction.  It matches up pretty well to the one in OpenSCAD. There are some drawbacks to that approach - the same project has some alternative sphere constructions. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 In reply to this post by boxcarmib You can look at: https://github.com/thehans/FunctionalOpenSCAD/blob/master/functional.scadFor a sphere construction.  It matches up pretty well to the one in OpenSCAD. The same project has some alternative sphere constructions. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 In reply to this post by boxcarmib Isn't it simpler to simply add more polygons to the sphere?  sphere(100,\$fn=10); //Looks like crap    translate([240,0,0])  sphere(100,\$fn=50); //Looks pretty good    translate([480,0,0])  sphere(100,\$fn=500); //Looks smooth -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 In reply to this post by boxcarmib OpenSCAD internally generates polyhedrons for those primitives and obviously uses the rule that each vertex v satisfies the respective equation. Thus all other points on the 2-manifold don't. You can see this by circle(5, \$fn=4); #square(10, center = true); From an approximation error point of view this might not be the best solution, but it is how it is. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 There's this: https://www.thingiverse.com/thing:1484333On Tue, Feb 20, 2018 at 5:43 AM, Parkinbot wrote:OpenSCAD internally generates polyhedrons for those primitives and obviously uses the rule that each vertex v satisfies the respective equation. Thus all other points on the 2-manifold don't. You can see this by circle(5, \$fn=4); #square(10, center = true); From an approximation error point of view this might not be the best solution, but it is how it is. -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- ----------------------------------------------Gary A. Crowell Sr., P.E., CID+ _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

Open this post in threaded view
|

## Re: how does OpenSCAD represent edges and how are spheres constructed?

 nophead wrote > It tends to be important that spheres have vertices spot on the six 90 > degree points so that when you hull them to make rounded cubes they have > the correct dimensions > ... Ideally they also have seams that correspond to octahedron edges.  Then you can use the octahedron/cube duality for the edges of the rounded cube as well. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org