JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

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

    Design Discussions
    1
    4
    679
    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-SW
      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
      • Referenced by  Hermann-SW Hermann-SW 
      • Hermann-SW
        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-SW
          Hermann-SW last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Hermann-SW
            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-SW 1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB | Contributors