我有一个线段图案,它与另一条线成 90 度角:
require(spatstat)
range <- c(0,10)
owin <- owin(xrange = range, yrange = range)
l1 <- psp(x0 = 8, x1 = 8, y0 = 2, y1 = 8, window = owin, marks = "l1")
l2 <- psp(x0 = 6, x1 = 6, y0 = 2, y1 = 8, window = owin, marks = "l2")
l3 <- psp(x0 = 4, x1 = 4, y0 = 2, y1 = 8, window = owin, marks = "l3")
l4 <- psp(x0 = 2, x1 = 2, y0 = 2, y1 = 8, window = owin, marks = "l4")
lines <- superimpose(l1, l2, l3, l4)
main <- psp(x0 = 8, x1 = 0, y0 = 5, y1 = 5, window = owin, marks = "main")
angles.psp(lines)*(180/pi)
[1] 90 90 90 90
这是一个视觉表示:
plot(x = range, y = range, type = "n", main = "", asp = 1, axes = F, xlab = "x", ylab = "y")
plot(lines, col = "darkgrey", add = T)
plot(main, col = "black", add = T)
axis(1)
axis(2, las = 2)
现在我想旋转lines
,使它们main
在同一点交叉,但角度为 45 度。
lines.rotated <- rotate(lines, -0.7853982)
angles.psp(lines.rotated)*(180/pi)
[1] 45 45 45 45
这可行,但angles.psp
函数似乎owin
根据我的需要单独旋转窗口()而不是行。
plot(x = range, y = range, type = "n", main = "", asp = 1, axes = F, xlab = "x", ylab = "y")
plot(lines, col = "darkgrey", add = T)
plot(lines.rotated, col = "blue", add = T)
plot(main, col = "black", add = T)
axis(1)
axis(2, las = 2)
有没有办法lines
相对于main
线旋转所有角度,使角度为 45 度,但交叉点保持不变?