How to calculate angular rotation for a 2D line?

  • #1
53
6
For illustration purposes, I have attached an image of the line with the angle that I want to calculate. I am trying to determine the angle of rotation and the calculation that I am using currently is as below:

angle = math.atan2(y,x)

I use this formula to calculate the rotation for A and A', and then I add up the angle of a and b get the rotation. So I am really not sure if this is the correct way to do this. The idea in the end is to see if the rotation from A to A' is >70 degrees or <70 degrees. Sorry my math is pretty rusted at the moment.

P_20180904_192952 (1).jpg
 

Attachments

Answers and Replies

  • #2
138
26
Can you explain the problem more, it is not clear at all for me.
 
  • #3
53
6
line A is the position of the line at timepoint 1 while line A' is the position of the line at timepoint 2. I want to calculate the angle of rotation from the position of the line at timepoint1 to the position of the line at timepoint 2. My approach now is to calculate the angle at each timepoint then I add up these angles to get the degree of rotation. Hope this is clear.
 
  • #4
Merlin3189
Homework Helper
Gold Member
1,655
769
I'm not sure what y and x are, nor what math.atan2 is. (arctan type 2 or arctan squared maybe?)

My feeling would be that each line has a direction - relative to the arbitrary reference frame of the paper - so you can just subtract the initial direction from the final direction to get the rotation.

For eg., if a were 30 deg and b were 25 deg, if you took line ba as East-West, then the starting line dotA would have a bearing of 120 deg and the finishing line bA' would have a bearing of 65 deg giving a rotation of -55 deg.

Your main problems are; finding the angles a and b, and knowing whether a number of complete rotations have occured.
 
  • #5
53
6
thank you very much Merlin, this was what I was looking for. sorry if the explanation wasn't very clear.
 
  • #6
Merlin3189
Homework Helper
Gold Member
1,655
769
Looking at it now, I realise the bearings could be different, depending on how you label the lines:
Line A is either 120 deg (pointing right) or 300 deg (pointing left)
similarly, line A' is either 65 deg or 245 deg
so the possible rotations are 120 - 65 = 55, 120 - 245 = -125, 300 - 65 =235, or 300 - 245 = 55 degrees.

I think you need to label the ends, eg. A is PQ and A' is P'Q' then you'd be able to see if the line had turned more than 180 deg.

I wonder how you know the angles a and b ?
 
  • #7
34,688
6,394
nor what math.atan2 is. (arctan type 2 or arctan squared maybe?)
atan2 has nothing to do with squaring. atan and atan2 are functions common to many programming languages such as C, C++, C#, python, matlab, and others. Both functions return an angle in radians. atan() takes a single argument, and atan2() takes two arguments.

For example, atan(1.0) returns the numeric equivalent of ##\pi/4##, and atan2(2.0, 1.0) returns about 1.107, which is about 63.4°.
 

Related Threads on How to calculate angular rotation for a 2D line?

Replies
9
Views
12K
Replies
7
Views
4K
Replies
2
Views
575
Replies
3
Views
2K
Replies
1
Views
2K
Replies
2
Views
7K
  • Last Post
Replies
3
Views
3K
Replies
8
Views
770
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
1
Views
3K
Top