Orientation on path

Typically: "How do I... ", "How can I... " questions
Post Reply
Maenre
Posts: 8
Joined: 29 Jul 2019, 11:10

Orientation on path

Post 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

coppelia
Site Admin
Posts: 10504
Joined: 14 Dec 2012, 00:25

Re: Orientation on path

Post 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

Maenre
Posts: 8
Joined: 29 Jul 2019, 11:10

Re: Orientation on path

Post 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?

coppelia
Site Admin
Posts: 10504
Joined: 14 Dec 2012, 00:25

Re: Orientation on path

Post 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

Post Reply