source: trunk/MagicSoft/slalib/pxy.c@ 7560

Last change on this file since 7560 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaPxy ( int np, double xye[][2], double xym[][2],
4 double coeffs[6], double xyp[][2],
5 double *xrms, double *yrms, double *rrms )
6/*
7** - - - - - - -
8** s l a P x y
9** - - - - - - -
10**
11** Given arrays of "expected" and "measured" [x,y] coordinates, and a
12** linear model relating them (as produced by slaFitxy), compute
13** the array of "predicted" coordinates and the rms residuals.
14**
15** Given:
16** np int number of samples
17** xye double[np] expected [x,y] for each sample
18** xym double[np] measured [x,y] for each sample
19** coeffs double[6] coefficients of model (see below)
20**
21** Returned:
22** xyp double[np] predicted [x,y] for each sample
23** *xrms double RMS in x
24** *yrms double RMS in y
25** *rrms double total RMS (vector sum of xrms and yrms)
26**
27** The model is supplied in the array coeffs. Naming the
28** elements of coeff as follows:
29**
30** coeffs[0] = a
31** coeffs[1] = b
32** coeffs[2] = c
33** coeffs[3] = d
34** coeffs[4] = e
35** coeffs[5] = f
36**
37** The model is applied thus:
38**
39** xp = a + b*xm + c*ym
40** yp = d + e*xm + f*ym
41**
42** The residuals are (xp-xe) and (yp-ye).
43**
44** If np is less than or equal to zero, no coordinates are
45** transformed, and the rms residuals are all zero.
46**
47** See also slaFitxy, slaInvf, slaXy2xy, slaDcmpf
48**
49** Called: slaXy2xy
50**
51** Last revision: 31 October 1993
52**
53** Copyright P.T.Wallace. All rights reserved.
54*/
55{
56 int i;
57 double sdx2, sdy2, xp, yp, dx, dy, dx2, dy2, p;
58
59/* Initialize summations */
60 sdx2 = 0.0;
61 sdy2 = 0.0;
62
63/* Loop by sample */
64 for ( i = 0; i < np; i++ ) {
65
66 /* Transform "measured" [x,y] to "predicted" [x,y] */
67 slaXy2xy ( xym[i][0], xym[i][1], coeffs, &xp, &yp );
68 xyp[i][0] = xp;
69 xyp[i][1] = yp;
70
71 /* Compute residuals in x and y, and update summations */
72 dx = xye[i][0] - xp;
73 dy = xye[i][1] - yp;
74 dx2 = dx * dx;
75 dy2 = dy * dy;
76 sdx2 = sdx2 + dx2;
77 sdy2 = sdy2 + dy2;
78
79 /* Next sample */
80 }
81
82/* Compute RMS values */
83 p = (double) gmax ( 1.0, np );
84 *xrms = sqrt ( sdx2 / p );
85 *yrms = sqrt ( sdy2 / p );
86 *rrms = sqrt ( *xrms * *xrms + *yrms * *yrms );
87}
Note: See TracBrowser for help on using the repository browser.