use of suite.rt.RayTracer.RayIntersection in project suite by stupidsing.
the class Plane method hit.
@Override
public List<RayHit> hit(Ray ray) {
double denum = R3.dot(normal, ray.dir);
double adv;
if (MathUtil.epsilon < Math.abs(denum))
adv = (originIndex - R3.dot(normal, ray.startPoint)) / denum;
else
// treats as not-hit
adv = -1d;
double advance = adv;
if (RayTracer.negligibleAdvance < advance) {
RayHit rayHit = new RayHit() {
public double advance() {
return advance;
}
public RayIntersection intersection() {
R3 hitPoint = ray.hitPoint(advance);
return new RayIntersection() {
public R3 hitPoint() {
return hitPoint;
}
public R3 normal() {
return normal;
}
public Material material() {
return material;
}
};
}
};
return List.of(rayHit);
} else
return List.of();
}
Aggregations