discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

allowing center= parameter to be a vector of booleans

DR
Drew Rogge
Mon, May 4, 2015 12:33 AM

I often find that I want a cube to be centered about the z axis but sitting on the z = 0 xy plane. What do people think of allowing the center= parameter of 2D and 3D primitives to be a vector of booleans. That way one could center a primitive on whatever axes are desired instead of all or nothing. In my cube example I could use:

cube([10, 20, 5], center=[true, true, false]);

instead of translate([-5, -10, 0]) cube([10, 20, 5]); or translate([0, 0, 2.5]) cube([10, 20, 5]);

Although not clean it would also be handy if booleans could also be represented by zero/non-zero numeric values instead of the verbose "true" and "false".

I'm open to other ways of doing the above if anyone has any suggestions.

Drew

I often find that I want a cube to be centered about the z axis but sitting on the z = 0 xy plane. What do people think of allowing the center= parameter of 2D and 3D primitives to be a vector of booleans. That way one could center a primitive on whatever axes are desired instead of all or nothing. In my cube example I could use: cube([10, 20, 5], center=[true, true, false]); instead of translate([-5, -10, 0]) cube([10, 20, 5]); or translate([0, 0, 2.5]) cube([10, 20, 5]); Although not clean it would also be handy if booleans could also be represented by zero/non-zero numeric values instead of the verbose "true" and "false". I'm open to other ways of doing the above if anyone has any suggestions. Drew
CL
Chow Loong Jin
Mon, May 4, 2015 2:02 AM

On Sun, May 03, 2015 at 05:33:53PM -0700, Drew Rogge wrote:

I often find that I want a cube to be centered about the z axis but sitting on
the z = 0 xy plane. What do people think of allowing the center= parameter of 2D
and 3D primitives to be a vector of booleans. That way one could center a
primitive on whatever axes are desired instead of all or nothing. In my cube
example I could use:

cube([10, 20, 5], center=[true, true, false]);

instead of translate([-5, -10, 0]) cube([10, 20, 5]); or translate([0, 0,
2.5]) cube([10, 20, 5]);

Although not clean it would also be handy if booleans could also be
represented by zero/non-zero numeric values instead of the verbose "true" and
"false".

I'm open to other ways of doing the above if anyone has any suggestions.

This is something that has crossed my mind recently as well, and I quite like
the idea. But the zero/non-zero numeric values should probably not be used, as
that tends to imply a coordinate rather than a bitfield.

--
Kind regards,
Loong Jin

On Sun, May 03, 2015 at 05:33:53PM -0700, Drew Rogge wrote: > I often find that I want a cube to be centered about the z axis but sitting on > the z = 0 xy plane. What do people think of allowing the center= parameter of 2D > and 3D primitives to be a vector of booleans. That way one could center a > primitive on whatever axes are desired instead of all or nothing. In my cube > example I could use: > > cube([10, 20, 5], center=[true, true, false]); > > instead of translate([-5, -10, 0]) cube([10, 20, 5]); or translate([0, 0, > 2.5]) cube([10, 20, 5]); > > Although not clean it would also be handy if booleans could also be > represented by zero/non-zero numeric values instead of the verbose "true" and > "false". > > I'm open to other ways of doing the above if anyone has any suggestions. This is something that has crossed my mind recently as well, and I quite like the idea. But the zero/non-zero numeric values should probably not be used, as that tends to imply a coordinate rather than a bitfield. -- Kind regards, Loong Jin
M
MichaelAtOz
Mon, May 4, 2015 2:48 AM

Although not clean it would also be handy if booleans could also be

represented by zero/non-zero numeric values instead of the verbose "true"
and "false".

wiki https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
"Most values, when used in a Boolean context, are equivalent to 'true', but
there are a few that are equivalent to 'false'. The values that count as
false are:

false
0 and -0
""
[]
undef

Note that nan (Not A Number) counts as true."


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12565.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

> Although not clean it would also be handy if booleans could also be represented by zero/non-zero numeric values instead of the verbose "true" and "false". wiki <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General> "Most values, when used in a Boolean context, are equivalent to 'true', but there are a few that are equivalent to 'false'. The values that count as false are: false 0 and -0 "" [] undef Note that nan (Not A Number) counts as true." ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12565.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Mon, May 4, 2015 3:38 AM

On May 3, 2015, at 20:33 PM, Drew Rogge drew@DasRogges.com wrote:

[…]
cube([10, 20, 5], center=[true, true, false]);

On May 3, 2015, at 20:33 PM, Drew Rogge <drew@DasRogges.com> wrote: > […] > cube([10, 20, 5], center=[true, true, false]); > See: https://github.com/openscad/openscad/issues/265 https://github.com/openscad/openscad/pull/753 Not quite resolved yet.. -Marius
DR
Drew Rogge
Mon, May 4, 2015 4:06 AM

@MichaelAtOz: in the center= case in version 2015.03-1, 1 doesn't equate to true. Try:

difference() {
cylinder(d=10, h=10, center=true);
cylinder(d=10, h=10, center=1);
}

0 does equate to false:

difference() {
cylinder(d=10, h=10);
cylinder(d=10, h=10, center=0);
}

@Marius: thanks for the reference to issue #265. Not sure that I would want anything more than just being able to center on the individual axes. Using the center= parameter to offset to an arbitrary position seems counter intuitive.

It's been almost a year since anythings happened with pull #753. What would it take to move this forward?

Thanks,
Drew

On 5/3/15 8:38 PM, Marius Kintel wrote:

On May 3, 2015, at 20:33 PM, Drew Rogge drew@DasRogges.com wrote:

[…]
cube([10, 20, 5], center=[true, true, false]);

@MichaelAtOz: in the center= case in version 2015.03-1, 1 doesn't equate to true. Try: difference() { cylinder(d=10, h=10, center=true); cylinder(d=10, h=10, center=1); } 0 does equate to false: difference() { cylinder(d=10, h=10); cylinder(d=10, h=10, center=0); } @Marius: thanks for the reference to issue #265. Not sure that I would want anything more than just being able to center on the individual axes. Using the center= parameter to offset to an arbitrary position seems counter intuitive. It's been almost a year since anythings happened with pull #753. What would it take to move this forward? Thanks, Drew On 5/3/15 8:38 PM, Marius Kintel wrote: > On May 3, 2015, at 20:33 PM, Drew Rogge <drew@DasRogges.com> wrote: > >> […] >> cube([10, 20, 5], center=[true, true, false]); >> > See: > https://github.com/openscad/openscad/issues/265 > https://github.com/openscad/openscad/pull/753 > > Not quite resolved yet.. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
M
MichaelAtOz
Mon, May 4, 2015 4:34 AM

Drew Rogge wrote

@MichaelAtOz: in the center= case in version 2015.03-1, 1 doesn't equate
to true. Try:

difference() {
cylinder(d=10, h=10, center=true);
cylinder(d=10, h=10, center=1);
}

0 does equate to false:

difference() {
cylinder(d=10, h=10);
cylinder(d=10, h=10, center=0);
}

I'd say that-there is a bug.


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12568.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Drew Rogge wrote > @MichaelAtOz: in the center= case in version 2015.03-1, 1 doesn't equate > to true. Try: > > > difference() { > cylinder(d=10, h=10, center=true); > cylinder(d=10, h=10, center=1); > } > > 0 does equate to false: > > difference() { > cylinder(d=10, h=10); > cylinder(d=10, h=10, center=0); > } I'd say that-there is a bug. ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12568.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Mon, May 4, 2015 4:44 AM

Github issue raised  1333 https://github.com/openscad/openscad/issues/1333


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12569.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Github issue raised 1333 <https://github.com/openscad/openscad/issues/1333> ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12569.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DR
Drew Rogge
Mon, May 4, 2015 4:46 AM

Thanks Michael.

On 5/3/15 9:44 PM, MichaelAtOz wrote:

Thanks Michael. On 5/3/15 9:44 PM, MichaelAtOz wrote: > Github issue raised 1333 <https://github.com/openscad/openscad/issues/1333> > >
M
MichaelAtOz
Mon, May 4, 2015 5:43 AM

Workaround

translate([0,20,0])
cylinder(d=10,h=10, center=!!0);
translate([0,-20,0])
cylinder(d=10,h=10, center=!!1);


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12572.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Workaround translate([0,20,0]) cylinder(d=10,h=10, center=!!0); translate([0,-20,0]) cylinder(d=10,h=10, center=!!1); ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/allowing-center-parameter-to-be-a-vector-of-booleans-tp12563p12572.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DR
Drew Rogge
Sat, May 30, 2015 6:47 PM

On 05/03/2015 08:38 PM, Marius Kintel wrote:

On May 3, 2015, at 20:33 PM, Drew Rogge drew@DasRogges.com wrote:

[…]
cube([10, 20, 5], center=[true, true, false]);

It looks like the pull request listed above has been idle for a year so
I'm going to go ahead and implement the feature myself. The items in the
vector are going to be anything that can be converted to a boolean.
I'm not going to implement more fine grain positioning as discussed in
issue 265.

Right now the centering behavior for the different primitives that
accept the center= parameter are equivalent to:

	center == false		center == true

cube [false, false, false] [true, true, true]
cylinder [true, true, false] [true, true, true]
square [false, false, true] [true, true, true]
surface [false, false, ???] [true, true, ???]
linear_extrude [false, false, false] [false, false, true]

For primitives that don't take a center parameter:

sphere [true, true, true] [true, true, true]
circle [true, true, true] [true, true, true]
polygon [false, false, true] [false, false, true]
polyhedron [false, false, false] [false, false, false]

Note that the 2D prims square, circle and polygon only center in Z
because the default is that they have a height of 1 if not extruded.

One question is if all primitives should be changed to take the center
parameter and to center in all three axes. For example the default for
cylinder would still be [true, true, false] but one could be able to
specify [false, false, true] if a cylinder in the ++ quadrant and
centered in Z was desired. Sphere could could also do the same thing.

I think it's more orthogonal if all primitives could be centered in all
axes. In fact their default non-centered location should be in the +++
octant. However that would break existing programs.

Prims that are specified by coordinates like surface, polygon, etc are a
bit more problematic. Since the user is specifying the actual coords of
the components does centering make sense?

So anyway, thoughts on expanding centering to all prims in all axes?

Drew

On 05/03/2015 08:38 PM, Marius Kintel wrote: > > On May 3, 2015, at 20:33 PM, Drew Rogge <drew@DasRogges.com> wrote: > >> […] >> cube([10, 20, 5], center=[true, true, false]); >> > See: > https://github.com/openscad/openscad/issues/265 > https://github.com/openscad/openscad/pull/753 > > Not quite resolved yet.. > > -Marius > It looks like the pull request listed above has been idle for a year so I'm going to go ahead and implement the feature myself. The items in the vector are going to be anything that can be converted to a boolean. I'm not going to implement more fine grain positioning as discussed in issue 265. Right now the centering behavior for the different primitives that accept the center= parameter are equivalent to: center == false center == true cube [false, false, false] [true, true, true] cylinder [true, true, false] [true, true, true] square [false, false, true] [true, true, true] surface [false, false, ???] [true, true, ???] linear_extrude [false, false, false] [false, false, true] For primitives that don't take a center parameter: sphere [true, true, true] [true, true, true] circle [true, true, true] [true, true, true] polygon [false, false, true] [false, false, true] polyhedron [false, false, false] [false, false, false] Note that the 2D prims square, circle and polygon only center in Z because the default is that they have a height of 1 if not extruded. One question is if all primitives should be changed to take the center parameter and to center in all three axes. For example the default for cylinder would still be [true, true, false] but one could be able to specify [false, false, true] if a cylinder in the ++ quadrant and centered in Z was desired. Sphere could could also do the same thing. I think it's more orthogonal if all primitives could be centered in all axes. In fact their default non-centered location should be in the +++ octant. However that would break existing programs. Prims that are specified by coordinates like surface, polygon, etc are a bit more problematic. Since the user is specifying the actual coords of the components does centering make sense? So anyway, thoughts on expanding centering to all prims in all axes? Drew