cylinder face orientation has changed?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

cylinder face orientation has changed?

Triffid Hunter
Hi,

We of the reprap community have noticed that cylinder faces are
appearing in different places- specifically they're rotated by 90
degrees in the new version vs the previous one. This is rather vexing
as we've been using them for nut traps, some of which need to be in
particular orientations.

Can we change it back, or at least have some way to test openscad's
version so we can make our scripts compatible between versions?

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Whosawhatsis
I hadn't noticed this, but it looks like you're right. The orientation
of the facets of cylinders can be very important, especially when the
cylinder module is used with $fn = 6 to create hexagons. In addition
to using these for nut traps, I have a bunch of models that use
hexagons to make horizontal holes, and these need to have a flat at
the top (which makes a bridge that will print cleanly), not a point at
the top (which will create two unprintable 60° overhangs).

On Fri, Jun 3, 2011 at 3:16 PM, Triffid Hunter <[hidden email]> wrote:

> Hi,
>
> We of the reprap community have noticed that cylinder faces are
> appearing in different places- specifically they're rotated by 90
> degrees in the new version vs the previous one. This is rather vexing
> as we've been using them for nut traps, some of which need to be in
> particular orientations.
>
> Can we change it back, or at least have some way to test openscad's
> version so we can make our scripts compatible between versions?
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

M.Rule
I also rely on this functionality for scripts that create hexagons. This change effectively breaks 90% of my scripts. I don't plan on upgrading, but scripts released on Thingiverse will start to fail for other users with the newer version. 

I think changing it back is best for compatibility, all else being equal. 

On Fri, Jun 3, 2011 at 6:39 PM, Whosawhatsis <[hidden email]> wrote:
I hadn't noticed this, but it looks like you're right. The orientation
of the facets of cylinders can be very important, especially when the
cylinder module is used with $fn = 6 to create hexagons. In addition
to using these for nut traps, I have a bunch of models that use
hexagons to make horizontal holes, and these need to have a flat at
the top (which makes a bridge that will print cleanly), not a point at
the top (which will create two unprintable 60° overhangs).

On Fri, Jun 3, 2011 at 3:16 PM, Triffid Hunter <[hidden email]> wrote:
> Hi,
>
> We of the reprap community have noticed that cylinder faces are
> appearing in different places- specifically they're rotated by 90
> degrees in the new version vs the previous one. This is rather vexing
> as we've been using them for nut traps, some of which need to be in
> particular orientations.
>
> Can we change it back, or at least have some way to test openscad's
> version so we can make our scripts compatible between versions?
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Kliment Yanev
Yes, I am pretty certain this was not intentional. Can anyone (with a
fast-compiling machine) use git bisect to figure out what change caused it?

Kliment

On 06/04/2011 05:19 AM, M.Rule wrote:

> I also rely on this functionality for scripts that create hexagons. This
> change effectively breaks 90% of my scripts. I don't plan on upgrading,
> but scripts released on Thingiverse will start to fail for other users
> with the newer version.
>
> I think changing it back is best for compatibility, all else being equal.
>
> On Fri, Jun 3, 2011 at 6:39 PM, Whosawhatsis <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I hadn't noticed this, but it looks like you're right. The orientation
>     of the facets of cylinders can be very important, especially when the
>     cylinder module is used with $fn = 6 to create hexagons. In addition
>     to using these for nut traps, I have a bunch of models that use
>     hexagons to make horizontal holes, and these need to have a flat at
>     the top (which makes a bridge that will print cleanly), not a point at
>     the top (which will create two unprintable 60° overhangs).
>
>     On Fri, Jun 3, 2011 at 3:16 PM, Triffid Hunter
>     <[hidden email] <mailto:[hidden email]>> wrote:
>      > Hi,
>      >
>      > We of the reprap community have noticed that cylinder faces are
>      > appearing in different places- specifically they're rotated by 90
>      > degrees in the new version vs the previous one. This is rather vexing
>      > as we've been using them for nut traps, some of which need to be in
>      > particular orientations.
>      >
>      > Can we change it back, or at least have some way to test openscad's
>      > version so we can make our scripts compatible between versions?
>      > _______________________________________________
>      > OpenSCAD mailing list
>      > [hidden email] <mailto:[hidden email]>
>      > http://rocklinux.net/mailman/listinfo/openscad
>      >
>     _______________________________________________
>     OpenSCAD mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Giles Bathgate-2
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

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Olivier Iffrig
Giles Bathgate <[hidden email]> wrote (2011-06-04 11:16:58 +0100):
> 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.

Git bisect confirmed:
commit 8c95ac44629e699c842a883c79d0833c5b83475c
Author: Marius Kintel <[hidden email]>
Date:   Wed Apr 13 14:30:55 2011 +0200

    Changed circle calculation to match sphere tessellation; makes
    example022 look better

Line 229 of src/primitives.cc (as it is currently in origin/master) has:
        double phi = (M_PI*2* (i + 0.5)) / fragments;
The + 0.5 is responsible for this change (it was not there before).

Regards,

--
Olivier Iffrig


Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Giles Bathgate-2
In reply to this post by Giles Bathgate-2
On 4 June 2011 11:16, Giles Bathgate <[hidden email]> 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;

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Giles Bathgate-2
On 4 June 2011 11:33, Giles Bathgate <[hidden email]> wrote:
> and the following diff fixes the problem:

Pushed

https://github.com/openscad/openscad/commit/82b1216ad2dba7be4d1fe8521c78af3e15994720

Triffid, you can you try compiling with the above commit included (I
know you are used to doing this as you use gentoo)

Once Triffid has confirmed the fix is anyone desperate for a new
release or can you wait till the next one?

Regards

Giles

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Kliment Yanev
I'd say definitely new release. This breaks a lot of existing code.

On 06/04/2011 12:51 PM, Giles Bathgate wrote:

> On 4 June 2011 11:33, Giles Bathgate<[hidden email]>  wrote:
>> and the following diff fixes the problem:
>
> Pushed
>
> https://github.com/openscad/openscad/commit/82b1216ad2dba7be4d1fe8521c78af3e15994720
>
> Triffid, you can you try compiling with the above commit included (I
> know you are used to doing this as you use gentoo)
>
> Once Triffid has confirmed the fix is anyone desperate for a new
> release or can you wait till the next one?
>
> Regards
>
> Giles
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Giles Bathgate-2
On 4 June 2011 15:47, Kliment Yanev <[hidden email]> wrote:
> I'd say definitely new release. This breaks a lot of existing code.

Okay, I am not really sure how openscads Test Framework works, but I
would say we need to at least build a regression test for this issue
before building a release. Obviously the test could just be as simple
as:

cylinder(h=5,r=10,$fn=6);

as the input, and a known correct stl as the expected output. I think
this is really Marius department as he has some test framework stuff
in his visitor branch.

Regards

Giles

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

clothbot
On 2011-06-04, at 12:15 PM, Giles Bathgate wrote:
On 4 June 2011 15:47, Kliment Yanev <[hidden email]> wrote:
I'd say definitely new release. This breaks a lot of existing code.

Okay, I am not really sure how openscads Test Framework works, but I
would say we need to at least build a regression test for this issue
before building a release. Obviously the test could just be as simple
as:

cylinder(h=5,r=10,$fn=6);

as the input, and a known correct stl as the expected output. I think
this is really Marius department as he has some test framework stuff
in his visitor branch.

I've always defined & used my hexagons in terms of the measured "flat diameter" which I implement using a 3-rotation intersection_for() operation on rectangles.

I created the following chunk of code to compare & contrast a more generic outer_circle() implementation of my approach with the cylinder($fn=6) result.  See https://github.com/clothbot/makerbot/blob/master/tests/test_cylinder_fn/test_cylinder_fn.scad

Rendering it with OpenSCAD 2011/04/12 produces matched hexagonal orientation.  Rendering with latest 2011/04/26 visibly highlights the different orientation.

Andrew.

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/


Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Triffid Hunter
In reply to this post by Giles Bathgate-2
On Sat, Jun 4, 2011 at 8:51 PM, Giles Bathgate <[hidden email]> wrote:
> On 4 June 2011 11:33, Giles Bathgate <[hidden email]> wrote:
>> and the following diff fixes the problem:
>
> Pushed
>
> https://github.com/openscad/openscad/commit/82b1216ad2dba7be4d1fe8521c78af3e15994720
>
> Triffid, you can you try compiling with the above commit included (I
> know you are used to doing this as you use gentoo)

yep that flips it back, works for me

> Once Triffid has confirmed the fix is anyone desperate for a new
> release or can you wait till the next one?

How many openscad scripts do you want written in the current version
that'll break when you switch it back? I'd go for another release.

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

kintel
Administrator
In reply to this post by Giles Bathgate-2
On Jun 4, 2011, at 12:51 PM, Giles Bathgate wrote:
> Pushed
>
> https://github.com/openscad/openscad/commit/82b1216ad2dba7be4d1fe8521c78af3e15994720
>
Thanks Giles.
I've done some testing and changed all the offsets to 0, and then removed the offset code.

I agree that this warrants a new release. It will happen momentarily.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

kintel
Administrator
In reply to this post by Triffid Hunter
Hi,

Latest binaries for Mac has fixed this. If nobody complain I'll try releasing tomorrow:
http://www.kintel.net/public/openscad-latest.dmg

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

Kliment Yanev
Should I rebuild the Windows one?

On Mon, Jun 6, 2011 at 1:42 AM, Marius Kintel <[hidden email]> wrote:

> Hi,
>
> Latest binaries for Mac has fixed this. If nobody complain I'll try releasing tomorrow:
> http://www.kintel.net/public/openscad-latest.dmg
>
>  -Marius
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>

Reply | Threaded
Open this post in threaded view
|

Re: cylinder face orientation has changed?

kintel
Administrator
On Jun 6, 2011, at 13:43 PM, kliment yanev wrote:

> Should I rebuild the Windows one?
>
It's always nice for testing, but if it's an effort I'd wait until I've tagged the new release, hopefully later today.

 -Marius