I have a function s[x,y,z] that assumes a reference of centered at the origin and pointed along the positive z axis. Given two points, I want to rotate and translate that function such that its center is now at the midpoint of the two points and it is rotated to point toward the second of the points. I can do it sequentially with two operators like so:
rot[p1_,p2_]@f_:=f@@RotationTransform[{Normalize[p2-p1],{0,0,1}}][{x,y,z}]
rs[x_,y_,z_]=rot[point1,point2]@s
trans[p1_,p2_]@f_:=f@@TranslationTransform[-(p2+p1)/2][{x,y,z}]
trs[x_,y_,z_]=trans[point1,point2]@rs
However, I cannot seem to write an operator that does both correctly. This seems like it should work, and yet does not.
move[p1_,p2_]@f_:=f@@(Composition[TranslationTransform[-(p2+p1)/2],
RotationTransform[{Normalize[p1-p2],{0,0,1}}]][{x, y, z}])
The rotation seems fine, but the translation is off. Help?
Edited to add: Here is a test function and some initial points (midpoint at origin, displaced equally along z axis).
Here is some code showing the starting conditions:
Here is some code showing the desired outcome (the two points that will be passed, the vector for the direction I want it pointing, and the midpoint where I want the origin translated to).
When I use the two individual operators in sequence, I get the correct output:
move[p1_, p2_]@ f_ := (Composition[f @@ TranslationTransform[-(p2 + p1)/2], f @@ RotationTransform[{Normalize[p1 - p2], {0, 0, 1}}]][{x, y, z}])
work? $\endgroup$move[point1, point2]@s
givess[1/2 (-point1 - point2)][ s[{(point1 - point2)/Norm[point1 - point2], {0, 0, 1}}][{x, y, z}]]
$\endgroup$