source: trunk/MagicSoft/slalib/invf.c@ 6308

Last change on this file since 6308 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaInvf ( double fwds[6], double bkwds[6], int *j )
4/*
5** - - - - - - - -
6** s l a I n v f
7** - - - - - - - -
8**
9** Invert a linear model of the type produced by the slaFitxy routine.
10**
11** Given:
12** fwds double[6] model coefficients
13**
14** Returned:
15** bkwds double[6] inverse model
16** *j int status: 0 = OK, -1 = no inverse
17**
18** The models relate two sets of [x,y] coordinates as follows.
19** Naming the elements of fwds:
20**
21** fwds[0] = a
22** fwds[1] = b
23** fwds[2] = c
24** fwds[3] = d
25** fwds[4] = e
26** fwds[5] = f
27**
28** Where two sets of coordinates [x1,y1] and [x2,y1] are related
29** thus:
30**
31** x2 = a + b*x1 + c*y1
32** y2 = d + e*x1 + f*y1
33**
34** The present routine generates a new set of coefficients:
35**
36** bkwds[0] = p
37** bkwds[1] = q
38** bkwds[2] = r
39** bkwds[3] = s
40** bkwds[4] = t
41** bkwds[5] = u
42**
43** Such that:
44**
45** x1 = p + q*x2 + r*y2
46** y1 = s + t*x2 + u*y2
47**
48** Two successive calls to slaInvf will thus deliver a set
49** of coefficients equal to the starting values.
50**
51** See also slaFitxy, slaPxy, slaXy2xy, slaDcmpf
52**
53** Last revision: 30 October 1993
54**
55** Copyright P.T.Wallace. All rights reserved.
56*/
57{
58 double a, b, c, d, e, f, det;
59
60 a = fwds[0];
61 b = fwds[1];
62 c = fwds[2];
63 d = fwds[3];
64 e = fwds[4];
65 f = fwds[5];
66 det = b * f - c * e;
67
68 if ( det != 0.0 ) {
69 bkwds[0] = ( c * d - a * f ) / det;
70 bkwds[1] = f / det;
71 bkwds[2] = - c / det;
72 bkwds[3] = ( a * e - b * d ) / det;
73 bkwds[4] = - e / det;
74 bkwds[5] = b / det;
75 *j = 0;
76 } else {
77 *j = -1;
78 }
79}
Note: See TracBrowser for help on using the repository browser.