Skip to content

Commit 5dbedd3

Browse files
committed
first bug fixes.
1 parent 17e2f78 commit 5dbedd3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Graphics/Implicit/ExtOpenScad/Primitives.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ polyhedron = moduleWithoutSuite "polyhedron" $ \_ _ -> do
284284
-- FIXME: use warnC here, instead of error.
285285
trianglesFromFace :: [] -> [(,,)]
286286
trianglesFromFace [p1,p2,p3] = [(p1,p2,p3)]
287-
trianglesFromFace (p1:p2:p3:xs) = ((p1,p2,p3):trianglesFromFace (p2:p3:xs))
287+
trianglesFromFace (p1:p2:p3:xs) = ((p1,p2,p3):trianglesFromFace (p1:p3:xs))
288288
trianglesFromFace ys = error $ "too few points:" <> (show ys) <> "\n"
289289

290290
cone :: (Symbol, SourcePosition -> [OVal] -> ArgParser (StateC [OVal]))

Graphics/Implicit/ObjectUtil/GetImplicit3.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ getImplicit3 _ (Polyhedron [] _) = error "Asked to find distance to an empty pol
7878
getImplicit3 _ (Polyhedron _ []) = error "Asked to find distance to an empty polygon. No tris."
7979
getImplicit3 _ (Polyhedron points tris) = \(point) ->
8080
if insideMesh triangles point
81-
then minimum $ distancePointToTriangle point <$> triangles
82-
else negate $ minimum $ distancePointToTriangle point <$> triangles
81+
then negate $ minimum $ distancePointToTriangle point <$> triangles
82+
else minimum $ distancePointToTriangle point <$> triangles
8383
where
8484
-- decompose our tris into triangles.
8585
triangles = findTriangle points <$> tris
@@ -241,6 +241,7 @@ insideMesh triangles point = odd $ length $ foundIntersection point unsafeSafeRa
241241
-- the intersection is not on the triangle (distance along vec12 out of range)
242242
| u <= 0 || u > 1 = False
243243
| v <= 0 || v > 1 = False
244+
| u + v > 1 = False
244245
| otherwise = True
245246
where
246247
-- Our edge vectors. We have picked v1 to address the space by, for convenience.
@@ -327,4 +328,4 @@ distancePointToTriangle point (virtex1, virtex2, virtex3) = distance point close
327328
dx = d4 - d3
328329
dy = d5 - d6
329330
-- The denominator.
330-
denom = 1 / va + vb + vc
331+
denom = 1 / (va + vb + vc)

0 commit comments

Comments
 (0)