Skip to content

Does not appear to handle chained transformations correctly #185

Closed

Description

@charlieb

When transformations are chained together in the normal openscad way solid only seems to take the outermost.

The two snippets should generate the same object but in the second case all that's generated is a translated sphere.

Consider the results of:
sp = s.sphere(r=10)
sp = s.scale([1, 2, 0.5])(sp)
sp = s.rotate([0, 20 + 9, 10])(sp)
sp = s.translate([-4, 0, 8])(sp)

vs

s.translate([-4, 0, 8])(
s.rotate([0, 20 + 9, 10])(
s.scale([1, 2, 0.5])))(
s.sphere(r=10))

Activity

  1. jeff-dh commented on Sep 19, 2021

    @jeff-dh
    Collaborator

    Take a closer look at the parenthesis of your second code snippet.

    I only reformated it:

    s.translate([-4, 0, 8])(
        s.rotate([0, 20 + 9, 10])(
            s.scale([1, 2, 0.5])
        )
    )(
        s.sphere(r=10)
    )
    

    And that's exactly the code (at least exp)Solid generates:

    translate(v = [-4, 0, 8]) {
            rotate(a = [0, 29, 10]) {
                    scale(v = [1, 2, 0.5000000000]);
            }
            sphere(r = 10);
    }
    
  2. charlieb commented on Sep 19, 2021

    @charlieb
    Author

    Oh I see what I did. I wasn't thinking of it as a tree. I had imagined that calling translate with a rotation argument would result in a callable that performs both operations and that if I called that operation on a sphere it would do both. What it actually does is to build a tree from the translation object with two children that are processed separately.

    The code I was looking for was:
    s.translate([-4, 0, 8])(
    s.rotate([0, 20 + 9, 10])(
    s.scale([1, 2, 0.5])(
    s.sphere(r=10))))

    Where every subsequent call creates a single branch from its predecessor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions