I have a problem that I want to solve in R with the examples below. I know this must have been resolved many times, but I could not find a solution that works for me in R.
The core of what I want to do is find how to translate a set of 2D coordinates to best fit into another, larger set of two-dimensional coordinates. Imagine, for example, that you have a Polaroid photo of a small part of the starry sky at night, and you want to keep it in such a position that they correspond to the current positions of the stars.
Here's how to generate data similar to my real problem:
set.seed(99)
ref_coords = data.frame(x = runif(50,0,100), y = runif(50,0,100))
my_coords_final = ref_coords[c(5,12,15,24,31,34,48,49),]
set.seed(100)
my_coords_final$x = my_coords_final$x+rnorm(8,0,.1)
set.seed(101)
my_coords_final$y = my_coords_final$y+rnorm(8,0,.1)
my_coords_start =apply(my_coords_final,2,function(x) x-min(x))
plot(ref_coords, cex = 1.2)
points(my_coords_start,pch=20, col = "red")
points(my_coords_final,pch=20, col = "blue")
segments(my_coords_start[1,1],my_coords_start[1,2],
my_coords_final[1,1],my_coords_final[1,2],lty="dotted")
Data construction, as indicated above, should yield:

, , , .. , , .
.
1000 ( , )
10-20 , , .
, !
: , . , , , . .
, my_coords_final, , my_coords_start, ref_coords.
