Work on gibs and chasms
This commit is contained in:
+10
-6
@@ -32,6 +32,7 @@ import Geometry.Triangulate
|
||||
import Geometry.Vector
|
||||
import Geometry.Vector3D
|
||||
import ListHelp
|
||||
import Linear.Metric
|
||||
|
||||
{- | Return a point a distance away from a first point towards a second point.
|
||||
Does not go past the second point.
|
||||
@@ -90,9 +91,9 @@ midPoint !a !b = 0.5 *.* (a +.+ b)
|
||||
-}
|
||||
circOnSegNoEndpoints :: Point2 -> Point2 -> Point2 -> Float -> Bool
|
||||
{-# INLINE circOnSegNoEndpoints #-}
|
||||
circOnSegNoEndpoints !p1 !p2 !c !rad = intersectSegSegTest p1 p2 (c -.- norm) (c +.+ norm)
|
||||
circOnSegNoEndpoints !p1 !p2 !c !rad = intersectSegSegTest p1 p2 (c -.- n) (c +.+ n)
|
||||
where
|
||||
norm = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
n = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
|
||||
{- | Test whether a circle is on a segment by intersecting a normal and testing
|
||||
the distance to the endpoints of the segment.
|
||||
@@ -103,9 +104,9 @@ circOnSeg :: Point2 -> Float -> Point2 -> Point2 -> Bool
|
||||
circOnSeg !c !rad !p1 !p2 =
|
||||
magV (p1 -.- c) <= rad
|
||||
|| magV (p2 -.- c) <= rad
|
||||
|| intersectSegSegTest p1 p2 (c -.- norm) (c +.+ norm)
|
||||
|| intersectSegSegTest p1 p2 (c -.- n) (c +.+ n)
|
||||
where
|
||||
norm = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
n = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
|
||||
{- | Test whether a segment intersects a circle by intersecting a normal and testing
|
||||
the distance to the endpoints of the segment.
|
||||
@@ -115,9 +116,9 @@ segOnCirc :: Point2 -> Point2 -> Point2 -> Float -> Bool
|
||||
segOnCirc !p1 !p2 !c !rad =
|
||||
magV (p1 -.- c) <= rad
|
||||
|| magV (p2 -.- c) <= rad
|
||||
|| intersectSegSegTest p1 p2 (c -.- norm) (c +.+ norm)
|
||||
|| intersectSegSegTest p1 p2 (c -.- n) (c +.+ n)
|
||||
where
|
||||
norm = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
n = rad *.* vNormal (normalizeV $ p1 -.- p2)
|
||||
|
||||
cylinderOnSeg :: Point3 -> Point3 -> Point3 -> Float -> Bool
|
||||
{-# INLINE cylinderOnSeg #-}
|
||||
@@ -136,6 +137,9 @@ difference x y
|
||||
reflectIn :: Point2 -> Point2 -> Point2
|
||||
reflectIn line vec = rotateV (2 * angleBetween line vec) vec
|
||||
|
||||
reflectInNormal :: Point3 -> Point3 -> Point3
|
||||
reflectInNormal n v = v - (2 * project n v)
|
||||
|
||||
-- takes an angle of entry (measured from x axis) and two wall points and gives a
|
||||
-- reflected angle (from x axis)
|
||||
reflectAngle :: Float -> Point2 -> Point2 -> Float
|
||||
|
||||
Reference in New Issue
Block a user