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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <plset.h>
include <plio.h>
include "plcircle.h"
# PL_UCIRCLE -- Regionrop ufcn for a circle (circular region), clipped at
# the borders of the mask.
bool procedure pl_ucircle (ufd, y, rl_reg, xs, npix)
pointer ufd #I user function descriptor
int y #I mask line number
int rl_reg[3,ARB] #O output range list for line Y
int xs #O first pixel to be edited
int npix #O number of pixels affected
pointer pl
real radius, dx, dy
int rn, axlen, x1, x1_clipped, x2, x2_clipped
begin
pl = C_PL(ufd)
rn = RL_FIRST
axlen = PL_AXLEN(pl,1)
radius = C_RADIUS(ufd)
dy = abs (C_YCEN(ufd) - y)
if (dy <= radius) {
dx = sqrt (radius**2 - dy**2)
x1 = C_XCEN(ufd) - int(dx)
x2 = C_XCEN(ufd) + int(dx)
x1_clipped = max(1, min(axlen, x1))
x2_clipped = max(1, min(axlen, x2))
xs = x1_clipped
npix = x2_clipped - x1_clipped + 1
RL_X(rl_reg,rn) = 1
RL_N(rl_reg,rn) = npix
RL_V(rl_reg,rn) = C_PV(ufd)
rn = rn + 1
} else {
npix = 0
xs = 1
}
RL_LEN(rl_reg) = rn - 1
RL_AXLEN(rl_reg) = npix
return (true)
end
|