|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package eu.jonahbauer.raytracing.scene.hittable2d;
|
|
|
|
|
|
|
|
|
|
import eu.jonahbauer.raytracing.math.AABB;
|
|
|
|
|
import eu.jonahbauer.raytracing.math.Range;
|
|
|
|
|
import eu.jonahbauer.raytracing.math.Ray;
|
|
|
|
|
import eu.jonahbauer.raytracing.math.Vec3;
|
|
|
|
|
import eu.jonahbauer.raytracing.render.material.Material;
|
|
|
|
@ -33,10 +32,11 @@ public final class Parallelogram extends Hittable2D implements Target {
|
|
|
|
|
public double getProbabilityDensity(@NotNull Vec3 origin, @NotNull Vec3 direction) {
|
|
|
|
|
if (Double.isNaN(hit0(new Ray(origin, direction), FORWARD))) return 0;
|
|
|
|
|
|
|
|
|
|
var a = this.origin.minus(origin).unit();
|
|
|
|
|
var b = this.origin.plus(u).minus(origin).unit();
|
|
|
|
|
var c = this.origin.plus(v).minus(origin).unit();
|
|
|
|
|
var d = this.origin.plus(u).plus(v).minus(origin).unit();
|
|
|
|
|
var o = this.origin.minus(origin);
|
|
|
|
|
var a = o.unit();
|
|
|
|
|
var b = o.plus(u).unit();
|
|
|
|
|
var c = o.plus(v).unit();
|
|
|
|
|
var d = o.plus(u).plus(v).unit();
|
|
|
|
|
var angle = PdfUtil.getSolidAngle(a, b, d) + PdfUtil.getSolidAngle(c, b, d);
|
|
|
|
|
return 1 / angle;
|
|
|
|
|
}
|
|
|
|
@ -45,6 +45,6 @@ public final class Parallelogram extends Hittable2D implements Target {
|
|
|
|
|
public @NotNull Vec3 getTargetingDirection(@NotNull Vec3 origin, @NotNull RandomGenerator random) {
|
|
|
|
|
var alpha = random.nextDouble();
|
|
|
|
|
var beta = random.nextDouble();
|
|
|
|
|
return this.origin.plus(u.times(alpha)).plus(v.times(beta)).minus(origin);
|
|
|
|
|
return get(alpha, beta).minus(origin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|