Group point if vector is oriented like a reference vector?

   2080   2   0
User Avatar
Member
1008 posts
Joined: April 2017
Offline
Hi!

I have 2 vectors at each points on a line. A reference vector and another one pointing in another direction called magnitude. I need a way to compare both vectors and group only if the magnitude vector is pointing in a similar direction as the reference vector. Any magnitude pointing at 90 degrees or more away from the reference vector should not be grouped.

Any advice on how to do this in VEX?

Thanks!

Attachments:
group_by_vector_direction.jpg (74.6 KB)

User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
In the hip file the code to do this is in the wrangle.

There is only one line needed to figure out what the angle is between the two vectors,

but I included some extra stuff so you can play around with it to understand it better if needed.

One thing to note; The formula to figure out the angle between the two vectors only goes up to 180 degrees,

before it ‘climbs’ back down to zero. One would need some extra coding if say you need to determine ranges from 180 to 360 that differentiate those of 0 to 180.

But as your saying you only need to determine 90 degree limit, this should work as is.

Here's an example web reference where this was constructed from.

http://www.softschools.com/math/pre_calculus/angle_between_two_vectors/ [www.softschools.com]


Edit: So that in order to use what I have in the hip to apply, just swap out the Reference_Position with the base position of your reference vector, and one of the point numbers with the endpoint of your reference vector. After which you can run however you want the conditional of the result to include or not in your group.
Edited by BabaJ - Oct. 1, 2018 12:50:01

Attachments:
Angle Between Two Vectors v1.hiplc (70.8 KB)

User Avatar
Member
1008 posts
Joined: April 2017
Offline
ah! The dot product.

I completely forgot about that on! thanks a lot for the detailed info!

-Olivier
  • Quick Links