Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
angle between two vectors

Subject: angle between two vectors

From: brian adams

Date: 6 Aug, 2010 18:49:04

Message: 1 of 4

In 2-space, I have a three points:
c, the ctr
p, an arbitrary point, and
 v, a point indicating a direction (as a vector from the ctr to v).

I need to determine whether the point p is in the forward direction of the vector v from the center point, c.

I have gotten this to work by means of the law of cosines to determine the angle between the the vectors, p-c and v-c. I needed to calculate the distances between the three points, apply acos, and determine if the abs of the angle is <= 90.

However, this method is computational intensive for the number of points for which I need to perform this operation.

Is there a less computationally intensive means by which to determine this?

Subject: angle between two vectors

From: us

Date: 6 Aug, 2010 18:59:05

Message: 2 of 4

"brian adams" <adamsbriand@yahoo.com> wrote in message <i3hlf0$olk$1@fred.mathworks.com>...
> In 2-space, I have a three points:
> c, the ctr
> p, an arbitrary point, and
> v, a point indicating a direction (as a vector from the ctr to v).
>
> I need to determine whether the point p is in the forward direction of the vector v from the center point, c.
>
> I have gotten this to work by means of the law of cosines to determine the angle between the the vectors, p-c and v-c. I needed to calculate the distances between the three points, apply acos, and determine if the abs of the angle is <= 90.
>
> However, this method is computational intensive for the number of points for which I need to perform this operation.
>
> Is there a less computationally intensive means by which to determine this?

show CSSM your ML code that you've come up with so far...

us

Subject: angle between two vectors

From: Roger Stafford

Date: 6 Aug, 2010 19:18:06

Message: 3 of 4

"brian adams" <adamsbriand@yahoo.com> wrote in message <i3hlf0$olk$1@fred.mathworks.com>...
> In 2-space, I have a three points:
> c, the ctr
> p, an arbitrary point, and
> v, a point indicating a direction (as a vector from the ctr to v).
>
> I need to determine whether the point p is in the forward direction of the vector v from the center point, c.
>
> I have gotten this to work by means of the law of cosines to determine the angle between the the vectors, p-c and v-c. I needed to calculate the distances between the three points, apply acos, and determine if the abs of the angle is <= 90.
>
> However, this method is computational intensive for the number of points for which I need to perform this operation.
>
> Is there a less computationally intensive means by which to determine this?
- - - - - - -
 If dot(p-c,v-c) > 0, then p is in the "forward" direction if I interpret you correctly. No need to find the angle or the lengths of the vectors.

Roger Stafford

Subject: angle between two vectors

From: brian adams

Date: 6 Aug, 2010 20:11:19

Message: 4 of 4

Roger

That worked beautifully. Thank you.


Brian

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us