[OpenSCAD] XOR

whosawhatsis whosawhatsis at gmail.com
Sun Jul 15 21:11:13 CEST 2012


XOR doesn't really make sense with more than two objects. Difference takes the first object and subtracts all the others from it, so for consistency with that, I would recommend unioning all of the children after the first before feeding it to the function that you have defined. As you have written it, only areas included in all objects will be subtracted.

On Sunday, July 15, 2012 at 9:41 AM, Johannes Reinhardt wrote:

> Hi everybody,
> 
> I just made a xor module to accompany union, intersection and
> difference. After drawing some truth tables I figured out that the
> difference of union and intersection should give xor, or in OpenSCAD
> code:
> 
> module xor(){
> difference(){
> for(i = [0 : $children - 1])
> child(i);
> intersection_for(i = [0: $children -1])
> child(i);
> } 
> }
> 
> Maybe this is of use for someone.
> 
> Regards
> 
> Johannes
> 
> 
> -- 
> Johannes Reinhardt <jreinhardt at ist-dein-freund.de (mailto:jreinhardt at ist-dein-freund.de)>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org)
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20120715/1a48f616/attachment.html


More information about the OpenSCAD mailing list