diff options
Diffstat (limited to 'MeshSketch.hs')
-rw-r--r-- | MeshSketch.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/MeshSketch.hs b/MeshSketch.hs index 02c813d..0c1b4a2 100644 --- a/MeshSketch.hs +++ b/MeshSketch.hs | |||
@@ -471,6 +471,13 @@ onResize glarea realized w h = do | |||
471 | unit :: (Linear t c, Fractional t, Normed (c t)) => c t -> c t | 471 | unit :: (Linear t c, Fractional t, Normed (c t)) => c t -> c t |
472 | unit v = scale (1/realToFrac (norm_2 v)) v | 472 | unit v = scale (1/realToFrac (norm_2 v)) v |
473 | 473 | ||
474 | -- | Compute the height of a pixel at the given 3d point. | ||
475 | pixelDelta :: Camera -> Vector Float -> Float | ||
476 | pixelDelta cam x = realToFrac $ frustumHeight eyeToPoint / realToFrac (camHeight cam) | ||
477 | where | ||
478 | eyeToPoint = norm_2 (x - camPos cam) | ||
479 | frustumHeight d = 2 * d * tan (realToFrac $ camHeightAngle cam / 2) | ||
480 | |||
474 | -- This computes a point in world coordinates on the view screen if | 481 | -- This computes a point in world coordinates on the view screen if |
475 | -- we assume the camera is located at the origin. | 482 | -- we assume the camera is located at the origin. |
476 | computeDirection :: Camera -> Double -> Double -> Vector Float | 483 | computeDirection :: Camera -> Double -> Double -> Vector Float |