I'm using X=rpoisline(4)
to generate lines and plot them with plot(X)
.
With X$ends
I have their coordinates and their intersection points with selfcrossing.psp(X)
(In R with spatstat : library(spatstat)
).
I need to get a list of segments and their coordinates and be able to manipulate them (change their orientation, position, intersection...). Those segments have to be defined by the intersection of a line with an other line and with the window.
So, am I missing a simple way to convert a psp of few intersecting lines in a psp of non intersecting segments (I hope it's clear) ?
If you have a non-simple way, I'm interested to !
Thanks for your time !
edit :
Here are the lines I have :
And here are the kind of random stuff I think I can produce if I manage to handle each segments (one by one). So I need to get a list of segments from my list of random lines.
The
spatstat
functionselfcut.psp
is designed for exactly this purpose.For further information about manipulating line segment patterns, see section 4.4 in the spatstat book.
Ok, several coffeebreaks later, here's some buggy code that does what you want. The cleanup I'll leave to you.