I need to get the correct angle of rotation of the ellipses. These ellipses are examples. I have a canonical coefficients of the equation of the five points.
$$Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0$$
Ellipses:
Points:
Zero ellipse: [16,46] [44,19] [50,35] [31,61] [17,54]
First ellipse: [14,95] [47,71] [55,83] [23,107] [16,103]
Second ellipse: [12,128] [36,117] [58,128] [35,146] [13,136]
Third ellipse: [16,164] [29,157] [54,188] [40,195] [17,172]
Fourth ellipse: [22,236] [31,207] [50,240] [40,252] [26,244]
Coefficients:
Zero ellipse First ellipse Second ellipse Third ellipse Fourth ellipse
A: 0.00039679682899033947 A: 0.00007365946131786486 A: 0.000021675708916102692 A: 0.00004189611868790682 A: 0.00004418821462144713
B: 0.00021821614636627075 B: 0.00006770936206052314 B: -0.000002834437159146921 B: -0.00004283926773569747 B: -0.000012890924982902275
C: 0.00024184103978866782 C: 0.00009244517004290531 C: 0.000057745675577137415 C: 0.00003944519997403195 C: 0.000020104667194164587
D: -0.03490717401354479 D: -0.01110309000831378 D: -0.0011544916677563865 D: 0.0046141642800698515 D: -0.00016090203479326006
E: -0.026421911476591453 E: -0.01877226426820658 E: -0.015086084806642279 E: -0.012396706675782408 E: -0.008774013189179199
F: 1.0 F: 1.0 F: 1.0 F: 1.0 F: 1.0
I successfully find the coordinates of the center and the length of the axes. But I get the wrong rotation.
I get the angle using the equation: $$\theta = \frac{1}{2} \arctan \left( \frac{B}{A-C} \right) $$
Angles result:
Zero ellipse: 0.4766612094205555
First ellipse: -0.6500786401646479
Second ellipse: 0.03921024408607312
Third ellipse: -0.7568233305427435
Fourth ellipse: -0.24572750447422026
Visualization of the result:
How do I calculate the correct angle? And how to convert the value to degrees without errors?
UPDATED:
I wrote the algorithm here. The first set points angle is not correct. In the second set of points, the correct angle. You can put your own values and see the result.
UPDATED: SOLVED!
Based on the response of @Ng Chung Tak, I managed to get into the code and implement the right formula!
Implementation of the code here.
Formula:
$$\theta = \tan^{-1} \left( \frac{C-A}{B}+\frac{\sqrt{(A-C)^{2}+B^{2}}}{B} \: \right) $$
Result:
Thanks to all!
Do you have any idea how to write an equation?
– Qulery Jun 25 '16 at 19:36