animate 3d plot with some further requirements in mathematica -
i posted @ this post before, still not solve following problem completely. example:
{pa, pb, pc, pd} = {{0, 0, sqrt[61/3]}, {sqrt[7], 4*sqrt[2/3], 0}, {0, -5*sqrt[2/3], 0}, {-sqrt[71], 4*sqrt[2/3], 0}}; axis={1,0,0};pt={0,1,0}; plotpolygon[{a_, b_, c_}] := {opacity[.4], polygon[{a, b, c}]}; graph=graphics3d[{plotpolygon[{pa, pb, pc}], plotpolygon[{pa, pb, pd}], plotpolygon[{pb, pc, pd}], plotpolygon[{pa, pc, pd}]}, axes -> true, axesorigin->pt]; animate[graph/.gg : graphics3d[___] :> rotate[gg, theta, axis], {theta, 0., 2.*pi}]
i want rotate along axis axis={1,0,0}
passes point pt={0,1,0}
. don't know how specify point information. rotation animation seems chaotic in sense expect @ least 1 point (in case, origin?) not rotating.
you need first change origin of vertices of polygon, rotate, , translate back. can hand
(rotationmatrix[theta,axis].(#-pt) + pt)& /@ {pa, pb, pc, pd}
or, can combine transformations using composition
composition[ affinetransform[{rotationmatrix[theta,axis],pt}],translationtransform[-pt] ] /@ {pa, pb, pc, pd}
or, can take previous composition , apply directly graphics
object
geometrictransformation[ <graphics>, composition[ ... ]]
this documentation gives thorough list of can done.
edit: here's working animation script
animate[ graph /. graphics3d[prims__, opts : optionspattern[]] :> graphics3d[ geometrictransformation[prims, composition[ affinetransform[{rotationmatrix[theta, axis], pt}], translationtransform[-pt] ] ], opts ], {theta, 0., 2.*pi} ]
there's couple of things note here. first, geometrictransformation
appears work on primitives themselves, had split out primitives options in graphics3d
via rule graphics3d[prims__, opts : optionspattern[]]
. also, transformation needs within animate
use local version of theta
.
Comments
Post a Comment