angle between two vectors with sign

angle between two vectors with sign

gguedia5QZFN
Participant Participant
39 Views
5 Replies
Message 1 of 6

angle between two vectors with sign

gguedia5QZFN
Participant
Participant

[ FlexSim 23.1.0 ]

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!

0 Likes
Accepted solutions (1)
40 Views
5 Replies
Replies (5)
Message 2 of 6

joerg_vogel_HsH
Mentor
Mentor
@Gilles , what if you do a projection of an moved item on a conveyor to gather your data to get angle of alignment. A conveyor is defined by start position to end position. It is not a typical location, rotation and size matrix like other objects. But an item owns this data again.
0 Likes
Message 3 of 6

gguedia5QZFN
Participant
Participant
hi Joerg,

what you explained is not the problem I am trying to solve. I am not worried about an item moving on a conveyor.

I am creating a 3d model, using a code. creating object and placing them in the right location and rotate them if necessary. As I explained, when I place a queue, as you can see on the image, I want to rotate that queue so that it has the same orientation with the divert. in some cases it works and in some it does not work. because I don't know how to get if the angle is in the clock direction or is counter clock direction.

Is there any command which can provide angle between two vectors with the angle direction?

0 Likes
Message 4 of 6

joerg_vogel_HsH
Mentor
Mentor
0 Likes
Message 5 of 6

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

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

Vec3 Vec3test = Vec3(0,0,0).projectRotation(variable,model()); //variable = object
double ang = Vec3test.z;
0 Likes
Message 6 of 6

gguedia5QZFN
Participant
Participant
perfect! this is exactly what I was looking for.

Thank you!

0 Likes