Allow tweaking z buffer when rendering polygon, improve explosion render
This commit is contained in:
@@ -115,12 +115,10 @@ Identical to detV. -}
|
||||
crossV :: Point2 -> Point2 -> Float
|
||||
crossV (ax,ay) (bx,by) = ax*by - ay*bx
|
||||
{- | TO CHECK Orthographic projection of one vector onto another. -}
|
||||
projV
|
||||
:: Point2
|
||||
-> Point2
|
||||
-> Point2
|
||||
projV :: Point2 -> Point2 -> Point2
|
||||
projV fromv onv
|
||||
| den == 0 = error "tried projecting onto zero vector"
|
||||
| otherwise = (fromv `dotV` onv) / den *.* onv
|
||||
where
|
||||
den = onv `dotV` onv
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ module Geometry.Vector3D
|
||||
import Geometry.Vector
|
||||
import Geometry.Data
|
||||
|
||||
import Data.List
|
||||
|
||||
infixl 6 +.+.+, -.-.-
|
||||
infixl 7 *.*.*
|
||||
|
||||
@@ -56,3 +58,33 @@ magV3 (x,y,z) = sqrt $ x^i + y^i + z^i
|
||||
normalizeV3 :: Point3 -> Point3
|
||||
normalizeV3 (0,0,0) = (0,0,0)
|
||||
normalizeV3 p = (1 / magV3 p) *.*.* p
|
||||
|
||||
addZ :: Float -> Point2 -> Point3
|
||||
addZ z (x,y) = (x,y,z)
|
||||
|
||||
orderAround3
|
||||
:: Point3 -- ^ Vector to order around
|
||||
-> [Point3]
|
||||
-> [Point3]
|
||||
orderAround3 v ps = sortOn (argV . prj) ps
|
||||
where
|
||||
xdir = crossProd v (head ps)
|
||||
ydir = crossProd v xdir
|
||||
prj p = (dotV3 xdir p, dotV3 ydir p)
|
||||
|
||||
vCen3 :: [Point3] -> Point3
|
||||
vCen3 ps = (1 / fromIntegral (length ps)) *.*.* foldr (+.+.+) (0,0,0) ps
|
||||
|
||||
dotV3
|
||||
:: Point3
|
||||
-> Point3
|
||||
-> Float
|
||||
dotV3 (x,y,z) (a,b,c) = x*a + y*b + z*c
|
||||
|
||||
projV3
|
||||
:: Point3
|
||||
-> Point3
|
||||
-> Point3
|
||||
projV3 = undefined
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user