discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: It's logical? [Solved]

F
fred
Thu, Dec 29, 2022 11:38 AM

The suggested conditional didn't perform as hoped, as I had made exactly that attempt. I changed it to == to see what would happen. The result was the inverse of my objective, which was promising. It created the nine pins in the appropriate locations. A bit more experimenting and this works:
if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) )

Thanks for the assistance!

On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller <private2michael@gmail.com> wrote:  

I'd just let the for loops produce the whole grid and put the "if" in the innermost place. It would then sayif ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) ) 
Msquare

The suggested conditional didn't perform as hoped, as I had made exactly that attempt. I changed it to == to see what would happen. The result was the inverse of my objective, which was promising. It created the nine pins in the appropriate locations. A bit more experimenting and this works: if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) ) Thanks for the assistance! On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller <private2michael@gmail.com> wrote: I'd just let the for loops produce the whole grid and put the "if" in the innermost place. It would then sayif ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )  Msquare
DM
Douglas Miller
Fri, Dec 30, 2022 2:04 PM

This is a trifle simpler, and (to me, at least) more clear:

    if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) )

The opposite of (a AND b) is not (NOT a) AND (NOT b): it's (NOT a)
OR (NOT b)
, and that's why the suggested

    if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )

doesn't work, and

    if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) )

will.

On 12/29/2022 6:38 AM, fred wrote:

The suggested conditional didn't perform as hoped, as I had made
exactly that attempt. I changed it to == to see what would happen. The
result was the inverse of my objective, which was promising. It
created the nine pins in the appropriate locations. A bit more
experimenting and this works:

if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) )

Thanks for the assistance!

On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller
private2michael@gmail.com wrote:

I'd just let the for loops produce the whole grid and put the "if" in
the innermost place. It would then say
if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )

Msquare

This is a trifle simpler, and (to me, at least) more clear:     if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) ) The opposite of *(a AND b)* is not *(NOT a) AND (NOT b)*: it's *(NOT a) OR (NOT b)*, and that's why the suggested     if ( (col_counter % 4 != 0) *&&* (row_counter % 4 != 0 ) ) doesn't work, and     if ( (col_counter % 4 != 0) *||* (row_counter % 4 != 0) ) will. On 12/29/2022 6:38 AM, fred wrote: > The suggested conditional didn't perform as hoped, as I had made > exactly that attempt. I changed it to == to see what would happen. The > result was the inverse of my objective, which was promising. It > created the nine pins in the appropriate locations. A bit more > experimenting and this works: > > if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) ) > > Thanks for the assistance! > > On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller > <private2michael@gmail.com> wrote: > > > I'd just let the for loops produce the whole grid and put the "if" in > the innermost place. It would then say > if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) ) > > Msquare > > >
HL
Hans L
Fri, Dec 30, 2022 10:10 PM

The conditional that Douglas Miller suggests is logically equivalent due to
"De Morgan's Laws" by the way:
https://en.wikipedia.org/wiki/De_Morgan%27s_laws

On Fri, Dec 30, 2022 at 8:05 AM Douglas Miller doug@milmac.com wrote:

This is a trifle simpler, and (to me, at least) more clear:

 if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) )

The opposite of (a AND b) is not (NOT a) AND (NOT b): it's (NOT a)
OR (NOT b)
, and that's why the suggested

 if ( (col_counter % 4 != 0) *&&* (row_counter % 4 != 0 ) )

doesn't work, and

 if ( (col_counter % 4 != 0) *||* (row_counter % 4 != 0) )

will.

On 12/29/2022 6:38 AM, fred wrote:

The suggested conditional didn't perform as hoped, as I had made exactly
that attempt. I changed it to == to see what would happen. The result was
the inverse of my objective, which was promising. It created the nine pins
in the appropriate locations. A bit more experimenting and this works:

if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) )

Thanks for the assistance!

On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller
private2michael@gmail.com private2michael@gmail.com wrote:

I'd just let the for loops produce the whole grid and put the "if" in the
innermost place. It would then say
if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )

Msquare


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

The conditional that Douglas Miller suggests is logically equivalent due to "De Morgan's Laws" by the way: https://en.wikipedia.org/wiki/De_Morgan%27s_laws On Fri, Dec 30, 2022 at 8:05 AM Douglas Miller <doug@milmac.com> wrote: > This is a trifle simpler, and (to me, at least) more clear: > > if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) ) > > The opposite of *(a AND b)* is not *(NOT a) AND (NOT b)*: it's *(NOT a) > OR (NOT b)*, and that's why the suggested > > if ( (col_counter % 4 != 0) *&&* (row_counter % 4 != 0 ) ) > > doesn't work, and > > if ( (col_counter % 4 != 0) *||* (row_counter % 4 != 0) ) > > will. > > On 12/29/2022 6:38 AM, fred wrote: > > The suggested conditional didn't perform as hoped, as I had made exactly > that attempt. I changed it to == to see what would happen. The result was > the inverse of my objective, which was promising. It created the nine pins > in the appropriate locations. A bit more experimenting and this works: > > if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) ) > > Thanks for the assistance! > > On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller > <private2michael@gmail.com> <private2michael@gmail.com> wrote: > > > I'd just let the for loops produce the whole grid and put the "if" in the > innermost place. It would then say > if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) ) > > Msquare > > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
F
fred
Fri, Dec 30, 2022 10:18 PM

After seeing DeMorgan's Laws, I realize that this is something I once knew, again, back in my high school days, but those bytes have been lost to the extreme birthdays behind me.  I suppose since they are equivalent, having accomplished this much has been satisfying.
If it wasn't for the necessity of a taper, I'd have been able to SVG this entire project. Even now, if the alignment isn't correct, I'll start with an SVG and difference shorter cylinders without the taper in every location. As long as it doesn't reach z = 0, the effective result is acceptable.
It's certainly been a fun learning experience, which is part of the reason I use (and occasionally struggle with) OpenSCAD. This would have been a fun high school or college course, to be sure.

On Friday, December 30, 2022 at 05:11:47 PM EST, Hans L <thehans@gmail.com> wrote:  

The conditional that Douglas Miller suggests is logically equivalent due to "De Morgan's Laws" by the way:https://en.wikipedia.org/wiki/De_Morgan%27s_laws

On Fri, Dec 30, 2022 at 8:05 AM Douglas Miller doug@milmac.com wrote:

This is a trifle simpler, and (to me, at least) more clear:

    if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) )

The opposite of (a AND b) is not (NOT a) AND (NOT b): it's (NOT a) OR (NOT b), and that's why the suggested

    if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )

doesn't work, and
   
    if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) )

will.

On 12/29/2022 6:38 AM, fred wrote:

The suggested conditional didn't perform as hoped, as I had made exactly that attempt. I changed it to == to see what would happen. The result was the inverse of my objective, which was promising. It created the nine pins in the appropriate locations. A bit more experimenting and this works:
if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) )

Thanks for the assistance!

  On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller <private2michael@gmail.com> wrote:  

 I'd just let the for loops produce the whole grid and put the "if" in the innermost place. It would then say if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )  

Msquare


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

After seeing DeMorgan's Laws, I realize that this is something I once knew, again, back in my high school days, but those bytes have been lost to the extreme birthdays behind me.  I suppose since they are equivalent, having accomplished this much has been satisfying. If it wasn't for the necessity of a taper, I'd have been able to SVG this entire project. Even now, if the alignment isn't correct, I'll start with an SVG and difference shorter cylinders without the taper in every location. As long as it doesn't reach z = 0, the effective result is acceptable. It's certainly been a fun learning experience, which is part of the reason I use (and occasionally struggle with) OpenSCAD. This would have been a fun high school or college course, to be sure. On Friday, December 30, 2022 at 05:11:47 PM EST, Hans L <thehans@gmail.com> wrote: The conditional that Douglas Miller suggests is logically equivalent due to "De Morgan's Laws" by the way:https://en.wikipedia.org/wiki/De_Morgan%27s_laws On Fri, Dec 30, 2022 at 8:05 AM Douglas Miller <doug@milmac.com> wrote: This is a trifle simpler, and (to me, at least) more clear:     if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) ) The opposite of (a AND b) is not (NOT a) AND (NOT b): it's (NOT a) OR (NOT b), and that's why the suggested     if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) ) doesn't work, and         if ( (col_counter % 4 != 0) || (row_counter % 4 != 0) ) will. On 12/29/2022 6:38 AM, fred wrote: The suggested conditional didn't perform as hoped, as I had made exactly that attempt. I changed it to == to see what would happen. The result was the inverse of my objective, which was promising. It created the nine pins in the appropriate locations. A bit more experimenting and this works: if (! ( (col_counter % 4 == 0) && (row_counter % 4 == 0 ) ) ) Thanks for the assistance! On Wednesday, December 28, 2022 at 07:03:20 PM EST, Michael Möller <private2michael@gmail.com> wrote: I'd just let the for loops produce the whole grid and put the "if" in the innermost place. It would then say if ( (col_counter % 4 != 0) && (row_counter % 4 != 0 ) )  Msquare _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
DM
Douglas Miller
Sat, Dec 31, 2022 9:42 AM

On 12/30/2022 5:10 PM, Hans L wrote:

The conditional that Douglas Miller suggests is logically equivalent
due to "De Morgan's Laws" by the way:
https://en.wikipedia.org/wiki/De_Morgan%27s_laws

Yes, it is, and I was stunned to discover, early in my career, how many
professional programmers don't know those laws. In my opinion, it should
be impossible to graduate a university curriculum in computer science
without understanding them. Later, when I began /teaching/ computer
science, I did my own small part to rectify that situation.

My first exposure to them was in an undergrad course in formal logic --
which I took as an elective; inexplicably, it was not required for my
major. I think it should be. In fact, I think a course in formal logic
should be a requirement for earning a university degree in /any/
subject, or even for earning a high school diploma -- but that's an
entirely different rant.

On 12/30/2022 5:10 PM, Hans L wrote: > The conditional that Douglas Miller suggests is logically equivalent > due to "De Morgan's Laws" by the way: > https://en.wikipedia.org/wiki/De_Morgan%27s_laws > Yes, it is, and I was stunned to discover, early in my career, how many professional programmers don't know those laws. In my opinion, it should be impossible to graduate a university curriculum in computer science without understanding them. Later, when I began /teaching/ computer science, I did my own small part to rectify that situation. My first exposure to them was in an undergrad course in formal logic -- which I took as an elective; inexplicably, it was not required for my major. I think it should be. In fact, I think a course in formal logic should be a requirement for earning a university degree in /any/ subject, or even for earning a high school diploma -- but that's an entirely different rant.