Skip to content
Prev 11557 / 398502 Next

inout() in splancs working properly?

I have a problem with function 'inout()' in package 'splancs' on CRAN-R
Version 1.2.3 under FreeBSD4.3-STABLE.

The following script produces and draws points and a polygon-surrounded
area. Repeating the same script many times shows, that points on the
polygon-line often, but not always, are outside of the polygon-area.


    library(splancs)
    # dataset with polygon (convex hull)
    ds1 <- as.points(rnorm(10),rnorm(10))
    ds1.poly <- ds1[chull(ds1),]

    # plot area within convex hull
    plot(ds1, type="n")
    polymap(ds1.poly, border="lightblue", col="lightblue", lwd=1)

    # Next dataset in and out of first one
    ds2 <- as.points(rnorm(100),rnorm(100))

    points(ds2[inout(ds2,ds1.poly),],  col="green",  pch=20)
    points(ds2[!inout(ds2,ds1.poly),], col="orange", pch=20)

    points(ds1[inout(ds1,ds1.poly),],  col="black",  pch=20)
    points(ds1[!inout(ds1,ds1.poly),], col="red",    pch=20)


If points lay on the polygon-line, inout() tells sometimes they are
inside (black points), sometimes outside (red points) of the surrounded
(here ligthblue) area.

Same with another dataset, testing against the given polygon. Points
inside are shown in green, outside in orange color. Some of the orange
points must be green points?

Is my understanding of function inout() correct? I am looking for a
function, that gives all points inside the area, including points laying
on the polygon-line, as 'TRUE' or 'inside'.

I had a look at your source code at 'splancs/src/ipippa.f', but had not
been able to resolve my problem here. (Perhaps variable 'iwind' is not
modified correctly at all situations?)

It would be very nice, if you could give me a hint what I'm doing wrong
and how to solve my problem.

Excuse me for my weaky english. Many thanks in advance.

Rainer Hurling