B <- edges(letterR)
if(require(spatstat.random)) {
  A <- rpoisline(5, Frame(B))
} else {
  FB <- Frame(B)
  A <- as.psp(from=runifrect(5, FB), to=runifrect(5, FB))
}
  MA <- test.selfcrossing.psp(A)
  MAB <- test.crossing.psp(A, B)
Run the code above in your browser using DataLab