Skip to content

Commit

Permalink
Tweak is.subset.owin
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Dec 16, 2023
1 parent 1d4871f commit e6d56e4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.geom
Version: 3.2-7.001
Date: 2023-12-08
Version: 3.2-7.002
Date: 2023-12-16
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre", "cph"),
Expand Down
11 changes: 9 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
CHANGES IN spatstat.geom VERSION 3.2-7.001
CHANGES IN spatstat.geom VERSION 3.2-7.002

OVERVIEW

o Internal improvements.
o Minor improvements.

SIGNIFICANT USER-VISIBLE CHANGES

o is.subset.owin
Algorithm slightly modified to give better results when
the two polygons share some common edges.


CHANGES IN spatstat.geom VERSION 3.2-7

Expand Down
24 changes: 12 additions & 12 deletions R/is.subset.owin.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# is.subset.owin.R
#
# $Revision: 1.16 $ $Date: 2019/03/01 06:02:27 $
# $Revision: 1.17 $ $Date: 2023/12/16 05:02:18 $
#
# Determine whether a window is a subset of another window
#
Expand Down Expand Up @@ -52,17 +52,17 @@ is.subset.owin <- local({
return(FALSE)
## all vertices of A are inside B.
if(is.convex(B)) return(TRUE)
## check for boundary crossings
bx <- crossing.psp(edges(A), edges(B))
if(npoints(bx) > 0) return(FALSE)
## Absence of boundary crossings is sufficient if B has no holes
if(length(B$bdry) == 1 || !any(sapply(B$bdry, is.hole.xypolygon)))
return(TRUE)
## Compare area of intersection with area of putative subset
## (these are subject to numerical rounding error)
areaA <- area(A)
if(overlap.owin(A,B) >= areaA ||
overlap.owin(B,A) >= areaA) return(TRUE)
## check whether the boundaries are disjoint
if(!anycrossing.psp(edges(A), edges(B))) {
## Disjoint boundary crossings sufficient if B has no holes
if(length(B$bdry) == 1 || !any(sapply(B$bdry, is.hole.xypolygon)))
return(TRUE)
## Compare area of intersection with area of putative subset
## (use '>=' instead of '==' because of numerical rounding error)
areaA <- area(A)
if(overlap.owin(A,B) >= areaA ||
overlap.owin(B,A) >= areaA) return(TRUE)
}
## continue...
}

Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2023-09-05" "3.2-5" 450 1203 0 35948 15822
"2023-10-19" "3.2-6" 451 1203 0 35983 15822
"2023-10-20" "3.2-7" 451 1203 0 35983 15822
"2023-12-08" "3.2-7.001" 452 1203 0 36031 15822
"2023-12-16" "3.2-7.002" 452 1203 0 36031 15822

0 comments on commit e6d56e4

Please sign in to comment.