From cb4dcc53f14614a434429cfcde23bdee94414b59 Mon Sep 17 00:00:00 2001 From: jbb01 <32650546+jbb01@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:31:20 +0200 Subject: [PATCH] fix a bug in PdfUtil#getSolidAngle --- src/main/java/eu/jonahbauer/raytracing/scene/util/PdfUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } }