caustics 0.2.0 → 0.2.1
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/.codespellignore +0 -0
- data/.yamllint +16 -0
- data/CHANGELOG.md +4 -0
- data/lib/caustics/version.rb +1 -1
- data/lib/caustics.rb +11 -8
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c67829aea9662c33cf0df62b40f293a063c19b99426617582ddfe5b49b43febe
|
|
4
|
+
data.tar.gz: 96c9e7af7d4563b1211c950b357b4e45fdb1ae626b62281eff85ba3d2dbd9aed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1dc1ee270030df2ac75237c9c1a8ae94d0ca5b9fda06d8eee0077aaabf3a577afa427866e5fc58c51ce56b020357db5e456a4e3aa31136886a46b87c807c50d9
|
|
7
|
+
data.tar.gz: 6233d0882d15cb984345c98644b85da078287dcd69042785a956a81967d1efbad25938cd340c0281c77ccd8d58cb73f2c90e28bbfdd9f21b073a5df8b7b95a89
|
data/.codespellignore
ADDED
|
File without changes
|
data/.yamllint
ADDED
data/CHANGELOG.md
CHANGED
data/lib/caustics/version.rb
CHANGED
data/lib/caustics.rb
CHANGED
|
@@ -135,7 +135,7 @@ module Caustics
|
|
|
135
135
|
attr_reader :center, :radius, :material
|
|
136
136
|
def initialize(center:, radius:, material:)
|
|
137
137
|
@center, @radius, @material = center, radius.to_f, material
|
|
138
|
-
raise ArgumentError, "sphere radius must be positive" unless @radius.positive?
|
|
138
|
+
raise ArgumentError, "sphere radius must be positive and finite" unless @radius.finite? && @radius.positive?
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def hit(ray, minimum, maximum)
|
|
@@ -246,8 +246,10 @@ module Caustics
|
|
|
246
246
|
class Material
|
|
247
247
|
def initialize(color: Vec3.new(1, 1, 1), fuzz: 0, index: 1.5, emission: Vec3.new(0, 0, 0), kind: :lambertian)
|
|
248
248
|
@index = Float(index)
|
|
249
|
-
raise ArgumentError, "refractive index must be positive" unless @index.positive?
|
|
250
|
-
|
|
249
|
+
raise ArgumentError, "refractive index must be positive and finite" unless @index.finite? && @index.positive?
|
|
250
|
+
fuzz = Float(fuzz)
|
|
251
|
+
raise ArgumentError, "material fuzz must be finite" unless fuzz.finite?
|
|
252
|
+
@color, @fuzz, @emission, @kind = color, fuzz.clamp(0, 1), emission, kind
|
|
251
253
|
end
|
|
252
254
|
attr_reader :color, :emission, :index, :kind
|
|
253
255
|
|
|
@@ -278,10 +280,11 @@ module Caustics
|
|
|
278
280
|
attr_reader :origin, :horizontal, :vertical, :lower_left
|
|
279
281
|
def initialize(from: [13, 2, 3], to: [0, 0, 0], up: [0, 1, 0], fov: 20, aspect: 16.0 / 9, aperture: 0, focus_distance: 10)
|
|
280
282
|
@origin = vec(from)
|
|
281
|
-
|
|
282
|
-
raise ArgumentError, "camera
|
|
283
|
-
raise ArgumentError, "camera
|
|
284
|
-
raise ArgumentError, "camera
|
|
283
|
+
fov, aspect, aperture, focus_distance = [fov, aspect, aperture, focus_distance].map { |value| Float(value) }
|
|
284
|
+
raise ArgumentError, "camera fov must be between 0 and 180 degrees" unless fov.positive? && fov < 180
|
|
285
|
+
raise ArgumentError, "camera aspect must be finite and positive" unless aspect.finite? && aspect.positive?
|
|
286
|
+
raise ArgumentError, "camera focus distance must be finite and positive" unless focus_distance.finite? && focus_distance.positive?
|
|
287
|
+
raise ArgumentError, "camera aperture must be finite and non-negative" unless aperture.finite? && !aperture.negative?
|
|
285
288
|
theta = fov * Math::PI / 180
|
|
286
289
|
viewport_height = 2 * Math.tan(theta / 2)
|
|
287
290
|
viewport_width = aspect * viewport_height
|
|
@@ -476,7 +479,7 @@ module Caustics
|
|
|
476
479
|
class NoiseTexture
|
|
477
480
|
def initialize(scale: 1, seed: 42)
|
|
478
481
|
@scale = Float(scale)
|
|
479
|
-
raise ArgumentError, "noise texture scale must be positive" unless @scale.positive?
|
|
482
|
+
raise ArgumentError, "noise texture scale must be finite and positive" unless @scale.finite? && @scale.positive?
|
|
480
483
|
@noise = Perlin.new(seed)
|
|
481
484
|
end
|
|
482
485
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caustics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tessel
|
|
@@ -38,6 +38,8 @@ executables:
|
|
|
38
38
|
extensions: []
|
|
39
39
|
extra_rdoc_files: []
|
|
40
40
|
files:
|
|
41
|
+
- ".codespellignore"
|
|
42
|
+
- ".yamllint"
|
|
41
43
|
- CHANGELOG.md
|
|
42
44
|
- LICENSE.txt
|
|
43
45
|
- README.md
|