Craig Treptow
New Member
Doing this in Scala, while learning Scala.
Posts: 9
|
Post by Craig Treptow on Sept 6, 2020 13:56:36 GMT
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:
> 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?
|
|
|
Post by jaredp on Sept 6, 2020 23:54:48 GMT
Just at a glance, what stands out is that FOV and all angles in the book are already in radians, so the conversion factor of (pi/180) isn't necessary.
|
|
Craig Treptow
New Member
Doing this in Scala, while learning Scala.
Posts: 9
|
Post by Craig Treptow on Sept 7, 2020 12:58:11 GMT
Oh, you're absolutely right. Without the conversion, I get 0.0099999999999998 (9.999999999999998e-3) I definitely had this without the radians originally, but either had another issue, or couldn't accept scientific notation an convert it in my head.
Thank you!
|
|