diff --git a/src/main/java/eu/jonahbauer/raytracing/scene/util/PdfUtil.java b/src/main/java/eu/jonahbauer/raytracing/scene/util/PdfUtil.java index efead20..09c0d4f 100644 --- a/src/main/java/eu/jonahbauer/raytracing/scene/util/PdfUtil.java +++ b/src/main/java/eu/jonahbauer/raytracing/scene/util/PdfUtil.java @@ -13,6 +13,7 @@ public final class PdfUtil { var j = b.minus(o).unit(); var k = c.minus(o).unit(); - return 2 * Math.atan(Math.abs(i.times(j.cross(k))) / (1 + i.times(j) + j.times(k) + k.times(i))); + var angle = 2 * Math.atan(Math.abs(i.times(j.cross(k))) / (1 + i.times(j) + j.times(k) + k.times(i))); + return angle < 0 ? 2 * Math.PI + angle : angle; } }