Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# xyz2pov

This Python script converts xyz coordinate files into povray scenes.
This implementation in Python and `numpy` converts xyz coordinate files into
povray scenes by

``` shell
python ./xyz2povray.py input.xyz
```

to yield `input.pov` and `input.ini`. A subsequent run of `povray ./input.pov`
writes a single 800x600 px `input.png`. With `povray ./input.ini` a sequence
of 36 frames (640x420 px) yields a full rotation of the structure around
POVRay's x-axis, which can serve as template for further exploration, and to
write an animated .gif e.g. on [ezgif](https://ezgif.com/)

![Example for glucose](glucose.gif)

All atoms starting from 1 (hydrogen, H) up to 96 (curium, Cm) are supported
by a color scheme close to the one used by Jmol. If the interatomic
distance is less or equal the sum of the corresponding covalent radii
compiled by [Wikipedia](https://en.wikipedia.org/wiki/Covalent_radius), two
atoms are considered to be bound together; the model depicts them as
connected by a tube. An atom "too far out" to bind with an other atom is
going to be displayed as sphere.

So far, only hydrogen and carbon atoms are supported, but this is extendable for
other atoms. The style is similar to Avogadro's tube model.
The camera is automatically directed to the molecule's center of mass and placed
at an appropriate distance. Two lights are placed relative to the camera
automatically.

TODO: automatic rotation of the camera to get a horizontal view of the
molecule.
Binary file added glucose.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Written for Linux Debian 12/bookworm with Python 3.11.2; equally
# known to work in Linux Xubuntu 22.04.2 Jammy with Python 3.10.6.
numpy==1.24.3
File renamed without changes.
17 changes: 17 additions & 0 deletions test_molecules/diethylether.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
15

C 1.05226 -0.05118 -0.07983
C 2.56736 -0.00919 -0.07150
O 3.06571 -1.31944 -0.33155
C 4.49062 -1.34380 -0.33639
C 4.95531 -2.75883 -0.61723
H 0.63467 0.94053 0.11699
H 0.68037 -0.74731 0.67921
H 0.68037 -0.40467 -1.04720
H 2.92318 0.33323 0.90628
H 2.92318 0.68069 -0.84440
H 4.86916 -1.01676 0.63832
H 4.86916 -0.66931 -1.11230
H 4.57512 -3.44928 0.14301
H 6.04819 -2.81488 -0.62835
H 4.57512 -3.10661 -1.58352
19 changes: 19 additions & 0 deletions test_molecules/ethylpyridine.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
17

C 1.41296 0.10302 0.00141
C 0.64113 1.26139 0.02360
C -0.73734 1.13219 0.03626
N -1.37948 -0.05512 0.03497
C -0.60408 -1.16294 0.01072
C 0.78738 -1.14561 -0.01734
C 1.58000 -2.42169 -0.05489
C 1.88600 -2.95600 1.33548
H 2.49742 0.17960 -0.00851
H 1.10384 2.24198 0.02822
H -1.38148 2.00661 0.04696
H -1.15587 -2.09946 0.00969
H 2.51732 -2.25594 -0.59970
H 1.02859 -3.17773 -0.62711
H 2.48501 -2.24360 1.91252
H 2.44981 -3.89166 1.26320
H 0.96737 -3.15694 1.89715
26 changes: 26 additions & 0 deletions test_molecules/glucose.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
24

O 4.59506 0.44106 -3.18607
C 4.05938 0.72532 -1.89257
C 2.98776 -0.30438 -1.50340
O 1.91330 -0.23175 -2.44604
C 0.85139 -1.11865 -2.16127
O -0.18177 -0.90552 -3.11301
C 1.33510 -2.58932 -2.18448
O 0.27087 -3.51063 -1.92486
C 2.46110 -2.74119 -1.15473
O 3.00118 -4.06417 -1.13001
C 3.58139 -1.71941 -1.41795
O 4.55971 -1.75973 -0.36979
H 5.16453 1.19425 -3.42069
H 3.61335 1.72785 -1.93053
H 4.88306 0.73137 -1.17545
H 2.60456 -0.01108 -0.51419
H 0.41460 -0.88077 -1.18320
H 0.04931 -1.42082 -3.90159
H 1.71521 -2.84259 -3.18064
H 0.08274 -3.51136 -0.97050
H 2.05939 -2.58506 -0.14388
H 3.30065 -4.28731 -2.03033
H 4.08740 -1.99062 -2.35084
H 4.30606 -2.46202 0.25763
26 changes: 26 additions & 0 deletions test_molecules/iodo.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
24

C -3.05938 -3.21987 0.72725
N -4.16473 -3.37773 1.50103
O -4.09462 -2.71557 2.76828
P -2.89848 -3.15224 3.79443
S -1.38288 -2.34994 2.64644
C -1.80899 -2.78556 1.00485
C -0.73339 -2.67949 -0.05568
C 0.42871 -3.68938 0.06469
O 1.21780 -3.42398 1.23177
C 0.03967 -5.17720 0.08063
C -0.71431 -5.69635 -1.15397
I 0.52239 -5.56703 -2.95916
C -1.09584 -7.16870 -0.97145
H -3.20027 -3.51007 -0.31360
H -0.32054 -1.66251 -0.02114
H -1.18046 -2.78232 -1.05277
H 1.10831 -3.50409 -0.77306
H 0.59060 -3.35347 1.97817
H -0.56338 -5.37234 0.97735
H 0.95274 -5.76943 0.23428
H -1.62604 -5.11610 -1.32373
H -0.21026 -7.80096 -0.83274
H -1.64183 -7.54723 -1.84341
H -1.74008 -7.29709 -0.09483
29 changes: 29 additions & 0 deletions test_molecules/pentylbenzene.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
27

C -0.18369 0.78488 -0.95826
C -1.06696 -0.27641 -0.75656
C -0.90247 -1.12526 0.33602
C 0.14900 -0.91472 1.22608
C 1.03081 0.14805 1.02734
C 0.87632 1.00904 -0.06840
C 1.81056 2.17724 -0.27248
C 3.29089 1.79735 -0.39488
C 3.59115 0.92840 -1.61860
C 5.08149 0.59670 -1.69771
C 5.39771 -0.27792 -2.89994
H -0.32884 1.43729 -1.81648
H -1.88811 -0.43862 -1.45070
H -1.59375 -1.94708 0.49639
H 0.28098 -1.57690 2.07761
H 1.83998 0.30093 1.73818
H 1.68607 2.85763 0.57974
H 1.51423 2.74785 -1.16117
H 3.62859 1.28375 0.51354
H 3.87610 2.72310 -0.46124
H 3.27954 1.45419 -2.52869
H 3.01784 -0.00437 -1.57039
H 5.39494 0.07698 -0.78485
H 5.66594 1.52203 -1.76125
H 4.85596 -1.22749 -2.84735
H 6.46886 -0.49940 -2.93416
H 5.12350 0.22420 -3.83345
11 changes: 11 additions & 0 deletions test_molecules/thiophene.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
9

C 1.38296 0.71961 0.00140
C 0.10409 1.23203 -0.00494
S -1.08316 -0.00090 -0.00999
C 0.11198 -1.22614 -0.00521
C 1.38752 -0.70558 0.00147
H 2.27214 1.33793 0.00541
H -0.19362 2.27159 -0.00668
H -0.17913 -2.26757 -0.00725
H 2.28065 -1.31820 0.00587
Loading