diff --git a/labs/3/renderSuite/Sphere.java b/labs/3/renderSuite/Sphere.java index 63ed2b6..054cbfa 100644 --- a/labs/3/renderSuite/Sphere.java +++ b/labs/3/renderSuite/Sphere.java @@ -4,8 +4,7 @@ import renderSuite.Vec3; import renderSuite.Util; import renderSuite.Ray; -public class Sphere { - Vec3 p, c; +public class Sphere extends Surface { double r; public Sphere(Vec3 position, Vec3 color, double radius) { diff --git a/labs/3/renderSuite/Surface.java b/labs/3/renderSuite/Surface.java new file mode 100644 index 0000000..bd51fdd --- /dev/null +++ b/labs/3/renderSuite/Surface.java @@ -0,0 +1,39 @@ +package renderSuite; + +import renderSuite.Vec3; +//import renderSuite.Util; +//import renderSuite.Ray; + +public class Surface { + Vec3 p, c; + + public void main() { + + } + + /* + public boolean intersect(Ray r) { + // OLD + //double dist = Util.d(ray_position, position); + //return (Util.d(ray_position, position) <= radius); + + // using RTX + Vec3 l = new Vec3(this.p.x - r.p.x, + this.p.y - r.p.y, + this.p.z - r.p.z); + + Vec3 nl = l.get_norm(); + double cosine = Util.dot(r.f, nl); + + // >90 degrees = no intersection + if (cosine < 0) { + return false; + } + + double tc = l.len() * cosine; + double d = Math.sqrt( l.len()*l.len() - tc*tc ); + + return (d < this.r); + } + */ +}