JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Problem with "subtract()"ing "hull()", is this a bug?

    Scheduled Pinned Locked Moved Design Discussions
    4 Posts 1 Posters 1.9k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Hermann-SWH Offline
      Hermann-SW
      last edited by Hermann-SW

      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:
      https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria2.png

      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()":
      https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria.subtract_hull.problem.png

      Here is hull definition:

              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})
                             )
      
      

      Why does "subtract()" not work when subtracting "h"?
      (subtract does work for look_inside=yes, subtracting sphere and cube from outer sphere)
      Here is link for you to play with:
      https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/Q.JSCAD.vertex_edge2.sp_tria.js

      ...
              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
                           )  
      ...
      

      "sp_tria(4,13,14)" call is in line 244 near the end.

      1 Reply Last reply Reply Quote 0
      • Hermann-SWH Offline
        Hermann-SW
        last edited by

        Oops, too late/early, need to get more sleep.

        1. problem was bad indentation of brackets and placing ",h" at wrong level.
        2. problem was that I want "intersect()" and not "subtract()":
                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
                               )
                             )  
        
        

        Works like a charme now:
        https://stamm-wilbrandt.de/en/forum/JSCAD.sp_tria.subtract_hull.solution.png

        Hermann-SWH 1 Reply Last reply Reply Quote 0
        • Hermann-SWH Offline
          Hermann-SW
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Hermann-SWH Offline
            Hermann-SW @Hermann-SW
            last edited by

            Forgot to post the "answer" link for viewing in browser:
            https://openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/A.JSCAD.vertex_edge2.sp_tria.js

            1 Reply Last reply Reply Quote 0
            • Hermann-SWH Hermann-SW referenced this topic on

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            Powered by NodeBB | Contributors