Skip to content
Back to formatted view

Raw Message

Message-ID: <CAAmySGPbsdESmcamwzFk8_1ocui23-J=u7150jLP3X+FBdjEDQ@mail.gmail.com>
Date: 2011-11-10T01:55:38Z
From: R. Michael Weylandt
Subject: determine length of bivariate polynomial
In-Reply-To: <CAKbO-iyQwxekqB=GNsBsmMyschV24mzDxd=cXRMUyoiUBNh=7Q@mail.gmail.com>

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.
>