[R-sig-Geo] (no subject)
adrian at maths.uwa.edu.au
adrian at maths.uwa.edu.au
Wed May 7 04:15:01 CEST 2008
Markus Loecher <mao.loecher at gmail.com> writes:
> I am looking for a function that
> indicates whether a line segment falls inside a rectangle (i.e. crosses
> the rectangle boundaries somewhere).
In the spatstat package: Suppose W is the rectangle (or other polygon),
stored as an object of class "owin", and S is the line segment, stored as
an object of class "psp" (inside some arbitrary, larger window). Then
X <- crossing.psp(as.psp(W), S)
X$n > 0
returns TRUE if the line segment crosses any of the edges of the
rectangle. The command as.psp(W) converts the edges of the window to a
list of line segments.
> In addition I need to (ii) compute the orthogonal projection
> of a point onto a line segment.
Do you mean the orthogonal projection of a point onto an infinite line, or
the convex projection (nearest point) of a point onto a line segment?
Adrian Baddeley
More information about the R-sig-Geo
mailing list