question

Gilles avatar image
0 Likes"
Gilles asked Gilles commented

angle between two vectors with sign

queue-orientation.pnghello team,

I have two vectors, the first vector is the direction of a conveyor (direction). the second vector is the orientation of a queue (orientation). I would like to rotate the queue so that its orientation is aligned with the direction of the conveyor.

to get the angle between the two vectors, I do: angle = orientation.angle(direction).

then to rotate the queue in order to align its orientation, I do : obj.setRotation(0,0,angle );

as you can see on the image above, it does not work in all scenarios. what I found is, if I do angle = direction.angle(orientation), I get the same result as angle = orientation.angle(direction). so it does not capture sign of the angle, in other words, it does not capture the information if I am in clock direction or counter clock direction.


I will appreciate a help with this.

Thanks!

FlexSim 23.1.0
rotationvec3angle
queue-orientation.png (123.7 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Gilles commented

Here is an example to get rotation values in a range of ]-180 .. 0 .. +180[

angle_project_plus_minus_180.fsm

rotate-projected-smaller.gif

  1. Vec3 Vec3test = Vec3(0,0,0).projectRotation(variable,model()); //variable = object
  2. double ang = Vec3test.z;

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.