为什么bezierPoints不返回无单点?

时间:2023-01-31 19:58:14

I need to get the x- and y-coordinates of points along a Bezier curve in R. I thought this would work:

我需要在R中沿Bezier曲线得到点的x坐标和y坐标。我认为这样可行:

x <- c(0, 0, 1, 1)
y <- c(0, 1, 1, 0)
bg <- bezierGrob(x, y)
trace <- bezierPoints(bg)

But after running that trace$x and trace$y are a bunch of measurements in inches well outside the range of (0,1). The man page for bezierPoints says:

但在运行该跟踪后,$ x和跟踪$ y是一系列测量,以英寸远远超出(0,1)的范围。 bezierPoints的手册页说:

Rather than drawing an Xspline (or Bezier curve), this function returns the points that would be used to draw the series of line segments for the Xspline.

此函数不是绘制Xspline(或Bezier曲线),而是返回用于绘制Xspline的一系列线段的点。

Am I running into some grid weirdness? Or am I trying to use the wrong solution to this problem?

我遇到了一些网格奇怪吗?或者我是否尝试使用错误的解决方案来解决这个问题?

1 个解决方案

#1


1  

Looks like the bezier package, not grid, is the way to go. This works:

看起来像bezier包,而不是网格,是要走的路。这有效:

t <- seq(0, 1, length=100)
p <- matrix(c(0,0, 0,1, 1,1, 1,0), nrow=4, ncol=2, byrow=TRUE)
bp <- bezier(t=t, p=p)

#1


1  

Looks like the bezier package, not grid, is the way to go. This works:

看起来像bezier包,而不是网格,是要走的路。这有效:

t <- seq(0, 1, length=100)
p <- matrix(c(0,0, 0,1, 1,1, 1,0), nrow=4, ncol=2, byrow=TRUE)
bp <- bezier(t=t, p=p)