Class: CrystalCell::Povray::Cell
- Defined in:
- lib/crystalcell/povray/cell.rb
Constant Summary collapse
- RADIUS_RATIO =
0.3
- LATTICE_RADIUS =
0.1
- LATTICE_COLOR =
[0.50, 0.50, 0.50]
- BOND_RADIUS =
0.05
- BOND_COLOR =
[0.75, 0.75, 0.75]
Instance Attribute Summary
Attributes inherited from Cell
#angle_tolerance, #atoms, #axes, #comment, #element_names, #symprec
Instance Method Summary collapse
-
#atoms_to_povs(tolerance = 0.0) ⇒ Object
原子を描画するための pov 形式文字列を返す。 周期境界近傍の原子が tolerance 未満ならば、反対側のセル境界にも描画する。.
-
#bonds_to_povs(elem0, elem1, min_distance, max_distance) ⇒ Object
原子間の連結棒を描画するための pov 形式文字列を返す。 E.g., elem0 = ‘O’ elem1 = ‘Li’ min_distance = 0.0 max_distance = 1.0 上記の指定の場合、O-O 間かつ距離が 0.0〜1.0 の原子間のみ bond を出力する。.
-
#lattice_to_povs ⇒ Object
格子の棒を描画するための pov 形式文字列を返す。.
-
#to_pov ⇒ Object
povray 形式の文字列を返す。.
Methods inherited from Cell
#==, #add_atom, #atoms_in_supercell, #brv_lattice, #brv_positions, #brv_types, #calc_volume, #cell_of_elements, #center_of_atoms, #delete_atom, #distance, #elements, #equal_atoms_in_delta?, #equal_in_delta?, #equal_lattice_in_delta?, #exchange_axes, #exchange_axes!, #hall_symbol, #hallnum, #initialize, #inverse_axis, #inverse_axis!, #o_shift, #operate, #positions, #reflect, #reflect!, #rotate, #rotate!, #rotations, #select_indices, #set_elements, #setting, #spg, #spgnum, #symmetry_operations, #t_mat, #to_pcell, #translate, #translate!, #translations, #unite, #wyckoffs
Constructor Details
This class inherits a constructor from CrystalCell::Cell
Instance Method Details
#atoms_to_povs(tolerance = 0.0) ⇒ Object
原子を描画するための pov 形式文字列を返す。 周期境界近傍の原子が tolerance 未満ならば、反対側のセル境界にも描画する。
20 21 22 23 24 25 26 27 28 |
# File 'lib/crystalcell/povray/cell.rb', line 20 def atoms_to_povs(tolerance = 0.0) results = [] atoms.each do |atom| periodic_translations(atom.position, tolerance).each do |translation| results << atom_to_pov(atom.translate(translation)) end end results end |
#bonds_to_povs(elem0, elem1, min_distance, max_distance) ⇒ Object
原子間の連結棒を描画するための pov 形式文字列を返す。 E.g.,
elem0 = 'O'
elem1 = 'Li'
min_distance = 0.0
max_distance = 1.0
上記の指定の場合、O-O 間かつ距離が 0.0〜1.0 の原子間のみ bond を出力する。
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/crystalcell/povray/cell.rb', line 38 def bonds_to_povs(elem0, elem1, min_distance, max_distance) results = [] cell = self.to_pcell cell.find_bonds(elem0, elem1, min_distance, max_distance).each do |pair| cart0 = pair[0].to_v3d(self.axes) cart1 = pair[1].to_v3d(self.axes) midpoint = Mageo::Vector3D.midpoint(cart0, cart1) results << Mageo::Cylinder.new( [cart0, midpoint], BOND_RADIUS).to_pov( CrystalCell::Povray::Element.color(elem0)) + "\n" results << Mageo::Cylinder.new( [cart1, midpoint], BOND_RADIUS).to_pov( CrystalCell::Povray::Element.color(elem1)) + "\n" end results end |
#lattice_to_povs ⇒ Object
格子の棒を描画するための pov 形式文字列を返す。
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/crystalcell/povray/cell.rb', line 56 def lattice_to_povs v000 = Vector3DInternal[ 0.0, 0.0, 0.0 ].to_v3d(self.axes) v001 = Vector3DInternal[ 0.0, 0.0, 1.0 ].to_v3d(self.axes) v010 = Vector3DInternal[ 0.0, 1.0, 0.0 ].to_v3d(self.axes) v011 = Vector3DInternal[ 0.0, 1.0, 1.0 ].to_v3d(self.axes) v100 = Vector3DInternal[ 1.0, 0.0, 0.0 ].to_v3d(self.axes) v101 = Vector3DInternal[ 1.0, 0.0, 1.0 ].to_v3d(self.axes) v110 = Vector3DInternal[ 1.0, 1.0, 0.0 ].to_v3d(self.axes) v111 = Vector3DInternal[ 1.0, 1.0, 1.0 ].to_v3d(self.axes) results = [] results << Mageo::Cylinder.new([v000, v001], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v010, v011], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v100, v101], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v110, v111], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v000, v010], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v100, v110], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v001, v011], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v101, v111], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v000, v100], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v001, v101], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v010, v110], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results << Mageo::Cylinder.new([v011, v111], LATTICE_RADIUS).to_pov(LATTICE_COLOR).to_s + "\n" results end |
#to_pov ⇒ Object
povray 形式の文字列を返す。
12 13 14 |
# File 'lib/crystalcell/povray/cell.rb', line 12 def to_pov return atoms_to_pov + bonds_to_pov + lattice_to_pov end |