Home Toolbox functions Sample projects Tutorials Downloads |
|
Reference: Chapter 6 in Multibody Mechanics and Visualization by Harry Dankowicz, published by Springer Verlag UK, 2004.
To illustrate the use of rotations to represent orientations.
This Mambo project contains a stationary tetrahedral arrangement of blocks.
l: lengths of the edges of the tetrahedron.
Modify the Mambo project to generate three-dimensional representations of complex organic molecules where blocks are used to represent chemical bonds and different-colored spheres are used to represent different atomic species (cf. the Pyramid Mambo project).
tetra.zip (zip file, 4 kb, February 14, 2013) >Restart(): >DeclareObservers(W): >DeclarePoints(W,seq(cat(E,k),k=1..6)): >DeclareTriads(w,seq(cat(e,k),k=1..6)): >DefineObservers([W,W,w]): >assume(l>0): >rWC1:=MakeTranslations(w,-l/2,-l*sqrt(3)/6,-l*sqrt(6)/12): >rWC2:=MakeTranslations(w,l/2,-l*sqrt(3)/6,-l*sqrt(6)/12): >rWC3:=MakeTranslations(w,0,l*sqrt(3)/3,-l*sqrt(6)/12): >rWC4:=MakeTranslations(w,0,0,l*sqrt(6)/4): >DefinePoints([W,E1,(1/2) &** (rWC1 &++ rWC2)],[W,E2,(1/2) &** (rWC2 &++ rWC3)],[W,E3,(1/2) &** (rWC3 &++ rWC1)],[W,E4,(1/2) &** (rWC1 &++ rWC4)],[W,E5,(1/2) &** (rWC2 &++ rWC4)],[W,E6,(1/2) &** (rWC3 &++ rWC4)]): >edges:=[rWC2 &-- rWC1,rWC3 &-- rWC2,rWC1 &-- rWC3,rWC4 &-- rWC1,rWC4 &-- rWC2,rWC4 &-- rWC3]: >k:=1: >for each in edges do b1:=(1/VectorLength(each)) &** each: b2:=(1/VectorLength(b1 &xx MakeTranslations(w,3))) &** (b1 &xx MakeTranslations(w,3)): b3:=b1 &xx b2: DefineTriads(w,cat(e,k),simplify(Matrix(3,3,(i,j)->MakeTranslations(w,i) &oo cat(b,j)))): k:=k+1: od: >DefineObjects(seq([W,'Block',point=cat(E,k),orient=cat(e,k),xlength=l,ylength=l/10,zlength=l/10,color=yellow],k=1..6)): >GeometryOutput(main=W,parameters=[l=1],checktree,checkargs,filename="tetra.geo"); >MotionOutput(ode={},parameters=[l=1],filename="tetra.dyn"); |
©2004-2017 Harry Dankowicz Mechanical Science and Engineering University of Illinois at Urbana-Champaign | Home Toolbox functions Sample projects Tutorials Downloads |