Markus Loecher <[EMAIL PROTECTED]> 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

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to