Methane Molecule
This is my first and simple construction of a molecule. I chose to do Methane (CH4), one atom of carbon and four atoms of hydrogen, because it takes the shape of a tetrahedron. In this blog, I used a different but simple method to construct this tetrahedron shape. There is a special angle in tetrahedron. With this special angle, we can easily construct a tetrahedron.
This special angle is about 109.4712 degrees. It is the Edge central angle, also known as the tetrahedral angle or bond angle of the methane molecule. To be precise, this angle can be calculated as or .
Below is the 3D model created in VRMath2 Editor. I added a basic animation so the molecule will be rotating. You can click on the Carbon atom at the centre to toggle on and off the animation.
The Logo program is as below.
; Methane (CH4) molecule model ; by Andy Yeh (2014) TO arm FD 0.7 RD 90 SETSCALE 0.4 0.5 0.4 SETMAT 0 32 CAN RU 90 FD 0.5 RD 90 SETMAT 0 33 CAN RU 90 FD 0.7 RD 90 SETSCALE 1 1 1 BALL RU 90 BK 1.9 END CS RESET SETBG 43 MAKE "tetra_angle 2 * ARCTAN SQRT 2 SETMAT 0 32 BALL ; the carbon atom at the centre MAKE "carbon OBJECT RU 90 arm REPEAT 3 [ RD :tetra_angle arm RU :tetra_angle TL 120 ] RD 90 ; back to beginning direction SHOWALL ; add behaviour and simple animation so when clicked on the model it will toggle a simple rotation. ; firstly create a transform node and move all into the tranform node. TRANSFORM MAKE "methane OBJECT REPEAT 13 [ MAKE "source WORD "obj_ REPCOUNT - 1 MOVE :source :methane ] ; start creating animation. These codes are borrowed from other blogs such as ; from https://vrmath2.net/content/rotating-elevationgrid MAKE "key [] ; make a variable :key as an empty list MAKE "orilist [] ; make a variable :orilist as an empty list QUEUE "key 0 ; queue first value in key list QUEUE "orilist ORI ; queue first value of current orientation REPEAT 4 [ ; use repeat to collect the next 4 values. QUEUE "key REPCOUNT / 4 ; queue is a command to add a value to the end of the list RT 90 QUEUE "orilist ORI ] TIMESENSOR "ts 10 "true ORIENTATIONINTERPOLATOR "oi :key :orilist ROUTE "route1 "ts "fraction_changed "oi "set_fraction ROUTE "route2 "oi "value_changed :methane "rotation ; start adding behaviour ; sample codes borrowed from https://vrmath2.net/content/music-box TOGGLE "act1 "ts "enabled ; create a toggle action named act1 ; the transform at the moment deos not catch the click event, so I associate the click with the carbon atom in line 21 CLICK :carbon "act1 ; associate box click to act1
Files: methane_molecule.x3d methane_molecule.logo methane_molecule_animated.logo
Please leave a comment below if any questions.
- Andy's blog
- Login or register to post comments
- 8551 reads