[R] determine length of bivariate polynomial

R. Michael Weylandt michael.weylandt at gmail.com
Thu Nov 10 02:55:38 CET 2011


I think this will do it:

sum(sqrt(diff(x.pred)^2 + diff(y.pred)^2))

Michael

On Tue, Nov 8, 2011 at 11:34 AM, Nicolas Schuck
<nico.schuck at googlemail.com> wrote:
> Dear R-community,
>
> I have a fitted bivariate polynomial, i.e:
>
> fit = lm(cbind(x, y)~poly(t, 15))
>
> and I would like to determine the length of the line in the interval t =
> [a, b]. Obviously, I could use predict and go through all the points, i.e.
>
> for (t in a:(b-1)) {
> length = length + sqrt((x.pred[t] - x.pred[t+1])^2 + (y.pred[t] -
> y.pred[t+1])^2)
> }
>
> but that would take very long given the amount of data I have. Do you know
> of any better solutions?
>
> Many thanks!
> Nicolas
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list