CRect:PtInside


The PtInside method tests whether a point is interior to the CRect. The tests are made using <= or >= so that a point exactly on a CRect boundary is considered to be inside. The related PtInsideInt method tests the CRect using fuzzy integral boundaries.

Syntax

bSuccess = CRect:PtInside( x, y )

bullet.gif    wherex, y are numbers.

Example 1

The following script tests whether the point (225,300) is inside the CRect:

R = new_rect()

-- create a CRect object

R:Set(200,250,250,500)

 

x = 225 ; y = 300

 

test = R:PtInside(x,y)

-- returns test = true or false

Printf( "Inside= %d\n", test)

-- result: Inside = 1

 

Example 2

The script below tests whether an object intended for photometry is entirely inside the image when the size of the outer background aperture is considered. Assume a CApphot object A and a CImage object I already exist. This script uses the radius of the outer aperture to define a zone to be avoided around the margin of the image. The value is increased by 1 pixel to handle fractional pixels that might otherwise push the edge of the aperture outside the image.

nBorder = A.nRadius3 + 1

-- get the radius of the outer aperture, add 1 pixel

 

 

R = new_rect()

-- create a CRect object

R:SetToImage( I )

-- give the rectangle the dimension of the image

R:Inflate( -nBorder, -nBorder )

-- shrink the CRect by (aperture radius + 1)

 

 

x = 225 ; y = 300

-- get some coordinates for the object

test = R:PtInside(x,y)

-- returns test = true or false

Printf( "Inside= %d\n", test)

 

Related Topics

CRect class, PtInsideInt, RectInside, CImage:PtInside


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.