Page 1 of 1

Orientation on path

Posted: 26 Aug 2019, 09:50
by Maenre
Hello everyone.

I'm trying to make the dummy object following the path and failing to set object orientation coordinate (rotation around Z). I'm using getOrientationOnPath and using one of the axis rotation value to rotate my object around Z. For some reason on some parts of the path I get wrong orientation like this:
https://drive.google.com/file/d/10McXMr ... sp=sharing

What could be a problem?

https://drive.google.com/open?id=1xjxd- ... DsOpMP1ecd

Re: Orientation on path

Posted: 27 Aug 2019, 05:46
by coppelia
Hello,

the problem is how Euler angles work. Most of the time, you cannot simply consider one Euler angle alone.
Try instead something like:

Code: Select all

        position = sim.getPositionOnPath(path,l)
        position[3] = 0
        pathOrientation = sim.getOrientationOnPath(path,l)
        newObjectOrientation = pathOrientation

        local m=sim.buildMatrix(position,newObjectOrientation)
        m=sim.rotateAroundAxis(m,{m[2],m[6],m[10]},position,math.pi/2)
        m=sim.rotateAroundAxis(m,{m[3],m[7],m[11]},position,math.pi)
        sim.setObjectMatrix(object,-1,m)
Cheers

Re: Orientation on path

Posted: 28 Aug 2019, 08:41
by Maenre

Code: Select all

local m=sim.buildMatrix(position,newObjectOrientation)
m=sim.rotateAroundAxis(m,{m[2],m[6],m[10]},position,math.pi/2)
m=sim.rotateAroundAxis(m,{m[3],m[7],m[11]},position,math.pi)
Thank you, it works but I wonder how.
As far as I understand in 1st line we build rotation+translation matrix based on Euler angles and position.
In 2nd/3rd lines we rotate this around vectors that consist of 2nd/3rd column of this matrix. What meanings do these vectors have?

Re: Orientation on path

Posted: 28 Aug 2019, 13:11
by coppelia
In a transformation matrix, the first column corresponds to the X-axis of the transformation frame. The second column is the Y- and the third column is the Z-axis.

So basically, we rotate the frame around its own axes.

Cheers