How to avoid rounding off errors in parametrization?

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.

 채택된 답변

Roger Stafford
Roger Stafford 2014년 7월 28일
편집: Roger Stafford 2014년 7월 28일
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

António
António 2014년 7월 28일
편집: António 2014년 7월 28일
Thank you for the reply.
Actually, the algorithm that I was following begins by eliminating the xy component. However, this seems like a valid approach. Thank you for the help
Yes, eliminating the D and E terms can be done either way.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2014년 7월 27일

댓글:

2014년 7월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by