Rotation & angle of universal joint?

RE: Rotation & angle of universal joint?
(2019-10-02, 3:36)N. W. Perry Wrote: Since I got such quick and helpful advice on my piston rod question, here is my next challenge: universal joints!

I don't have the time to go in to details at the moment, but you might want to look at my 8860 animation script (included in LDCad's examples).

It does realtime frame depended universal placements.

Code section of interest:

    --The universal joints are a bit tricky and need some rotation matrix 'magic'.
    -- As there are two of them a function can be used to apply things on both of them.
    -- This uses the source's known local X and Z axis' to construct the link's orientation by using the also known destination Z-axis (axle length direction).
    -- The orientation of the destination can then be constructed based upon the link's orientation.
    -- We don't have to worry about positions in absolute model space as the aniTools joint mechanics will take care of that.
    local function calcUniAxle(fromAxleOri, dstAxleZ, linkPosOri, dstAxlePosOri)

      local jntX=fromAxleOri:getOriRow(1)
      local jntZ=fromAxleOri:getOriRow(3)
      local jAngle=jntX:getSignedAngle(dstAxleZ, jntZ)

      local ori=ldc.matrix()
      ori:setRotate(jAngle, jntX)

      local jntY=jntZ:getCross(jntX)
      ori:setOriRows(jntX, jntY, jntZ)

      jAngle=jntY:getSignedAngle(dstAxleZ, jntZ)
      ori:setRotate(jAngle, jntY)
      dstAxlePosOri:setOriRows(jntX, jntY, jntZ)

    local z=self.axle1Joint.orgAbsPosOri:getPos()-self.axle3Joint.orgAbsPosOri:getPos()
    calcUniAxle(self.axle3PosOri.value, z, self.axleJnt2PosOri.value, self.axle2PosOri.value)

    calcUniAxle(self.axle2PosOri.value, z, self.axleJnt1PosOri.value, self.axle1PosOri.value)
« Next Oldest | Next Newest »

Messages In This Thread
RE: Rotation & angle of universal joint? - by Roland Melkert - 2019-10-02, 18:17

Forum Jump:

Users browsing this thread: 1 Guest(s)