# The Ray Tracer Challenge: Chapter 7 - Calculating pixel size

**URL:** <https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530>\
**Category:** PragProg Customers\
**Tags:** book-the-ray-tracer-challenge, question\
**Created:** [6 September 2020 14:27 UTC](https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530 "2020-09-06T14:27:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CraigTreptow](https://forum.devtalk.com/user_avatar/forum.devtalk.com/craigtreptow/32/1032_2.png) [@CraigTreptow](https://forum.devtalk.com/u/CraigTreptow)\
**Post date:** [6 September 2020 14:27 UTC](https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530/1 "2020-09-06T14:27:52Z")

</div>

Hi. I’m working on this test:

Scenario ​: The pixel size for a horizontal canvas  
Given ​ c ← camera(200, 125, π/2)  
Then ​ c.pixel\_size = 0.01

I’m doing this in Haskell, so I’m pulling the following from a Haskell REPL prompt that is doing the same calculations as my code:

```auto
> hs = 200
> vs = 125
> fov = (pi/2)
> 1.5707963267948966

> radians = (fov/2) * (pi/180)
> 1.3707783890401887e-2 ==> (0.013707783)
> ar = (fromIntegral hs) / (fromIntegral vs)
> 1.6
> hv = tan radians
> 1.3708642534394055e-2 ==> (0.01370864253)
> hw = calcHalfWidth ar hv
> 1.3708642534394055e-2 ==> (0.01370864253)
> (hw * 2) / (fromIntegral hs) ==> (0.02741728506) / 200
1.3708642534394054e-4 ==> (0.00013708642)

```

I’m trying to track down where this is going wrong, and every time I double check my calculations, I convince myself that they are correct, even though I’m off by so much.

Does anybody see any obvious issues?

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nobbz/32/114_2.png) [@NobbZ](https://forum.devtalk.com/u/NobbZ)\
**Post date:** [7 September 2020 04:32 UTC](https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530/2 "2020-09-07T04:32:37Z")

</div>

You are not off. `0.000137` is just another way to write `1.37e-4`.

You have to read it as `1.37 * 10 ^ (-4)`.

It is called [scientific notation](https://en.wikipedia.org/wiki/Scientific_notation).

---

<div class="post-metadata">

**Author:** ![CraigTreptow](https://forum.devtalk.com/user_avatar/forum.devtalk.com/craigtreptow/32/1032_2.png) [@CraigTreptow](https://forum.devtalk.com/u/CraigTreptow)\
**Post date:** [7 September 2020 12:50 UTC](https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530/3 "2020-09-07T12:50:34Z")

</div>

Sorry, I wasn’t clear. That last calculation is the pixel size, which should equal 0.01. I was just showing the non-scientific notation values by adding the ‘==\> (some number)’

---

<div class="post-metadata">

**Author:** ![CraigTreptow](https://forum.devtalk.com/user_avatar/forum.devtalk.com/craigtreptow/32/1032_2.png) [@CraigTreptow](https://forum.devtalk.com/u/CraigTreptow)\
**Post date:** [7 September 2020 13:03 UTC](https://forum.devtalk.com/t/the-ray-tracer-challenge-chapter-7-calculating-pixel-size/1530/4 "2020-09-07T13:03:30Z")

</div>

I have confirmed the book uses only radians for angles, so after undoing the radian conversion, my answer was actually 9.999999999999998e-3. or 0.009999999. So, I had it all along, but just couldn’t see it.

That’s what a night of sleep and a helpful stranger gets you. 😉
