Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Entities Translation Transformation

Entities Translation Transformation

Scheduled Pinned Locked Moved Python API
4 Posts 2 Posters 555 Views
  • 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.
  • R Offline
    R Offline
    rediponi
    wrote on last edited by
    #1

    I apply a Translational transformation to a group of entities without changing other parameters.
    For the solid objects everything is fine, however for the Lines the Rotation property values are changed as well, even thought i dont apply any rotation. What might be the problem ?

    1 Reply Last reply
    0
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      It depends a bit on how you apply the transformation. Are you using the ApplyTransform function recursively to each of the entities of the group?
      Can you add a screenshot of the translation/rotation properties of the Line object before and after you apply the translation?

      R 1 Reply Last reply
      0
      • SylvainS Sylvain

        It depends a bit on how you apply the transformation. Are you using the ApplyTransform function recursively to each of the entities of the group?
        Can you add a screenshot of the translation/rotation properties of the Line object before and after you apply the translation?

        R Offline
        R Offline
        rediponi
        wrote on last edited by
        #3

        @sylvain Below you can find the screenshot. I notice that the rotation matrix changes.
        Also is there any way to input the old rotation matrix directly (without converting to an angle and a vector) ?
        0_1531412045452_7bc0a84e-6663-4dd3-bf1c-db1a81dd8a1a-image.png

        1 Reply Last reply
        0
        • SylvainS Offline
          SylvainS Offline
          Sylvain
          ZMT
          wrote on last edited by Sylvain
          #4

          The behavior you are describing is a related to a not-so-uncommon misunderstanding of the .Transform property.

          Model entities in Sim4Life have a Transform property (which you access by obj.Transform, for example). This property holds the transformation matrix between the initial object and its final position. This means that it holds the composition of all the transformations that have been applied to this object since its creation. So when you write something like obj.Transform = Rotation(axis, ori, ang), it does not just rotate the object - it replaces the transformation by a simple rotation, erasing all previous displacements.

          To apply a rotation, one should instead use obj.ApplyTransform(Rotation(axis, ori, ang)). The same is true for applying a translation: first define a Translation object (which is usually independent of the Transform property of the object itself), then apply the transformation.

          For example:

          
          from s4l_v1.model import Vec3, Translation, Transform
          import numpy
          
          t = Translation(Vec3(-20, -16, 10))           # for a translation
          r = Rotation(Vec3(0, 0, 1), numpy.pi / 4)  # for a rotation of angle pi/4 around the z-axis
          
          case = model.CreateSolidBlock(Vec3(0, 0, 0), Vec3(40, 16, -140))
          case.ApplyTransform( t )
          case.ApplyTransform( r )
          
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Search