Remove ssaTri, bullet movement is broken
This commit is contained in:
+1
-43
@@ -164,55 +164,13 @@ diffAngles x y
|
||||
| otherwise = diffAngles (x + 2*pi) y
|
||||
where
|
||||
diff = x-y
|
||||
-- | Given a triangle where we know the length of a first side,
|
||||
-- the length of a second side, and the angle between the first side and the
|
||||
-- third side, finds the length of the third side.
|
||||
-- Note this doesn't necessarily find ALL solutions, asin is a map not a function.
|
||||
ssaTri :: Float -> Float -> Float -> Float
|
||||
ssaTri ab bc a
|
||||
| sin a == 0 = ab - bc
|
||||
| bc == 0 = ab
|
||||
| otherwise =
|
||||
let c = asin ( (ab * sin a)/bc)
|
||||
b = pi - (a + c)
|
||||
in sin b * bc / sin a
|
||||
-- | Given two points of a triangle and a third point, return
|
||||
-- the point which lies between pa and pc' on a line from pb of length bc.
|
||||
-- Note that there are likely two such points, this should return the point
|
||||
-- closer to pc'.
|
||||
-- TODO this still causes errors, should be made error free
|
||||
ssaTriPoint :: Point2 -> Point2 -> Point2 -> Float -> Point2
|
||||
ssaTriPoint pa pb pc' bc
|
||||
= let ab = magV (pa -.- pb)
|
||||
a = errorAngleVV 6 (pb -.- pa) (pc' -.- pa)
|
||||
ac = ssaTri ab bc a
|
||||
in pa +.+ (ac *.* errorNormalizeV 47 (pc' -.- pa))
|
||||
-- | Safe version of 'ssaTriPoint'.
|
||||
--ssaTriPoint' :: Point2 -> Point2 -> Point2 -> Float -> Maybe Point2
|
||||
--ssaTriPoint' pa pb pc' bc
|
||||
-- | dist pb (closestPointOnSeg pa pc' pb) >= bc
|
||||
-- = Nothing
|
||||
-- | otherwise
|
||||
-- = Just $ ssaTriPoint pa pb pc' bc
|
||||
-- | Return Just a point if it is inside a circle, Nothing otherwise.
|
||||
pointInCircle :: Point2 -> Float -> Point2 -> Maybe Point2
|
||||
pointInCircle p r c
|
||||
| p == c = Just p
|
||||
| magV (p -.- c) < r = Just p
|
||||
| otherwise = Nothing
|
||||
-- | Determines if a moving point intersects with a circle,
|
||||
-- if so, returns a point on circle that intersects with the line passing
|
||||
-- throught the circle : HOPEFULLY THE CORRECT OF THE TWO!
|
||||
--collidePointCirc :: Point2 -> Point2 -> Float -> Point2 -> Maybe Point2
|
||||
--collidePointCirc p1 p2 rad c = ssaTriPoint' p2 c p1 rad
|
||||
-- | As 'collidePointCirc', but changes the point to a measure of the distance.
|
||||
--collidePointCirc' :: Point2 -> Point2 -> Float -> Point2 -> Maybe Float
|
||||
--collidePointCirc' p1 p2 rad c = fmap (\x -> magV (x -.- p1))
|
||||
-- (collidePointCirc p1 p2 rad c)
|
||||
-- | As 'collidePointCirc', but returns both the point and the measure of the distance.
|
||||
--collidePointCirc'' :: Point2 -> Point2 -> Float -> Point2 -> Maybe (Point2,Float)
|
||||
--collidePointCirc'' p1 p2 rad c = (,) <$> collidePointCirc p1 p2 rad c
|
||||
-- <*> collidePointCirc' p1 p2 rad c
|
||||
|
||||
-- | Finds the height of a triangle using herons formula.
|
||||
-- The base is the line between the first two points.
|
||||
heron :: Point2 -> Point2 -> Point2 -> Float
|
||||
|
||||
Reference in New Issue
Block a user