|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
package eu.jonahbauer.raytracing.render.spectral.colors;
|
|
|
|
|
|
|
|
|
|
import eu.jonahbauer.raytracing.math.IVec3;
|
|
|
|
|
import eu.jonahbauer.raytracing.math.Vec3;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
import static eu.jonahbauer.raytracing.Main.DEBUG;
|
|
|
|
|
|
|
|
|
|
public record ColorRGB(double r, double g, double b) implements IVec3<ColorRGB> {
|
|
|
|
|
public static final @NotNull ColorRGB BLACK = new ColorRGB(0.0, 0.0, 0.0);
|
|
|
|
|
public static final @NotNull ColorRGB WHITE = new ColorRGB(1.0, 1.0, 1.0);
|
|
|
|
@ -34,9 +31,9 @@ public record ColorRGB(double r, double g, double b) implements IVec3<ColorRGB>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ColorRGB {
|
|
|
|
|
if (DEBUG && (!Double.isFinite(r) || !Double.isFinite(g) || !Double.isFinite(b))) {
|
|
|
|
|
throw new IllegalArgumentException("r, g and b must be finite");
|
|
|
|
|
}
|
|
|
|
|
assert Double.isFinite(r) : "r must be finite";
|
|
|
|
|
assert Double.isFinite(g) : "g must be finite";
|
|
|
|
|
assert Double.isFinite(b) : "b must be finite";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -103,19 +100,6 @@ public record ColorRGB(double r, double g, double b) implements IVec3<ColorRGB>
|
|
|
|
|
return new ColorRGB(r * other.r, g * other.g, b * other.b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Vec3
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public @NotNull Vec3 toVec3() {
|
|
|
|
|
return new Vec3(r, g, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static @NotNull ColorRGB fromVec3(@NotNull Vec3 vec) {
|
|
|
|
|
return new ColorRGB(vec.x(), vec.y(), vec.z());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Accessors
|
|
|
|
|
*/
|
|
|
|
|