sketchucation logo sketchucation
    • Login
    1. Home
    2. Cheesygecko
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Groups 1

    Cheesygecko

    @Cheesygecko

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Cheesygecko Unfollow Follow
    registered-users

    Latest posts made by Cheesygecko

    • Rotation Matrix problem

      Hello, i've working with the ruby api for a few weeks now. I want to mate two components by their construction points (position) and Construction lines (alignment). I compute the global position of the points and move one component to another (so setting the position works fine). The problem is the alignment. I compoute the angle between the axis of the components. I get a correct angle in this part of my code. I also compue the normal vector of the plane that is defined by the two axes. Then i build a transformation matrix that should rotate the component , so the axes are parallel.The result is that they are "almost" parallel and the rotated component shrinks a little.
      Can anyone tell me why this is working this way? Is the matrix correct? Thank you! 😎

      This is my matrix (normal is the axis for the rotation, radAngle is the angle in radians:

      trans = Array.new(16)
      trans[0] = Math.cos(radAngle)+(normal[0]normal[0])(1-Math.cos(radAngle))
      trans[1] = (normal[0]normal[1])(1-Math.cos(radAngle))+normal[2]*Math.sin(radAngle)
      trans[2] = (normal[0]normal[2])(1-Math.cos(radAngle))-normal[1]*Math.sin(radAngle)
      trans[3] = 0

      trans[4] = (normal[0]normal[1])(1-Math.cos(radAngle))-normal[2]*Math.sin(radAngle)
      trans[5] = Math.cos(radAngle)+(normal[1]normal[1])(1-Math.cos(radAngle))
      trans[6] = (normal[1]normal[2])(1-Math.cos(radAngle))+normal[0]*Math.sin(radAngle)
      trans[7] = 0

      trans[8] = (normal[0]normal[2])(1-Math.cos(radAngle))+normal[1]*Math.sin(radAngle)
      trans[9] = (normal[1]normal[2])(1-Math.cos(radAngle))-normal[0]*Math.sin(radAngle)
      trans[10] = Math.cos(radAngle)+(normal[2]normal[2])(1-Math.cos(radAngle))
      trans[11] = 0

      trans[12] = 0
      trans[13] = 0
      trans[14] = 0
      trans[15] = 1

      mat = Geom::Transformation.new trans

      $newComp.transform! mat

      posted in Developers' Forum
      C
      Cheesygecko