[OpenSCAD] cylinder face orientation has changed?

Giles Bathgate giles.bathgate at gmail.com
Sat Jun 4 12:33:23 CEST 2011


On 4 June 2011 11:16, Giles Bathgate <giles.bathgate at gmail.com> wrote:
> My hunch is that it was commit 8c95ac44629e699c842a883c79d0833c5b83475c
>
> https://github.com/openscad/openscad/commit/8c95ac44629e699c842a883c79d0833c5b83475c
>
> In which a little bit of re-factoring was done to make cylinder use
> generate_circle
> which is shared by sphere.
>
> There was also a change that I did in commit
> 5eed043d5330b4283a27b438f0c6f95a9e08504a
> But I don't think this change could affect the fragment rotation.
>
> Regards
>
> Giles Bathgate


Well I have at least confirmed this on my machine

and the following diff fixes the problem:

diff --git a/src/primitives.cc b/src/primitives.cc
index 0f82c1b..0b021ce 100644
--- a/src/primitives.cc
+++ b/src/primitives.cc
@@ -223,10 +223,10 @@ struct point2d {
        double x, y;
 };

-static void generate_circle(point2d *circle, double r, int fragments)
+static void generate_circle(point2d *circle, double r, int fragments,
double offset)
 {
        for (int i=0; i<fragments; i++) {
-               double phi = (M_PI*2* (i + 0.5)) / fragments;
+               double phi = (M_PI*2* (i + offset)) / fragments;
                circle[i].x = r*cos(phi);
                circle[i].y = r*sin(phi);
        }
@@ -311,7 +311,7 @@ PolySet *PrimitiveNode::render_polyset(render_mode_e) const
                        double r = r1 * sin(phi);
                        ring[i].z = r1 * cos(phi);
                        ring[i].points = new point2d[fragments];
-                       generate_circle(ring[i].points, r, fragments);
+                       generate_circle(ring[i].points, r, fragments,0.5);
                }

                p->append_poly();
@@ -373,8 +373,8 @@ sphere_next_r2:
                point2d *circle1 = new point2d[fragments];
                point2d *circle2 = new point2d[fragments];

-               generate_circle(circle1, r1, fragments);
-               generate_circle(circle2, r2, fragments);
+               generate_circle(circle1, r1, fragments,0.0);
+               generate_circle(circle2, r2, fragments,0.0);

                for (int i=0; i<fragments; i++) {
                        int j = (i+1) % fragments;


More information about the OpenSCAD mailing list