manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.12 Molecules drawing sample

../png/molecule

C++ code

gr->Alpha(true); gr->Light(true);
gr->SubPlot(2,2,0);
gr->Text(mglPoint(0,1.2),"Methane, CH_4",0,-3); gr->Rotate(60,120);
gr->Sphere(mglPoint(0,0,0),0.25,"k");
gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2);
gr->Sphere(mglPoint(0,0,0.7),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g");
gr->SubPlot(2,2,1);
gr->Text(mglPoint(0,1.2),"Water, H{_2}O",0,-3); gr->Rotate(60,100);
gr->Sphere(mglPoint(0,0,0),0.25,"r");
gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g");
gr->SubPlot(2,2,2);
gr->Text(mglPoint(0,1.2),"Oxygen, O_2",0,-3); gr->Rotate(60,120);
gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0,0.5,0),0.25,"r");
gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0,-0.5,0),0.25,"r");
gr->SubPlot(2,2,3);
gr->Text(mglPoint(0,1.2),"Ammonia, NH_3",0,-3); gr->Rotate(60,120);
gr->Sphere(mglPoint(0,0,0),0.25,"b");
gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2);
gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2);
gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2);
gr->Sphere(mglPoint(-0.65,0,0),0.25,"g");

MGL code

alpha on
light on
subplot 2 2 0
text 0 1.2 'Methane, CH_4' '' -3
rotate 60 120
sphere 0 0 0 0.25 'k'
drop 0 0 0 0 0 1 0.35 'h' 1 2
sphere 0 0 0.7 0.25 'g'
drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2
sphere -0.66 0 -0.23 0.25 'g'
drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2
sphere 0.33 0.57 -0.23 0.25 'g'
drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2
sphere 0.33 -0.57 -0.23 0.25 'g'
subplot 2 2 1
text 0 1.2 'Water, H{_2}O' '' -3
rotate 60 100
sphere 0 0 0 0.25 'r'
drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2
sphere 0.3 0.5 0 0.25 'g'
drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2
sphere 0.3 -0.5 0 0.25 'g'
subplot 2 2 2
text 0 1.2 'Oxygen, O_2' '' -3
rotate 60 120
drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2
sphere 0 0.5 0 0.25 'r'
drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2
sphere 0 -0.5 0 0.25 'r'
subplot 2 2 3
text 0 1.2 0 'Ammonia, NH_3' '' -3
rotate 60 120
sphere 0 0 0 0.25 'b'
drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2
sphere 0.33 0.57 0 0.25 'g'
drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2
sphere 0.33 -0.57 0 0.25 'g'
drop 0 0 0 -0.65 0 0 0.32 'n' 1 2
sphere -0.65 0 0 0.25 'g'

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.