I’ve made some prints fit in my printer by printing them at a diagonal. I work it out by spinning it until I don’t get an error from the slicer.

I’d rather be able to calculate exactly what will fit beforehand instead of spinning the model around in CAD or the slicer.

Has anyone found/used a calculator that can do this?

  • HelloRoot@lemy.lol
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    27 days ago

    You won’t believe it but thats actually a very hard problem to solve algorithmically.

    If you want to search further, it is called the “containment under free rotation” problem.


    Edit:

    There is a tool called trimesh that lets you load in meshes, compute convex hulls, and compute oriented minimum bounding boxes. https://trimesh.org/quick_start.html search for “bounding box” on that page.

    • tal@lemmy.today
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      27 days ago

      The best methods we have (afaik) basically randomly position the object and then nudge it until it gives up after doing lots of tries

      I’m skeptical. I can think of some problems that do work like that, like graphviz’s node-cluster-and-fit-to-a-plane layout stuff. But here, you should just need to be working with the convex hull. It should be possible to eliminate a lot of classes of potential solutions by reducing it to looking at edge cases, like some face of the convex hull is in-plane with the bounding box or something.

      kagis

      Yeah.

      https://en.wikipedia.org/wiki/Minimum_bounding_box_algorithms

      In computational geometry, the smallest enclosing box problem is that of finding the oriented minimum bounding box enclosing a set of points. It is a type of bounding volume. “Smallest” may refer to volume, area, perimeter, etc. of the box.

      It is sufficient to find the smallest enclosing box for the convex hull of the objects in question.

      In 1985, Joseph O’Rourke published a cubic-time algorithm to find the minimum-volume enclosing box of a 3-dimensional point set.

      It is also possible to approximate the minimum bounding box volume, to within any constant factor greater than one, in linear time.

      EDIT: Though if OP is rotating along anything other than just the up-and-down axis (is that, by convention, Z for 3D printing? Been a while since I’ve printed anything), it’s more complicated than just determining whether a rotated object will fit in the bounding box, because 3D printers have their own constraints in things like the overhang that they can do.

      • HelloRoot@lemy.lol
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        27 days ago

        Technically my statement is incorrect, I agree.

        But have you read the algo?

        It basically takes the global minimum over all edge pairs (and their zero-curves) and return the orientation and extents with the smallest encountered volume. Which is basically like trying every possible position along the edges of the convex hull around your obect.

        But I edited my comment to remove that part, because that bit is honestly irrelevant for OPs question.

        • tal@lemmy.today
          link
          fedilink
          English
          arrow-up
          2
          ·
          27 days ago

          It’s not the nudging that you referred to. You edited your comment after I responded to remove that part of your comment.

          • HelloRoot@lemy.lol
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            27 days ago

            True, the random positioning and nudging is something I saw in gamedev for some reason a long time ago.

            I edited it before I read your reply and after I found a tool that can do what OP asked for.

              • HelloRoot@lemy.lol
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                27 days ago

                No need to be sorry, I’m actually happy that people on lemmy give their best to uphold Cunningham’s Law by correcting wrong statements.

                It’s a me problem, cause I think more after I write, so I end up posting, then editing the same comment a lot until it is “right”.

                Cheers! :D

      • Blue_Morpho@lemmy.worldOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        26 days ago

        because 3D printers have their own constraints in things like the overhang that they can do.

        That’s what supports are for. :) In my case I made a custom sprue because autogen supports sagged unless it was 0 clearance.

        I was just looking for something like a rectangular prism or cylinder to fit in a cube. I was surprised by the replies that it’s mathematically hard. I expected it to be a geometry problem with a bit of calculus to find the convergence.

    • MysteriousSophon21@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      25 days ago

      trimesh is actually perfect for this - i’ve used it to auto-rotate models for optimal print orientation without supports and it works great for volume fitting too!

  • roofuskit@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    27 days ago

    Never seen one, doesn’t seem universally useful considering how difficult and impractical it can make printing certain things.