- #1
DethLark
- 9
- 0
I'm trying to find the equation of a general ellipse given 3 points. Two of those points should be at each end of one axis. Using this I have the center of the ellipse, and the angle of rotation with respect to the x-axis that this axis is rotated. It's unknown whether this is the major or minor axis. The third point is given which can be anywhere on the ellipse. The only other thing to find is the other axis.
This is my attempt. Phi is the angle of rotation of the given mystery axis and abtemp is its size. X(3),Y(3) is the third point. The first equation assumes that the given axis is the major axis and the second assumes it is the minor axis. The problem is that for some of these near 400 ellipses I get negative and imaginary values for the other axes. I'm not sure what's going on here.
tb1 = (-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/sqrt(1-((X(3)*cos(phi)+Y(3)*sin(phi) Xcenter)/abtemp)^2);
ta1 = (X(3)*cos(phi)+Y(3)*sin(phi)-Xcenter)/sqrt(1-((-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/abtemp)^2);
This is my attempt. Phi is the angle of rotation of the given mystery axis and abtemp is its size. X(3),Y(3) is the third point. The first equation assumes that the given axis is the major axis and the second assumes it is the minor axis. The problem is that for some of these near 400 ellipses I get negative and imaginary values for the other axes. I'm not sure what's going on here.
tb1 = (-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/sqrt(1-((X(3)*cos(phi)+Y(3)*sin(phi) Xcenter)/abtemp)^2);
ta1 = (X(3)*cos(phi)+Y(3)*sin(phi)-Xcenter)/sqrt(1-((-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/abtemp)^2);