# Arrow Marker Orientation

Hey everyone,

I'm trying to publish an Arrow marker in the cluster center of extracted clusters. My goal is to set the orientation to the moving direction of the tracked cluster.

For this I'm able to utilize the X-Velocity and Y-Velocity (I also have access to the X and Y Position of the Point Origin)

Suppose for example the X-Velocity is 1 and the Y-Velocity is 0.5.

How do I set the POSE.ORIENTATION of the Arrow to point in a Direction that's parallel to the hypotenuse of this triangle (I do not want to change the length of the Arrow, just the direction)

Additionally I want it to point in the exact opposite direction if the velocity is negative (If the object is moving backwards, the arrow should point there too)

edit retag close merge delete

Sort by ยป oldest newest most voted

It would be much easier for you to use the start/end point method of specifying an arrow marker than the position orientation method.

You can normalize the velocity vector (divide each element by it's length) and add it to the current position to produce the end point. This way the arrow will always have a length of 1. You'll have to be careful and catch the case where it's velocity is zero since the end point will be a NAN. This arrow will always point in the velocity direction weather it's positive or negative.

Hope this helps.

more

1

Wow ! That was my first approach but I didn't think about normalizing the vectors! Duh. Of course!

Thanks again. Much appreciated

( 2018-08-16 06:35:04 -0500 )edit

Essentially works, however, by dividing the x-vel by itself I get a adjacent side length by 1. Then, by dividing the y-vel by the x-vel I get the correct ratio and the arrow points in the right direction. however the hypotenuse won't have length 1 then! Do you have any elegant solution for this ?

( 2018-08-17 04:39:03 -0500 )edit

I could calculate the euclidean distance between starting- and endpoint. this would be the length of the hypotenuse. However I can't simply divide this length by itself, because I'm not specifying the length, but the starting and endpoint, so this solution will get less and less elegant

( 2018-08-17 04:41:51 -0500 )edit
1

Calculate and store the magnitude of the velocity vector using sqrt(x'^2 + y'^2 + z'^2) Then divide each element of the vector sequentially by this stored magnitude. your velocity vector now has length 1. Use this velocity vector to find the arrows end point.

( 2018-08-17 06:53:57 -0500 )edit

perfect, thats the elegant solution I was missing :) ! thanks a ton

( 2018-08-17 09:02:20 -0500 )edit