|
Post by danylo on Jan 26, 2020 16:56:26 GMT
Hello there!
Currently I'm on Ch. 5 and trying to implement this test:
Scenario: Intersecting a scaled sphere with a ray
Given r ← ray(point(0, 0, -5), vector(0, 0, 1))
And s ← sphere()
When set_transform(s, scaling(2, 2, 2))
And xs ← intersect(s, r)
Then xs.count = 2
And xs[0].t = 3
And xs[1].t = 7
The problem is - both of answers I get are exactly half of expected. So xs[0].t = 1.5 and xs[1].t = 3.5
Every other test I've implemented before works correctly. Is there a book mistake, or I should check the code?
|
|
|
Post by danylo on Jan 26, 2020 16:59:02 GMT
The next test:
Scenario: Intersecting a translated sphere with a ray Given r ← ray(point(0, 0, -5), vector(0, 0, 1)) And s ← sphere() When set_transform(s, translation(5, 0, 0)) And xs ← intersect(s, r) Then xs.count = 0
Is working
|
|
|
Post by danylo on Jan 26, 2020 17:15:56 GMT
Transforming a ray gives me new ray where x = 0, y = 0, z = -2.5
|
|
|
Post by danylo on Jan 26, 2020 17:21:33 GMT
I found the answer When working with discriminant, I took "a" and "b" values from old ray
|
|