Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab angle between two points [duplicate]

I am looking for an algorithm to calculate the angle between two points (defined by x and y valaue) in an image. The angle should be between the horizontal-line of one of these points and the line that connects the two points.

How can I do that?

like image 449
farahm Avatar asked Apr 08 '14 18:04

farahm


People also ask

How do you find the angle between two points in Matlab?

angle = atan2d(x1*y2-y1*2,x1*x2+y1*y2);

How do you find the angle between two vector points?

Formula for angle between two Vectors The cosine of the angle between two vectors is equal to the sum of the product of the individual constituents of the two vectors, divided by the product of the magnitude of the two vectors. =| A | | B | cosθ.


1 Answers

For points (x1,y1) and (x2,y2) use this:

atan2(y2-y1,x2-x1)

This will return the angle between a horizontal vector from (x1,y1) to (x1+1,y1) and the vector from (x1,y1) to (x2,y2).

like image 189
Jorn Avatar answered Nov 03 '22 00:11

Jorn