I'm interested in using Solve[]
to find the centre point of rotation (as an $x,y,z$ coordinate point) and axis of rotation (as a vector) from a TransformationFunction
obtained by using the Mathematica
function FindGeometricTransform
. eg:
pts1 = {{-21.365, -1.61273, 2.41973}, {-41.0366, -4.33682, 4.78811},
{-18.1104, -20.673, 7.53}, {-19.804, 3.79904, 21.6102}};
pts2 = {{-17.9409, -3.2446, -7.46078}, {-35.9907, -7.76684, -14.7927},
{-14.3971, -22.658, -4.21113}, {-25.7926, -1.61099, 10.8609}};
FindGeometricTransform
gives the transformation:
t = FindGeometricTransform[pts2, pts1][[2]]
I posted a similar thread at Mathforum under the topic: How to calculate the 3-D centre point of rotation given the angle of rotation
and got the answer:
Then Solve will give you the fixed point, i.e. the centre of rotation:
{x, y, z} /. Solve[t[{x, y, z}] == {x, y, z}, {x, y, z}][[1]]
But when I try and use this get the following message:
During evaluation of In[928]:= RowReduce::luc: Result for RowReduce of badly conditioned matrix {{-0.438289,-0.152175,-0.114141,1.80057},{-0.196422,-0.022041,0.0708135,0.32083},{-0.12289,0.142966,0.458519,0.443714}} may contain significant numerical errors. >>
Out[928]= {-5.22037*10^14, 1.37944*10^15, -3.42994*10^14}
the output is also wrong as the answer should be close to my guesstimate of:
approxCenterOfRotation = {0.05418732005730931`,1.3533759077820666`, -0.1590650885642857`}
However, for some reason I cannot reply to the post on Math Forum to get say that this solution didn't work.
This problem can be visualised with the following (NB: I calculated the axisOfRotation
vector using a different method [i.e. not using Solve]
, but am still interested in a method using Solve
to calculate this if possible...):
axisOfRotation(*normalised*) = {0.347494, -0.904472, 0.247341}
viewVector = axisOfRotation*100
Show[
Graphics3D[{Black, PointSize[0.01], Point[approxCenterOfRotation]}],
ListPointPlot3D[{pts1, pts2, t /@ pts1},PlotStyle -> PointSize[0.01]],
Graphics3D[{Blue,Line[{{pts1[[1]], pts1[[2]]}, {pts1[[1]], pts1[[3]]}, {pts1[[1]],
pts1[[4]]}}]}],
Graphics3D[{Purple,Line[{{pts2[[1]], pts2[[2]]}, {pts2[[1]], pts2[[3]]}, {pts2[[1]],pts2[[4]]}}]}],
Graphics3D[{Brown,Line[{{(t /@ pts1)[[1]], (t /@ pts1)[[2]]}, {(t /@ pts1)[[1]], (t /@pts1)[[3]]}, {(t /@ pts1)[[1]], (t /@ pts1)[[4]]}}]}],
Graphics3D[{Orange, Thick, Dashed,Line[{(approxCenterOfRotation +(axisOfRotation*20)),(approxCenterOfRotation + (axisOfRotation*-20))}]}],
PlotRange -> All, BoxRatios -> Automatic, AspectRatio -> Automatic,
Axes -> True, ImageSize -> 700, ViewPoint -> viewVector]
Any suggestions ?
Thanks for your solution Sjoerd C. de Vries, but I'm still having problems using it for a similar case:
pts1 = {{-4.1703933347009725`,
1.4117161073762858`, -1.9926556291047952`}, {-22.189270524165632`,
6.791481789144898`, -8.802808787459966`}, {-10.82311078603393`,
-17.22865684593722`, 0.8844690943141205`}, {-9.74367022928643`,
6.269145198021164`, 16.59077697323315`}};
pts2 = {{4.170393334702319`, -1.4117161073741804`,
1.9926556291087356`}, {-10.018009366114274`,
2.942544547202209`, -11.413672837383066`}, {-3.8405873454718273`,
-19.553858138726234`, 4.578554129848027`}, {-7.427598618275446`,
5.792664273078895`, 16.607151377933118`}};
t = FindGeometricTransform[pts2, pts1][[2]]
centreOfRotation = t[{0, 0, 0}]
rotMat = {t[[1, 1, {1, 2, 3}]], t[[1, 2, {1, 2, 3}]],
t[[1, 3, {1, 2, 3}]]}
{rotVec} = NullSpace[rotMat - Transpose[rotMat]];
rotVec
viewVector = rotVec*100
Show[
Graphics3D[{Orange, PointSize[0.02], Point[centreOfRotation]}],
Graphics3D[{Green, PointSize[0.025], Point[pts1[[4]]]}],
Graphics3D[{Green, PointSize[0.025], Point[pts2[[4]]]}],
ListPointPlot3D[{pts1, pts2, t /@ pts1},
PlotStyle -> PointSize[0.01]],
Graphics3D[{Blue,
Line[{{pts1[[1]], pts1[[2]]}, {pts1[[1]], pts1[[3]]}, {pts1[[1]],
pts1[[4]]}}]}],
Graphics3D[{Purple,
Line[{{pts2[[1]], pts2[[2]]}, {pts2[[1]], pts2[[3]]}, {pts2[[1]],
pts2[[4]]}}]}],
Graphics3D[{Brown,
Line[{{(t /@ pts1)[[1]], (t /@ pts1)[[2]]}, {(t /@ pts1)[[1]], (t /@
pts1)[[3]]}, {(t /@ pts1)[[1]], (t /@ pts1)[[4]]}}]}],
Graphics3D[{Orange, Thick, Dashed,
Line[{(centreOfRotation + (rotVec*20)), (centreOfRotation +
(rotVec*-20))}]}], PlotRange -> All, BoxRatios -> Automatic,
AspectRatio -> Automatic, Axes -> True, AxesLabel -> {"X", "Y", "Z"},
ImageSize -> 700, ViewPoint -> viewVector]
The orange point is the point calculated by centreOfRotation = t[{0, 0, 0}]
, but looking at the graphic, the center point of rotation should lie closer to the two green points. Also, the axis of rotation (rotVec
) looks incorrect. Any further suggestions?