<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem with &quot;subtract()&quot;ing &quot;hull()&quot;, is this a bug?]]></title><description><![CDATA[<p dir="auto">For drawing a spherical triangle I need to draw 2 "sp_tria2()"s in that triangle on the sphere. "sp_tria2()" might overshoot sphere triangle borders as here:<br />
<img src="https://camo.nodebb.org/eb0e7b37494549aeb4733c291a9f1b2a3b2a77e1?url=https%3A%2F%2Fstamm-wilbrandt.de%2Fen%2Fforum%2FJSCAD.sp_tria2.png" alt="https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria2.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Next I create "hull()" from 6 points (found no way to do that, created "hull()" of 6 very small "cube()"s instead), the 3 triangle coordinates, and those coordinates scaled up to that "hull()" completely contains the wanted triangle part of "sp_tria2()":<br />
<img src="https://camo.nodebb.org/90d5497b243efd9e24ba38c714669c17fd1cef04?url=https%3A%2F%2Fstamm-wilbrandt.de%2Fen%2Fforum%2FJSCAD.sp_tria.subtract_hull.problem.png" alt="https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria.subtract_hull.problem.png" class=" img-responsive img-markdown" /></p>
<p dir="auto">Here is hull definition:</p>
<pre><code>        h =            hull(
                           cube({center: sv1, size: 0.01})
                           ,cube({center: sv2, size: 0.01})
                           ,cube({center: sv3, size: 0.01})
                           ,cube({center: s1, size: 0.01})
                           ,cube({center: s2, size: 0.01})
                           ,cube({center: s3, size: 0.01})
                       )

</code></pre>
<p dir="auto">Why does "subtract()" not work when subtracting "h"?<br />
(subtract does work for look_inside=yes, subtracting sphere and cube from outer sphere)<br />
Here is link for you to play with:<br />
<a href="https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/Q.JSCAD.vertex_edge2.sp_tria.js" rel="nofollow ugc">https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/Q.JSCAD.vertex_edge2.sp_tria.js</a></p>
<pre><code>...
        return colorize([0.5,0.5,0.5],
                     subtract(
                        translate([0,0,0],
                                  rotate([0,0,la1-degToRad(180)],
                                         rotate([0,ph1-degToRad(90),0],
                                                rotate([0,0,-al13],
                                                       sp_tria2(sc, s12, mpi(al13-al12), 0.1, 40, 40)
                                                      )
                                               )
                                        )
                                 )
                       ),
                       h
                     )  
...
</code></pre>
<p dir="auto">"sp_tria(4,13,14)" call is in line 244 near the end.</p>
]]></description><link>https://openjscad.nodebb.com/topic/378/problem-with-subtract-ing-hull-is-this-a-bug</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Mar 2026 11:57:45 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/378.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Aug 2022 03:45:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem with &quot;subtract()&quot;ing &quot;hull()&quot;, is this a bug? on Sun, 14 Aug 2022 08:33:32 GMT]]></title><description><![CDATA[<p dir="auto">Forgot to post the "answer" link for viewing in browser:<br />
<a href="https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/A.JSCAD.vertex_edge2.sp_tria.js" rel="nofollow ugc">https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/A.JSCAD.vertex_edge2.sp_tria.js</a></p>
]]></description><link>https://openjscad.nodebb.com/post/1239</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1239</guid><dc:creator><![CDATA[Hermann-SW]]></dc:creator><pubDate>Sun, 14 Aug 2022 08:33:32 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with &quot;subtract()&quot;ing &quot;hull()&quot;, is this a bug? on Sun, 14 Aug 2022 04:12:34 GMT]]></title><description><![CDATA[<p dir="auto">Oops, too late/early, need to get more sleep.</p>
<ol>
<li>problem was bad indentation of brackets and placing ",h" at wrong level.</li>
<li>problem was that I want "intersect()" and not "subtract()":</li>
</ol>
<pre><code>        return colorize([0.5,0.5,0.5],
                     intersect(
                        translate([0,0,0],
                                  rotate([0,0,la1-degToRad(180)],
                                         rotate([0,ph1-degToRad(90),0],
                                                rotate([0,0,-al13],
                                                       sp_tria2(sc, s12, mpi(al13-al12), 0.1, 40, 40)
                                                      )
                                               )
                                        )
                                 ),
                         h
                       )
                     )  

</code></pre>
<p dir="auto">Works like a charme now:<br />
<img src="https://camo.nodebb.org/24f54cb6993aba32bfd7a597487daa9e1728350c?url=https%3A%2F%2Fstamm-wilbrandt.de%2Fen%2Fforum%2FJSCAD.sp_tria.subtract_hull.solution.png" alt="https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria.subtract_hull.solution.png" class=" img-responsive img-markdown" /></p>
]]></description><link>https://openjscad.nodebb.com/post/1237</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1237</guid><dc:creator><![CDATA[Hermann-SW]]></dc:creator><pubDate>Sun, 14 Aug 2022 04:12:34 GMT</pubDate></item></channel></rss>