aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/polyphot/apycenter.x
blob: faa2d884ffbc05b7853aa7a0b60d8f06f0f50b20 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
include "../lib/center.h"
include "../lib/polyphot.h"

# AP_YCENTER -- Center the polygon using the centering package routines.

int procedure ap_ycenter (py, im, wx, wy, x, y, nver)

pointer	py		# pointer to polyphot structure
pointer	im		# pointer to the IRAF image
real	wx		# initial x center
real	wy		# initial y center
real	x[ARB]		# x coordinates of the polygon
real	y[ARB]		# y coordinates of the polygon
int	nver		# number of vertices

int	cier
int	apfitcenter()
real	apstatr()

begin
	if (IS_INDEFR(apstatr (py, PYCX)) || IS_INDEFR(apstatr (py, PYCY)))
	    cier = apfitcenter (py, im, INDEFR, INDEFR)
	else
	    cier = apfitcenter (py, im, wx, wy)

	if (! IS_INDEFR (apstatr (py, XCENTER)) && ! IS_INDEFR (apstatr (py,
	    YCENTER)) && ! IS_INDEFR (apstatr (py, PYCX)) &&
	    ! IS_INDEFR (apstatr (py, PYCY)))
	    call ap_yshift (py, im, x, y, nver, apstatr (py, XCENTER),
	        apstatr (py, YCENTER))

	return (cier)
end


# AP_YRECENTER -- Recenter the polygon using the existing buffer of pixels
# and the centering package routines.

int procedure ap_yrecenter (py, im, x, y, nver, cier)

pointer	py		# pointer to polyphot structure
pointer	im		# the input image descriptor
real	x[ARB]		# x coordinates of the polygon
real	y[ARB]		# y coordinates of the polygon
int	nver		# number of vertices
int	cier		# original centering error

int	aprefitcenter()
real	apstatr()

begin
	cier = aprefitcenter (py, im, cier)
	if (! IS_INDEFR (apstatr (py, XCENTER)) && ! IS_INDEFR (apstatr (py,
	    YCENTER)) && ! IS_INDEFR (apstatr (py, PYCX)) && !
	    IS_INDEFR (apstatr (py, PYCY)))
	    call ap_yshift (py, im, x, y, nver, apstatr (py, XCENTER),
	        apstatr (py, YCENTER))
	return (cier)
end