sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Translation and rotation vectors of copies of a component

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    5 Posts 3 Posters 481 Views 3 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.
    • S Offline
      smicha
      last edited by

      HI,
      I am looking for a help how to get a list of vectors of translation and rotation of every copy of the same component. It would be great to have such a list as a txt or csv file, eg:

      copy0 tx0 ty0 tz0 rx0 ry0 rz0
      copy1 tx1 ty1 tz1 rx1 ry1 rz1
      copy2 tx2 ty2 tz2 rx2 ry2 rz2
      .
      .
      .
      copyN txN tyN tzN rxN ryN rzN

      where tx ty tz denote translation, and rz ry rx rotaion.

      Users, please help. If this could be done in a form of a plugin it would be great. The intent is to use it in Octane Render and instancing.

      smicha


      copies2.jpg

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        The transformation matrix for components and groups is a 16 element array which contains the vector definitions for the x,y,z axes and the origin point. The rotations can be derived by finding the arcsin or arccos of certain values of the array.

        If t is the transformation array and tx0,ty0,tz0 refers to the origin then tx0=t[12], ty0=t[13], and tz0=t[14]. The x_rotation=acos(t[5]), y_rotation=acos(t[0]), and z_rotation=asin(t[4]). These rotation values are not independent and can be influenced by one another.

        What do you plan to do with this info once it is written to a file?

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • S Offline
          smicha
          last edited by

          @sdmitch said:

          What do you plan to do with this info once it is written to a file?

          Sam,
          Otoy in Octane Render introduced instancing, which shortly speaking means you can render let's say an obj that occupies 100MB of vram and copy it thousands times and still use 100mb of vram. To do so you have to manually add every copy/placement in Octane and input scale, rotation and translation parameters for x y z. Or you can paste or upload a scv file that contains such information in a form of a matrix Nx12, where N represents number of copies of an obj. and 12 are columns. I paste some info from Octane forum:

          *The coordinates in a scatter node are given as the first three rows of the transformation matrices (the fourth is always [0, 0, 0, 1).

          For instance the matrix for a 30° rotation around the Z axis looks like this:
          [.87, –.50, 0, 0]
          [.50, .87, 0, 0]
          [ 0, 0, 1, 0]
          [ 0, 0, 0, 1]

          The scatter node will contain these 12 values:
          .87 –.50 0 0 .50 .87 0 0 0 0 1 0

          For a translation:
          [1, 0, 0, tx]
          [0, 1, 0, ty]
          [0, 0, 1, tz]
          [0, 0, 0, 1]

          The scatter node will contain these 12 values:
          1 0 0 tx 0 1 0 ty 0 0 1 tz]*

          So I need these values to create such Nx12 matrix.

          I am attaching a screenshot from Octane. On the top right you see such matrix. Hope it clarifies my request for help.

          smicha


          scatter2.jpg

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Smicha

            I've responded on the Octane forum...
            It is possible...
            However, remember the YZ swapping and inches > meters etc...
            Here are questions...
            @unknownuser said:

            Is there a way to make Octane import csv information - or must you do that manually ?
            It would be possible for you to do it something like this...
            You select one component-instance.
            You run the tool.
            It makes a small OBJ/MTL file - named as the Model_Component's name - in the project's folder.
            It finds all component-instances that are the same definition.
            It makes a CSV file containing the location/rotation and scaling information for each.
            One entry per line.
            We name it after the Model_Component's name.
            The OBJ and CSV are imported into the OCS and it uses the one instance multiple times...

            Can you confirm the order that the CSV file's '12' entries need to be in ?
            Also what they are - I assume 'meters' and YZ swapping as usual...
            Do you have a simple/short example??

            I'll think about the example coding and come back to you soon...
            Some are already answered. You manually link the 'Box.OBJ' and 'Scatter' files ?
            The location of an instance is given in the elements near the end.
            I think the example transformation you showed is 'rotated'?
            There are several threads explaining what each part of the array does, several interact...
            First off... we need to establish what is extracted from the SKP transformation's 16 elements and put into your 12 in what order. The YZ swapping and making inches into meters is already discussed; the other rotation/scaling elements are 'floats' and don't need tweaking - beyond getting them in the right place. 🤓

            TIG

            1 Reply Last reply Reply Quote 0
            • S Offline
              smicha
              last edited by

              TIG,
              I'll keep answering your question on Octane forum.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement