How to avoid rounding off errors in parametrization?
1 view (last 30 days)
Show older comments
António
on 27 Jul 2014
Commented: Roger Stafford
on 28 Jul 2014
Hello everyone. I am parametrizing the function of a conic: Ax^2 + By^2 + Cxy + Dx + Ey + F = 0
The goal is to get the equation to the form: x^2/a^2 + y^2/b^2 = 1
One of the steps of the parametrization corresponds to rotating and scaling about the origin, i.e., eliminate the component of xy.
This is not working very well due to roundoff errors. Being C ~= 0, here is what I have to do:
x->qx+y; y->qy-x
where
q = sqrt(((B-A)/C)^2+1) + (B-A)/C;
When I do this replacement, the xy component doesn't really disappear, it actually becomes something like
1E-5*x*y
This corrupts all of the following algorithm of the parametrization. Any ideas of how to avoid this probelm?
Thank You.
0 Comments
Accepted Answer
Roger Stafford
on 28 Jul 2014
Edited: Roger Stafford
on 28 Jul 2014
First you need to get to translate to get rid of the D*x and E*y terms which I assume you have already done, which brings you to the form
A*x1^2 + B*y1^2 + C*x1*y1 + F1 = 0
Then instead of rotating with x->qx+y; y->qy-x, do this:
x1 = x2*cos(a)-y2*sin(a)
y1 = x2*sin(a)+y2*cos(a)
The coefficient of x2*y2 will then be
(B-A)*sin(2*a)+C*cos(2*a)
which you set to zero to eliminate the x2*y2 term. This gives
tan((2*a) = C/(A-B)
which you can solve with
a = 1/2*atan2(C,A-B)
Then you are nearly there.
2 Comments
More Answers (0)
See Also
Categories
Find more on Elementary Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!