IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 28, 2005, 5:17:26 AM (21 years ago)
Author:
eugene
Message:

minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/mana/fitcontour.c

    r3030 r3105  
    3636    r = hypot (x, y);
    3737
    38     /*
    39     t = 2*atan2(y,x);
    40     sn = sin(t);
    41     cs = cos(t);
    42     */
     38    /* calculate sin(2t), cos(2t) using 1/2 angle tri relationship above */
    4339    sn1 = y / r;
    4440    cs1 = x / r;
     
    6359  gaussj (C, NTERM, B, 1);
    6460 
     61  /** this is somewhat weak: if the object is too elongated, Rmin can be < 0 **/
    6562  dR = hypot (B[1][0], B[2][0]);
    6663  Rmaj = B[0][0] + dR;
     
    10198}
    10299
     100
     101/* this routine fits a single sine and cosine to the value of dr as a function of the angle around the central
     102 * point, theta.  this is NOT an exact fit, an is increasingly in error for more eccentric ellipses.  however,
     103 * it does a reasonable job of approximating the value of the major and minor axes, and it gets the angle of
     104 * orientation right at well.  We then assume the values of major and minor axis and angle are correct to get
     105 * the parameters for the elliptical gaussian fit:
     106 
     107 z = (x^2) / (2 Rx^2) + (y^2) / (2 Ry^2) + Rxy x y
     108
     109 the functions above give the correct relationship between these:
     110
     111   R1 = SQ(Rmaj) + SQ(Rmin);
     112   R2 = SQ(Rmaj) - SQ(Rmin);
     113   R3 = Rmaj*Rmin;
     114
     115   Rx = R3 / sqrt (R1 - R2*cs);
     116   Ry = R3 / sqrt (R1 + R2*cs);
     117   Rxy = -sn*R2 / SQ(R3);
     118
     119 to derive these relationships, write the equation for an ellipse with major axis in the x-dir and minor in
     120 the y-dir:
     121
     122 z = (x^2) / (2 Rmaj^2) + (y^2) / (2 Rmin^2)
     123
     124 apply the rotation matrix:
     125
     126 (x)' = (cos, -sin)(x,y)
     127 (y)' = (sin, +cos)(x,y)  (modulo the sign on the sine)
     128
     129 then group the x^2 terms, the y^2 terms, and the xy terms to find the three coeffs.
     130
     131 NOTE: I spent a while having trouble deriving this from the polar form of an ellipse:
     132
     133 x = Rmaj*cos(theta)
     134 y = Rmin*sin(theta)
     135
     136 it turns out that 'theta' above is NOT the angle (0,1)-(0,0)-(x,y). rather, it should be viewed as a
     137 paraterization of the ellipse. 
     138
     139*/
Note: See TracChangeset for help on using the changeset viewer.