25

There is no need to use Eigensystem or Eigenvectors to find the axis of a rotation matrix. Instead, you can read the axis vector components off directly from the skew-symmetric matrix $$a \equiv R^T-R$$ In three dimensions (which is assumed in the question), applying this matrix to a vector is equivalent to applying a cross product with a vector made up ...


25

Having this problem so often, I also generated some tools to handle it which I'd like to share. This is the code (along with a usage message which is basically a small modification of RotationMatrix::usage. Note that it does not handle exceptions and that it assumes that a C compiler is installed. Quiet@Block[{angle, v, vv, u, uu, ww, e1, e2, e2prime, e3}, ...


17

The trick is just to get rid of the internal Graphics heads and then wrap the full expression in Graphics: {e1, e2} /. Graphics -> Identity // Graphics


16

Those damn coordinate systems! :) You can see a small part of the object at the lower left corner of your result image. That's because you forgot to add the center vector after the rotation to translate it to the right position: i = ImageForwardTransformation[img, center + RotationMatrix[Pi/2].(# - center) &, DataRange ...


14

Using Composition I can apply RotationTransform, TranslationTransform , ShearingTransform one after the other. Graphics3D[{ Opacity[1] , Red , Arrow[{{0, 0, 0}, {1, 0, 0}}] , Green , Arrow[{{0, 0, 0}, {0, 1, 0}}] , Blue , Arrow[{{0, 0, 0}, {0, 0, 1}}] , Opacity[0.2] , GeometricTransformation[Cuboid[-{1, 1, 1}/4, {1, 1, 1}/4], ...


12

Here's a nice one-liner: TransformationFunction[{{1, 0, 0, 0}, {0, 0, -1, 0}, {0, 1, 0, 3}, {0, 0, 0, 1}}] // InverseFunction TransformationFunction[{{1, 0, 0, 0}, {0, 0, 1, -3}, {0, -1, 0, 0}, {0, 0, 0, 1}}] Note that TransformationFunction[] is the head of the results returned by geometric *Transform functions, which take a homogeneous transformation ...


11

Not a complete answer, but I think this can get you close to the solution. If you use images instead of text, there's less (or even no) jumping around. I only worked on the ticks. To have the ticks numbers rasterized, I made a variation of this, but there's probably a simpler way (I didn't try to put your ticks specification, but it should be easy). Then, ...


11

If you have a homogenous transformation matrix of the form $$\begin{bmatrix} \mathrm{R_{3 \times 3}} & \mathrm{d}_{3 \times 1} \\ 0_{1\times 3} & 1_{1\times 1} \end{bmatrix}$$ Then the inverse is given by $$\begin{bmatrix} \mathrm{R}^{-1} & -\mathrm{R}^{-1}\mathrm{d} \\ 0 & 1 \end{bmatrix}$$ Therefore, if your ...


11

I think the failure to discretize your first Graphics object is a bug. But, instead of creating graphics objects and then converting them to MeshRegion objects with DiscretizeGraphics, I think it is simpler to use Region functionality instead, since Rectangle is already a Region primitive. When working with Region primitives you need to use ...


10

If you are just asking how to use quaternions for rotation in Mathematica, I hope the following helps. You specify the axis with a unit vector and the angle of rotation. Here is one implementation: Needs["Quaternions`"]; qr[vec_, u_, a_] := Module[{qv, qu, r}, qv = ReplacePart[Join[{0}, vec], 0 -> Quaternion]; qu = ReplacePart[Join[{Cos[a/2]}, Sin[...


10

Perhaps the following will work for you. Since I worked it out more by trial-and-error than by expertise, there may be unnecessary code that remains. Mainly what I did was the following: Computed the camera position before doing the export by a better method. Your computation of the camera position was the source of the oscillation. Eliminated many options, ...


10

As an alternative you can use BoundaryElementMeshRotate (and a few other Boolean operations) for boundary element meshes that are part of the FEMAddOns paclet. The installation of the paclet is now very easy since the installation can be done via the FEMAddOnsInstall resource function. Install and load the paclet: ResourceFunction["FEMAddOnsInstall"][] ...


9

Update As noted in the comments by @pickett, the function showF in the original post does not preserve the relative positions of the inset graphics. I am not sure if it is possible to fix showF to address this issue. So, instead, I suggest an alternative approach using show2F := Show[# /. Rotate[Graphics[x_, y___], r__] :> Graphics[Rotate[x, r], y], ...


9

Suppose the curve is star-shaped with respect to your center point $\mathbf p=(u,v)$, so that any ray emanating from $\mathbf p$ meets the curve exactly once, at say point $\mathbf q$. Then $r = \|\mathbf q - \mathbf p\|$, $\theta$ is the angle between $\mathbf q-\mathbf p$ and the $x$-axis, and the average radius is $$\frac1{2\pi}\oint_{\mathbf q\in\mathcal ...


9

As noted, you can use FindGeometricTransform[] in tandem with EulerAngles[]: r = {{-0.517853, 0., -0.759239}, {-0.517853, 0., 0.759239}, {0.0647316, 0., 0.}}; rt = {{0.310733, -0.358839, -0.786917}, {0.690333, 0.298661, 0.527983}, {-0.0625667, 0.00376111, 0.0161833}}; fg = FindGeometricTransform[r, rt]; EulerAngles[Drop[TransformationMatrix[Last[fg]]...


9

You can actually use Dot directly. It works in unintuitive ways with tensors. n = 1000; mat1 = Table[Table[RandomReal[1], {2}], {n}, {n}]; matRot = Map[RotationMatrix[3 Degree].# &, mat1, {2}]; // AbsoluteTiming {79.8211, Null} matRot2 = Map[RotationTransform[3. Degree], mat1, {2}]; // AbsoluteTiming {9.04459, Null} matRot3 = mat1....


8

You might find it easier to use Rotate inside of Graphics rather than outside. To do this, you will need to "convert" the Graph to Graphics (I use Show) and then use MapAt to apply Rotate inside of Graphics. g = CompleteGraph[30, DirectedEdges -> True, EdgeStyle -> RGBColor[0, 0, 1], PlotRange -> 1.1*{{-1, 1}, {-1, 1}}, ...


8

There's actually a built in function RotationTransform for that: rotation = RotationTransform[0.3, fixedpoint]; ParametricPlot[{5 {Sin[ϕ], 1 - Cos[ϕ]}, rotation[5 {Sin[ϕ], 1 - Cos[ϕ]}]}, {ϕ, -0.2, 0.8}, PlotRange -> All]


8

It seems that the reason for the text wiggling is that on rendering the textual elements are aligned to the pixel grid. To avoid wiggling we should avoid using of font glyphs. P. Fonseca has showed the rasterization approach. I will show the outlining approach using the core of his tickF function: baseStyle = {FontSize -> 18, FontFamily -> "Helvetica",...


8

You can use RotationTransform. With[{rot = funs[[3]] /. Inner[Rule, {x, y}, RotationTransform[π/2][{x, y}], List]}, ContourPlot[rot, {x, -.5, .5}, {y, -.5, .5}] ] Hope this helps. Also with Manipulate Manipulate[ With[{rot = funs[[3]] /. Inner[Rule, {x, y}, RotationTransform[θ][{x, y}], List]}, Quiet@ContourPlot[rot, {x, -.5, .5}, {y, -.5, .5}]], ...


8

See "Method" in Graphics3D. Manipulate[ ParametricPlot3D[{Cos[p], Sin[p], 0}, {p, 0, 2 Pi}, Boxed -> False, Axes -> True, Ticks -> True, AxesOrigin -> {0, 0, 0}, SphericalRegion -> True, Method -> {"RotationControl" -> Dynamic@rotate}], {rotate, {"Globe", "ArcBall", "TrackBall"}} ] To change the setting in an existing ...


8

Using points as given, you can use RotationMatrix,e.g. : Animate[Show[ ListPointPlot3D[RotationMatrix[a, {0, 1, 0}].# & /@ points, PlotStyle -> {Yellow, PointSize[0.02]}, PlotRange -> Table[{-30, 30}, {3}], Background -> Black, BoxRatios -> 1], Graphics3D[{Red, Thickness[0.01], Arrow[{{0, -30, 0}, {0, 30, 0}}]}]], ...


8

TransformedRegion[] can quickly determine the rotated ellipsoid: er[θ_] = TransformedRegion[Ellipsoid[{0, 0, 0}, {4, 3, 2}], RotationTransform[θ, {0, 0, 1}]] which yields Ellipsoid[{0, 0, 0}, {{16 Cos[θ]^2 + 9 Sin[θ]^2, 7 Cos[θ] Sin[θ], 0}, {7 Cos[θ] Sin[θ], 9 Cos[θ]^2 + 16 Sin[θ]^2, 0}, ...


7

An even much faster way to accomplish this is: ComplexExpand[RotationMatrix[fi, {x, y, z}], TargetFunctions -> {Re, Im}] // FullSimplify


7

mfvonh's trick is nice, but I think it should be said that the normal approach is to rotate graphics primitives inside the Graphics wrapper. Graphics[{ Rotate[Disk[{0, 0}, {1/3, 1/4}], π/3], Rotate[Disk[{0, 0}, {1/3, 1/4}], π/7]}, ImageSize -> Small]


7

I needed to do this recently, so I broke down and decided to write routines for interconverting quaternions and rotation matrices. I'll give the quaternion to rotation matrix routine first, since it's the shortest. I merely needed to modify my Rodrigues routine in this answer: Needs["Quaternions`"]; quaternionToRotation[qq_] /; QuaternionQ[ToQuaternion[qq]...


7

To verify that the rotations happen the way they're supposed to according to the documentation for EulerMatrix, you could use the following Manipulate: Clear[arrowAxes]; arrowAxes[arrowLength_: 1] := Map[{Apply[RGBColor, #], Arrow[Tube[{-#, #}]]} &, arrowLength IdentityMatrix[3]] Manipulate[ Graphics3D[{GeometricTransformation[arrowAxes[.7], ...


7

This answers the slowness part. It is slow because you are using exact numbers for degrees and the matrix was not packed then. Compare the timing: Before: After Just change this one line: {alpha, 1, 180, 1}, {beta, 1, 180, 1}, {gamma, 1, 180, 1}] to {alpha, 1., 180, 1}, {beta, 1., 180, 1}, {gamma, 1., 180, 1}]


7

I have previously used the following routine based on ideas by Möller and Hughes in these previous answers, but it would be good to have it as an explicit answer here: vectorRotate[vv1_?VectorQ, vv2_?VectorQ] := Module[{v1 = Normalize[vv1], v2 = Normalize[vv2], c, d, d1, d2, t1, t2}, d = v1.v2; If[TrueQ[Chop[1 + d] == 0], c = ...


7

I think you want a single transformation function for all points, rather than one for each point independently as kglr's answer currently shows. set1 = {A0, A1, A2, A3}; set2 = {B0, B1, B2, B3}; tF2 = FindGeometricTransform[ set1, set2 , TransformationClass -> "Rigid" , Method -> "FindFit" ][[2]]; Graphics3D[{ {Red,...


Only top voted, non community-wiki answers of a minimum length are eligible