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.

 Respuesta aceptada

Roger Stafford
Roger Stafford el 28 de Jul. de 2014
Editada: Roger Stafford el 28 de Jul. de 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 comentarios

António
António el 28 de Jul. de 2014
Editada: António el 28 de Jul. de 2014
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Jul. de 2014

Comentada:

el 28 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by