Rotate a sphere with Quaternions (Wolfram Mathematica Software)
Rotate a sphere with Quaternions (Wolfram Mathematica Software)
The code below is used in Wolfram Mathematica software to build a cube like box and rotate it, using the set of the Quaternions:
<< Quaternions`
Q = Quaternion;
rotateq[theta_, v_] := Q @@ (Cos[theta/2], 0, 0, 0 + (Sin[theta/2] Prepend[v, 0])/Sqrt[ Plus @@ (v^2)]);
Rotaterho[vector_, angle_, axis_] := N[rotateq[angle,axis] ** (Q @@ (Prepend[vector, 0])) ** (rotateq[angle, axis])^-1] // Rest// Chop
faces = 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0,
0, 1, 0, 0, 1, 1, 1, 1, 1;
axis = 1, 1, 1;
dots = .5, 0, 1, .5, 1, 1, 1.5, .5, .5, -.5, .5, .5;
Manipulate[t = ANGLE Degree;
points = Table[List @@ Rotaterho[dots[[m]], t, axis], m, 1, 4];
rotatedfaces = Table[Table[List @@ Rotaterho[faces[[c, m]], t, axis], m, 1, 4], c, 1, 4];
box = Table[Polygon[rotatedfaces[[m]]], m, 1, 4];
Graphics3D[EdgeForm[Thick, Blue], FaceForm[Red, LightBlue], box,
Thickness[Medium], Line[-2, -2, -2, 2, 2, 2], PointSize[.03],Yellow, Point[points[[1]]], Green, Point[points[[2]]], Purple,
Point[points[[3]]], Point[points[[4]]],
Line[points[[3]], points[[4]]], Black, Point[0, 0, 0],
Point[1, 1, 1], Axes -> True,
Lighting -> Automatic, BaseStyle -> FontSize -> 13, Boxed -> True,
BoxStyle -> Directive[Dashed], AxesLabel -> x, y, z,
PlotRange -> -2, 2, -2, 2, -2, 2], ANGLE, 0., 360., 1.]
The result is shown in this picture
https://i.stack.imgur.com/75NAb.jpg
How to addapt that code and build a sphere like structure and obtain a similar result?
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.