Class: CrystalCell::Povray::Cell

Inherits:
Cell
  • Object
show all
Defined in:
lib/crystalcell/povray/cell.rb

Constant Summary collapse

RADIUS_RATIO =
0.3
LATTICE_RADIUS =
0.02
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

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, #to_povcell, #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 未満ならば、反対側のセル境界にも描画する。



25
26
27
28
29
30
31
32
33
# File 'lib/crystalcell/povray/cell.rb', line 25

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

#dump(io) ⇒ Object



17
18
19
20
21
# File 'lib/crystalcell/povray/cell.rb', line 17

def dump(io)
  self.to_pov.each do |line|
    io.print line
  end
end

#lattice_to_povsObject

格子の棒を描画するための pov 形式文字列を返す。



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/crystalcell/povray/cell.rb', line 61

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 = []
  cy = CrystalCell::Povray::Cylinder
  r = LATTICE_RADIUS
  c = LATTICE_COLOR
  results << cy.new(v000, v001, r, c).to_pov.to_s + "\n"
  results << cy.new(v010, v011, r, c).to_pov.to_s + "\n"
  results << cy.new(v100, v101, r, c).to_pov.to_s + "\n"
  results << cy.new(v110, v111, r, c).to_pov.to_s + "\n"
  results << cy.new(v000, v010, r, c).to_pov.to_s + "\n"
  results << cy.new(v100, v110, r, c).to_pov.to_s + "\n"
  results << cy.new(v001, v011, r, c).to_pov.to_s + "\n"
  results << cy.new(v101, v111, r, c).to_pov.to_s + "\n"
  results << cy.new(v000, v100, r, c).to_pov.to_s + "\n"
  results << cy.new(v001, v101, r, c).to_pov.to_s + "\n"
  results << cy.new(v010, v110, r, c).to_pov.to_s + "\n"
  results << cy.new(v011, v111, r, c).to_pov.to_s + "\n"
  results
end

#to_povObject

povray 形式の文字列を返す。



12
13
14
15
# File 'lib/crystalcell/povray/cell.rb', line 12

def to_pov
  #return atoms_to_povs + bonds_to_povs + lattice_to_povs
  return atoms_to_povs + lattice_to_povs
end