Re: [R] off-topic: affine transformation matrix

From: Dylan Beaudette <dylan.beaudette_at_gmail.com>
Date: Tue, 29 May 2007 12:56:57 -0700

Thanks for the prompt and clear reply! The simplicity of the solution may have been why I initially overlooked this approach...

The results look convincing (http://169.237.35.250/~dylan/temp/affine.png), now I just need to verify that the output from coef() is in the format that I need it in.

l <- lm(cbind(nx,ny) ~ x + y, data=g)
coef(l)

```                     nx           ny
(Intercept)  6.87938629  5.515261158
x            1.01158806 -0.005449152
y           -0.04481893  0.996895878

```

## convert to format needed for affine() function in postGIS? t(coef(l))

(Intercept) x y
nx 6.879386 1.011588063 -0.04481893
ny 5.515261 -0.005449152 0.99689588

note that the format that I am looking for looks something like the matrix defined on this page:
http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node15.html

cheers,

dylan

On Monday 28 May 2007 15:18, Prof Brian Ripley wrote:
> Isn't this just a regression (hopefully with a near-zero error).
>
> coef(lm(cbind(xnew, ynew) ~ xold + yold))
>
> should do what I think you are asking for. (I am not clear which
> direction you want the transformation, so choose 'old' and 'new'
> accordingly.)
>
> On Mon, 28 May 2007, Dylan Beaudette wrote:
> > This may sound like a very naive question, but...
> >
> > give two lists of coordinate pairs (x,y - Cartesian space) is there any
> > simple way to compute the affine transformation matrix in R.
> >
> > I have a set of data which is offset from where i know it should be. I
> > have coordinates of the current data, and matching coordinates of where
> > the data should be. I need to compute the composition of the affine
> > transformation matrix, so that I can apply an affine transform the entire
> > dataset.
> >
> > any ideas?
> >
> > thanks in advance!

```--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

______________________________________________
R-help_at_stat.math.ethz.ch 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.
```
Received on Tue 29 May 2007 - 20:12:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 May 2007 - 21:32:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.