Re: finding a rotation vector
- To: mathgroup at smc.vnet.net
- Subject: [mg79616] Re: finding a rotation vector
- From: Ray Koopman <koopman at sfu.ca>
- Date: Tue, 31 Jul 2007 06:10:39 -0400 (EDT)
- References: <f8kfbg$169$1@smc.vnet.net>
On Jul 30, 3:42 am, william <willpower... at hotmail.com> wrote: > Hi there, > > I have a problem in mathematica concerning 2 non geometric shapes: > > 1 the shapes are made up of collections of points in 3D space. > > 2 the shapes the not mathematically exactly the same (the points are not homologous), but they are very similar. > > 3 shape 2 is effectively shape 1 that has been translated (ie its centroid (mean of 3D coordinates) has been moved) and rotated in 3D space. > > I can find the translation vector (centroid 1-2), but cannot find the rotation vector. I was thinking along the lines of: least squares registering shape 2 to 1, and returning the rotation used in this process. I am very stuck with the process, so any help would be very much appreciated!! > > thanks in advance, > > will If a and b are n x m matrices, n > m, this will translate and rotate b into a least-squares approximation to a: ma = Mean@a; ac = #-ma& /@ a; mb = Mean@b; bc = #-mb@ /@ b; r = #[[3]].Transpose@#[[1]]& @ SingularValueDecomposition[Transpose at ac.bc]; ahat = #+ma& /@ (bc.r)