aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/polyphot/apyshift.x
blob: 4fd56cbe220f7d5ffb31a3e9d7d1c71903a8dde3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
include "../lib/apphot.h"
include "../lib/polyphot.h"

# AP_YSHIFT -- Shift a polygon to a new center position.

procedure ap_yshift (py, im, x, y, nver, newx, newy)

pointer	py		# pointer to the polyphot structure
pointer	im		# the input image descriptor
real	x[ARB]		# x coordinates of the vertices
real	y[ARB]		# y coordinates of the vertices
int	nver		# number of vertices
real	newx, newy	# new x and y coordinates of center

real	xshift, yshift
real	apstatr()
int	apstati()

begin
	call apsetr (py, PYX, apstatr (py, PYCX))
	call apsetr (py, PYY, apstatr (py, PYCY))

	xshift = newx - apstatr (py, PYCX)
	yshift = newy - apstatr (py, PYCY)
	call aaddkr (x, xshift, x, nver)
	call aaddkr (y, yshift, y, nver)
	call apsetr (py, PYCX, newx)
	call apsetr (py, PYCY, newy)

        switch (apstati(py,WCSOUT)) {
        case WCS_WORLD, WCS_PHYSICAL:
            call ap_ltoo (py, newx, newy, xshift, yshift, 1)
        case WCS_TV:
            call ap_ltov (im, newx, newy, xshift, yshift, 1)
        default:
	    xshift = newx
	    yshift = newy
        }
        call apsetr (py, OPYCX, xshift)
        call apsetr (py, OPYCY, yshift)
end