summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MeshSketch.hs7
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
471unit :: (Linear t c, Fractional t, Normed (c t)) => c t -> c t 471unit :: (Linear t c, Fractional t, Normed (c t)) => c t -> c t
472unit v = scale (1/realToFrac (norm_2 v)) v 472unit v = scale (1/realToFrac (norm_2 v)) v
473 473
474-- | Compute the height of a pixel at the given 3d point.
475pixelDelta :: Camera -> Vector Float -> Float
476pixelDelta 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.
476computeDirection :: Camera -> Double -> Double -> Vector Float 483computeDirection :: Camera -> Double -> Double -> Vector Float