crystalcell 0.0.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +7 -1
- data/Gemfile +2 -2
- data/VERSION +1 -1
- data/crystalcell.gemspec +17 -10
- data/lib/crystalcell/cell.rb +8 -3
- data/lib/crystalcell/povray/camera.rb +47 -23
- data/lib/crystalcell/povray/cell.rb +47 -39
- data/lib/crystalcell/povray/color.rb +42 -0
- data/lib/crystalcell/povray/cylinder.rb +15 -5
- data/lib/crystalcell/povray/sphere.rb +4 -0
- data/lib/crystalcell/povray/tetrahedron.rb +34 -0
- data/lib/crystalcell/povray/triangle.rb +24 -8
- data/lib/crystalcell/povray.rb +189 -1
- data/test/povray/test_camera.rb +178 -42
- data/test/povray/test_cell.rb +38 -38
- data/test/povray/test_colors.rb +106 -0
- data/test/povray/test_cylinder.rb +29 -0
- data/test/povray/test_tetrahedron.rb +47 -0
- data/test/povray/test_triangle.rb +41 -0
- data/test/test_cell.rb +9 -4
- data/test/test_povray.rb +104 -0
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a6d81b3b2df5aebe2d59092c8af9a06a86de351
|
4
|
+
data.tar.gz: 5956faf1dcd9aba246f3738ec238dd99d10bf0f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d44dd90fcc58571b9db57aa3cf1f072ab2469743d2d190bd17bf0b046f38f1ad3b2e5fd59d05fc7e3ef9efd75b706d834031830375b4d1fbf1f3c2d70b426b
|
7
|
+
data.tar.gz: 7b07a0e21b1972342ef2b647f215b4ec66c02aedeafead6de6c72d076250fc44d05366da87df2ff7a2f236b0ca0ff02d183250787cc7c2c623d2372922101a28
|
data/CHANGES
CHANGED
data/Gemfile
CHANGED
@@ -6,13 +6,13 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "test-unit", "~> 3.
|
9
|
+
gem "test-unit", "~> 3.2"
|
10
10
|
gem "rdoc", "~> 4.2"
|
11
11
|
gem "bundler", "~> 1.11"
|
12
12
|
gem "jeweler", "~> 2.0"
|
13
13
|
gem "simplecov", "~> 0.11"
|
14
14
|
gem "malge", "~> 0.0"
|
15
|
-
gem "mageo", "~> 0.
|
15
|
+
gem "mageo", "~> 0.1"
|
16
16
|
gem "maset", "~> 0.0"
|
17
17
|
gem "builtinextension", "~> 0.1"
|
18
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/crystalcell.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: crystalcell 0.0
|
5
|
+
# stub: crystalcell 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "crystalcell"
|
9
|
-
s.version = "0.0
|
9
|
+
s.version = "0.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["ippei94da"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-07-12"
|
15
15
|
s.description = "This gem provides Cell, LatticeAxes, Atom classes, and so on.\n And this provides simple treatment of a periodic boundary condition.\n "
|
16
16
|
s.email = "ippei94da@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -36,20 +36,27 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/crystalcell/povray.rb",
|
37
37
|
"lib/crystalcell/povray/camera.rb",
|
38
38
|
"lib/crystalcell/povray/cell.rb",
|
39
|
+
"lib/crystalcell/povray/color.rb",
|
39
40
|
"lib/crystalcell/povray/cylinder.rb",
|
40
41
|
"lib/crystalcell/povray/element.rb",
|
41
42
|
"lib/crystalcell/povray/sphere.rb",
|
43
|
+
"lib/crystalcell/povray/tetrahedron.rb",
|
42
44
|
"lib/crystalcell/povray/triangle.rb",
|
43
45
|
"test/cif/ZrO2-25C.cif",
|
44
46
|
"test/helper.rb",
|
45
47
|
"test/povray/test_camera.rb",
|
46
48
|
"test/povray/test_cell.rb",
|
49
|
+
"test/povray/test_colors.rb",
|
50
|
+
"test/povray/test_cylinder.rb",
|
47
51
|
"test/povray/test_element.rb",
|
52
|
+
"test/povray/test_tetrahedron.rb",
|
53
|
+
"test/povray/test_triangle.rb",
|
48
54
|
"test/test_atom.rb",
|
49
55
|
"test/test_cell.rb",
|
50
56
|
"test/test_element.rb",
|
51
57
|
"test/test_latticeaxes.rb",
|
52
|
-
"test/test_periodiccell.rb"
|
58
|
+
"test/test_periodiccell.rb",
|
59
|
+
"test/test_povray.rb"
|
53
60
|
]
|
54
61
|
s.homepage = "http://github.com/ippei94da/crystalcell"
|
55
62
|
s.licenses = ["MIT"]
|
@@ -60,34 +67,34 @@ Gem::Specification.new do |s|
|
|
60
67
|
s.specification_version = 4
|
61
68
|
|
62
69
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
-
s.add_development_dependency(%q<test-unit>, ["~> 3.
|
70
|
+
s.add_development_dependency(%q<test-unit>, ["~> 3.2"])
|
64
71
|
s.add_development_dependency(%q<rdoc>, ["~> 4.2"])
|
65
72
|
s.add_development_dependency(%q<bundler>, ["~> 1.11"])
|
66
73
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
67
74
|
s.add_development_dependency(%q<simplecov>, ["~> 0.11"])
|
68
75
|
s.add_development_dependency(%q<malge>, ["~> 0.0"])
|
69
|
-
s.add_development_dependency(%q<mageo>, ["~> 0.
|
76
|
+
s.add_development_dependency(%q<mageo>, ["~> 0.1"])
|
70
77
|
s.add_development_dependency(%q<maset>, ["~> 0.0"])
|
71
78
|
s.add_development_dependency(%q<builtinextension>, ["~> 0.1"])
|
72
79
|
else
|
73
|
-
s.add_dependency(%q<test-unit>, ["~> 3.
|
80
|
+
s.add_dependency(%q<test-unit>, ["~> 3.2"])
|
74
81
|
s.add_dependency(%q<rdoc>, ["~> 4.2"])
|
75
82
|
s.add_dependency(%q<bundler>, ["~> 1.11"])
|
76
83
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
77
84
|
s.add_dependency(%q<simplecov>, ["~> 0.11"])
|
78
85
|
s.add_dependency(%q<malge>, ["~> 0.0"])
|
79
|
-
s.add_dependency(%q<mageo>, ["~> 0.
|
86
|
+
s.add_dependency(%q<mageo>, ["~> 0.1"])
|
80
87
|
s.add_dependency(%q<maset>, ["~> 0.0"])
|
81
88
|
s.add_dependency(%q<builtinextension>, ["~> 0.1"])
|
82
89
|
end
|
83
90
|
else
|
84
|
-
s.add_dependency(%q<test-unit>, ["~> 3.
|
91
|
+
s.add_dependency(%q<test-unit>, ["~> 3.2"])
|
85
92
|
s.add_dependency(%q<rdoc>, ["~> 4.2"])
|
86
93
|
s.add_dependency(%q<bundler>, ["~> 1.11"])
|
87
94
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
88
95
|
s.add_dependency(%q<simplecov>, ["~> 0.11"])
|
89
96
|
s.add_dependency(%q<malge>, ["~> 0.0"])
|
90
|
-
s.add_dependency(%q<mageo>, ["~> 0.
|
97
|
+
s.add_dependency(%q<mageo>, ["~> 0.1"])
|
91
98
|
s.add_dependency(%q<maset>, ["~> 0.0"])
|
92
99
|
s.add_dependency(%q<builtinextension>, ["~> 0.1"])
|
93
100
|
end
|
data/lib/crystalcell/cell.rb
CHANGED
@@ -135,7 +135,7 @@ class CrystalCell::Cell
|
|
135
135
|
#b_max : b 軸方向のセルの方向を整数で示したときの最大値
|
136
136
|
#c_min : c 軸方向のセルの方向を整数で示したときの最小値
|
137
137
|
#c_max : c 軸方向のセルの方向を整数で示したときの最大値
|
138
|
-
#-1, 1, -1, 1, -1, 1 と指定すれば 3x3x3 の 27
|
138
|
+
#-1, 1, -1, 1, -1, 1 と指定すれば 3x3x3 の 27倍の原子数になる。
|
139
139
|
def atoms_in_supercell( a_min, a_max, b_min, b_max, c_min, c_max )
|
140
140
|
results = []
|
141
141
|
@atoms.each do |atom|
|
@@ -291,7 +291,7 @@ class CrystalCell::Cell
|
|
291
291
|
#Generate a new cell with the same lattice consants,
|
292
292
|
#containing atoms of indicated elements.
|
293
293
|
#Argument 'elems' must be an array of element names.
|
294
|
-
#含まれる @atoms
|
294
|
+
#含まれる @atoms の順序は保存される。元素ごとに並び換えたりしない。
|
295
295
|
#CrystalCell::Atom.element が elems の要素のどれかと完全一致しているもののみ対象となる。
|
296
296
|
#サブクラスのインスタンスで実行した場合には、
|
297
297
|
#サブクラスのインスタンスとして生成する。
|
@@ -519,6 +519,11 @@ class CrystalCell::Cell
|
|
519
519
|
|
520
520
|
#ptg_symbol, ptg_num, trans_mat = getptg(rotations)
|
521
521
|
|
522
|
+
def to_povcell
|
523
|
+
#pp @axes
|
524
|
+
CrystalCell::Povray::Cell.new(@axes, @atoms)
|
525
|
+
end
|
526
|
+
|
522
527
|
private
|
523
528
|
|
524
529
|
def get_spg_dataset
|
@@ -530,7 +535,7 @@ class CrystalCell::Cell
|
|
530
535
|
table[elem]
|
531
536
|
end
|
532
537
|
hall_num= 0
|
533
|
-
|
538
|
+
get_dataset(axes_t, poss, types, hall_num, @symprec, @angle_tolerance)
|
534
539
|
end
|
535
540
|
|
536
541
|
#POSCAR の内容の文字列を生成。
|
@@ -19,39 +19,63 @@ class CrystalCell::Povray::Camera
|
|
19
19
|
#@location = [ 3.0, 3.0, 3.0 ]
|
20
20
|
#@look_at = [ 0.0, 0.0, 0.0 ]
|
21
21
|
#@sky = [ 0.0, 0.0, 1.0 ]
|
22
|
-
#@right =
|
22
|
+
#@right =
|
23
23
|
#@up = [ 0.0, 1.0, 0.0 ]
|
24
24
|
#@angle = 68
|
25
25
|
|
26
|
-
attr_accessor :
|
26
|
+
attr_accessor :camera_type, :location, :right, :up, :direction,
|
27
|
+
:sky, :angle, :look_at
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
# camera_type: perspectice, orthographic, etc.
|
30
|
+
# Note: default values of some setting is modified from original povray
|
31
|
+
# because of left-handed coordinate system.
|
32
|
+
# This library provide only on right-handed system in crystallography.
|
33
|
+
#
|
34
|
+
# ---------------------------------------------
|
35
|
+
# setting default_orig default_this
|
36
|
+
# camera_type perspective
|
37
|
+
# location <0,0,0>
|
38
|
+
# direction <0,0,1>
|
39
|
+
# right <1.33,0,0> [-1.33, 0.0, 0.0],
|
40
|
+
# sky <0,1,0> [ 0.0, 0.0, 1.0],
|
41
|
+
# up <0,1,0>
|
42
|
+
# look_at <0,0,1>
|
43
|
+
def initialize(camera_type: nil, # perspective
|
44
|
+
location: nil, # <0,0,0>
|
45
|
+
right: [-1.33, 0.0, 0.0],
|
46
|
+
up: nil,
|
47
|
+
direction: nil,
|
48
|
+
sky: [0.0, 0.0, 1.0],
|
49
|
+
angle: nil,
|
50
|
+
#camera_modifiers: nil,
|
51
|
+
look_at: nil
|
52
|
+
)
|
53
|
+
@camera_type = camera_type
|
54
|
+
@location = location
|
55
|
+
@right = right
|
56
|
+
@up = up
|
57
|
+
@direction = direction
|
58
|
+
@sky = sky
|
59
|
+
@angle = angle
|
60
|
+
#@camera_modifiers = camera_modifiers
|
61
|
+
@look_at = look_at
|
38
62
|
end
|
39
63
|
|
40
64
|
def dump(io)
|
41
65
|
io.puts "camera {"
|
42
|
-
io.
|
43
|
-
io.printf(" location
|
44
|
-
io.printf("
|
45
|
-
io.printf("
|
46
|
-
io.printf("
|
47
|
-
io.printf("
|
48
|
-
io.printf(" angle
|
66
|
+
io.printf(" %s\n", @camera_type) if @camera_type
|
67
|
+
io.printf(" location <%f, %f, %f >\n", *@location) if @location
|
68
|
+
io.printf(" right <%f, %f, %f >\n", *@right) if @right
|
69
|
+
io.printf(" up <%f, %f, %f >\n", *@up) if @up
|
70
|
+
io.printf(" direction <%f, %f, %f >\n", *@direction) if @direction
|
71
|
+
io.printf(" sky <%f, %f, %f >\n", *@sky) if @sky
|
72
|
+
io.printf(" angle %f\n" , @angle) if @angle
|
73
|
+
#@camera_modifiers.each do |i|
|
74
|
+
# io.puts i
|
75
|
+
#end
|
76
|
+
io.printf(" look_at <%f, %f, %f >\n", *@look_at) if @look_at
|
49
77
|
io.puts "}"
|
50
|
-
@additions.each do |i|
|
51
|
-
io.puts i
|
52
|
-
end
|
53
78
|
end
|
54
79
|
|
55
80
|
end
|
56
81
|
|
57
|
-
|
@@ -3,17 +3,22 @@
|
|
3
3
|
class CrystalCell::Povray::Cell < CrystalCell::Cell
|
4
4
|
RADIUS_RATIO = 0.3
|
5
5
|
|
6
|
-
LATTICE_RADIUS = 0.
|
6
|
+
LATTICE_RADIUS = 0.02
|
7
7
|
LATTICE_COLOR = [0.50, 0.50, 0.50]
|
8
8
|
BOND_RADIUS = 0.05
|
9
9
|
BOND_COLOR = [0.75, 0.75, 0.75]
|
10
10
|
|
11
11
|
# povray 形式の文字列を返す。
|
12
12
|
def to_pov
|
13
|
-
|
13
|
+
#return atoms_to_povs + bonds_to_povs + lattice_to_povs
|
14
|
+
return atoms_to_povs + lattice_to_povs
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
+
def dump(io)
|
18
|
+
self.to_pov.each do |line|
|
19
|
+
io.print line
|
20
|
+
end
|
21
|
+
end
|
17
22
|
|
18
23
|
# 原子を描画するための pov 形式文字列を返す。
|
19
24
|
# 周期境界近傍の原子が tolerance 未満ならば、反対側のセル境界にも描画する。
|
@@ -27,30 +32,30 @@ class CrystalCell::Povray::Cell < CrystalCell::Cell
|
|
27
32
|
results
|
28
33
|
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def bonds_to_povs(elem0, elem1, min_distance, max_distance)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
35
|
+
## 原子間の連結棒を描画するための pov 形式文字列を返す。
|
36
|
+
## E.g.,
|
37
|
+
## elem0 = 'O'
|
38
|
+
## elem1 = 'Li'
|
39
|
+
## min_distance = 0.0
|
40
|
+
## max_distance = 1.0
|
41
|
+
## 上記の指定の場合、O-O 間かつ距離が 0.0〜1.0 の原子間のみ
|
42
|
+
## bond を出力する。
|
43
|
+
#def bonds_to_povs(elem0, elem1, min_distance, max_distance)
|
44
|
+
# results = []
|
45
|
+
# cell = self.to_pcell
|
46
|
+
# cell.find_bonds(elem0, elem1, min_distance, max_distance).each do |pair|
|
47
|
+
# cart0 = pair[0].to_v3d(self.axes)
|
48
|
+
# cart1 = pair[1].to_v3d(self.axes)
|
49
|
+
# midpoint = Mageo::Vector3D.midpoint(cart0, cart1)
|
50
|
+
# results << Mageo::Cylinder.new(
|
51
|
+
# [cart0, midpoint], BOND_RADIUS).to_pov(
|
52
|
+
# CrystalCell::Povray::Element.color(elem0)) + "\n"
|
53
|
+
# results << Mageo::Cylinder.new(
|
54
|
+
# [cart1, midpoint], BOND_RADIUS).to_pov(
|
55
|
+
# CrystalCell::Povray::Element.color(elem1)) + "\n"
|
56
|
+
# end
|
57
|
+
# results
|
58
|
+
#end
|
54
59
|
|
55
60
|
# 格子の棒を描画するための pov 形式文字列を返す。
|
56
61
|
def lattice_to_povs
|
@@ -64,18 +69,21 @@ class CrystalCell::Povray::Cell < CrystalCell::Cell
|
|
64
69
|
v111 = Vector3DInternal[ 1.0, 1.0, 1.0 ].to_v3d(self.axes)
|
65
70
|
|
66
71
|
results = []
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
results <<
|
71
|
-
results <<
|
72
|
-
results <<
|
73
|
-
results <<
|
74
|
-
results <<
|
75
|
-
results <<
|
76
|
-
results <<
|
77
|
-
results <<
|
78
|
-
results <<
|
72
|
+
cy = CrystalCell::Povray::Cylinder
|
73
|
+
r = LATTICE_RADIUS
|
74
|
+
c = LATTICE_COLOR
|
75
|
+
results << cy.new(v000, v001, r, c).to_pov.to_s + "\n"
|
76
|
+
results << cy.new(v010, v011, r, c).to_pov.to_s + "\n"
|
77
|
+
results << cy.new(v100, v101, r, c).to_pov.to_s + "\n"
|
78
|
+
results << cy.new(v110, v111, r, c).to_pov.to_s + "\n"
|
79
|
+
results << cy.new(v000, v010, r, c).to_pov.to_s + "\n"
|
80
|
+
results << cy.new(v100, v110, r, c).to_pov.to_s + "\n"
|
81
|
+
results << cy.new(v001, v011, r, c).to_pov.to_s + "\n"
|
82
|
+
results << cy.new(v101, v111, r, c).to_pov.to_s + "\n"
|
83
|
+
results << cy.new(v000, v100, r, c).to_pov.to_s + "\n"
|
84
|
+
results << cy.new(v001, v101, r, c).to_pov.to_s + "\n"
|
85
|
+
results << cy.new(v010, v110, r, c).to_pov.to_s + "\n"
|
86
|
+
results << cy.new(v011, v111, r, c).to_pov.to_s + "\n"
|
79
87
|
results
|
80
88
|
end
|
81
89
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#
|
7
|
+
class CrystalCell::Povray::Color
|
8
|
+
|
9
|
+
PI = Math::PI
|
10
|
+
#
|
11
|
+
def initialize()
|
12
|
+
end
|
13
|
+
|
14
|
+
# 色相環(color circle) 上での色を、与えられた角度に対して返す。
|
15
|
+
# 強度は [r, g, b] の配列で、0.0<=x<=1.0 の実数。
|
16
|
+
def self.circle_color(theta)
|
17
|
+
theta = theta % (2*PI); #-2*pi 〜 +2*pi の範囲に入る
|
18
|
+
|
19
|
+
r = self.trapezoidal_wave(theta, (4.0/6.0) * 2.0 * PI)
|
20
|
+
g = self.trapezoidal_wave(theta, (0.0/6.0) * 2.0 * PI)
|
21
|
+
b = self.trapezoidal_wave(theta, (2.0/6.0) * 2.0 * PI)
|
22
|
+
[r, g, b]
|
23
|
+
end
|
24
|
+
|
25
|
+
# 台形波
|
26
|
+
def self.trapezoidal_wave(theta, phase)
|
27
|
+
x = (theta - phase)/ (2.0*PI)
|
28
|
+
x = x - x.floor
|
29
|
+
if (0.0/6.0) <= x && x < (1.0/6.0)
|
30
|
+
return x * 6.0
|
31
|
+
elsif (1.0/6.0) <= x && x < (3.0/6.0)
|
32
|
+
return 1.0
|
33
|
+
elsif (3.0/6.0) <= x && x < (4.0/6.0)
|
34
|
+
return 4.0 - x * 6.0
|
35
|
+
elsif (4.0/6.0) <= x && x < (6.0/6.0)
|
36
|
+
return 0.0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# thetaBase: その色が上がり始める点を基準とする。R ならば 4π/3
|
@@ -1,12 +1,22 @@
|
|
1
1
|
#! /usr/bin/env ruby # coding: utf-8
|
2
2
|
|
3
|
-
class Mageo::Cylinder
|
3
|
+
class CrystalCell::Povray::Cylinder < Mageo::Cylinder
|
4
|
+
attr_reader :positions, :color
|
5
|
+
|
6
|
+
def initialize(position0, position1, radius, color)
|
7
|
+
super(position0, position1, radius)
|
8
|
+
@color = color
|
9
|
+
end
|
10
|
+
|
4
11
|
# povray 形式の文字列を返す。
|
5
12
|
# color は Float による配列。通常、0〜1の範囲。
|
6
|
-
def to_pov
|
13
|
+
def to_pov
|
7
14
|
sprintf( "object { cylinder{ <% 7.4f, % 7.4f, % 7.4f>, <% 7.4f, % 7.4f, % 7.4f>, %7.4f } pigment { color rgb <%4.2f, %4.2f, %4.2f> } }",
|
8
|
-
|
15
|
+
*positions[0], *positions[1], radius, *color)
|
16
|
+
#*@positions[0], *@positions[1], radius, @color)
|
9
17
|
end
|
10
|
-
end
|
11
|
-
|
12
18
|
|
19
|
+
def dump(io)
|
20
|
+
io.puts self.to_pov
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /usr/bin/env ruby # coding: utf-8
|
2
|
+
|
3
|
+
class CrystalCell::Povray::Tetrahedron < Mageo::Tetrahedron
|
4
|
+
|
5
|
+
attr_accessor :color, :transmit
|
6
|
+
|
7
|
+
# color should be Array like [r, g, b]. Float from 0.0 to 1.0.
|
8
|
+
def initialize(v0, v1, v2, v3, color, transmit = nil)
|
9
|
+
super(v0, v1, v2, v3)
|
10
|
+
@color = color
|
11
|
+
@transmit = transmit
|
12
|
+
end
|
13
|
+
|
14
|
+
# povray 形式の文字列を返す。
|
15
|
+
# color は Float による配列。通常、0〜1の範囲。
|
16
|
+
def to_pov
|
17
|
+
triangles.map { |triangle| triangle.to_pov }.join("\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
def dump(io)
|
21
|
+
io.puts self.to_pov
|
22
|
+
end
|
23
|
+
|
24
|
+
def triangles
|
25
|
+
results = VERTEX_INDICES_OF_TRIANGLES.map do |indices|
|
26
|
+
CrystalCell::Povray::Triangle.new( *(indices.map{|i| @vertices[i] }), @color, @transmit )
|
27
|
+
end
|
28
|
+
return results
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -1,17 +1,33 @@
|
|
1
1
|
#! /usr/bin/env ruby # coding: utf-8
|
2
2
|
|
3
|
-
class Mageo::Triangle
|
3
|
+
class CrystalCell::Povray::Triangle < Mageo::Triangle
|
4
|
+
|
5
|
+
attr_accessor :color, :transmit
|
6
|
+
|
7
|
+
def initialize(vec0, vec1, vec2, color, transmit = nil)
|
8
|
+
super(vec0, vec1, vec2)
|
9
|
+
@color = color
|
10
|
+
@transmit = transmit
|
11
|
+
end
|
12
|
+
|
4
13
|
# povray 形式の文字列を返す。
|
5
14
|
# color は Float による配列。通常、0〜1の範囲。
|
6
|
-
def to_pov
|
15
|
+
def to_pov
|
7
16
|
v = self.vertices
|
8
|
-
result =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
result = sprintf("triangle{<%f,%f,%f>,<%f,%f,%f>,<%f,%f,%f>",
|
18
|
+
*@vertices[0], *@vertices[1], *@vertices[2])
|
19
|
+
result += sprintf(" pigment {color rgb<%f,%f,%f>", *@color)
|
20
|
+
result += sprintf(" transmit %f", @transmit) if @transmit
|
21
|
+
result += "}}"
|
22
|
+
#result = sprintf("triangle{<%f,%f,%f>,<%f,%f,%f>,<%f,%f,%f> " +
|
23
|
+
# "pigment {color rgb<%f,%f,%f>}}",
|
24
|
+
# *@vertices[0], *@vertices[1], *@vertices[2], *@color)
|
25
|
+
#
|
13
26
|
return result
|
14
27
|
end
|
15
|
-
end
|
16
28
|
|
29
|
+
def dump(io)
|
30
|
+
io.puts self.to_pov
|
31
|
+
end
|
32
|
+
end
|
17
33
|
|