public virtual Ray getRay(double u, double v) { Vector3D direction = new Vector3D(u, v, focalLength_); direction.normalize(); return(new Ray(new Vector3D(u, v, 0), direction)); }
internal Sample(Vector3D p, Vector3D n, int depth) { pi = new Vector3D(p); ni = new Vector3D(n); ni.normalize(); irr = null; next = null; this.depth = depth; }
internal Sample(Vector3D p, Vector3D n, double r0, RGBColor irr, RGBColor[] rotGradient, RGBColor[] transGradient, int depth) { pi = new Vector3D(p); ni = new Vector3D(n); ni.normalize(); invR0 = 1.0 / r0; this.irr = new RGBColor(irr); this.rotGradient = rotGradient; this.transGradient = transGradient; this.depth = depth; next = null; }
public Triangle(Vertex v0, Vertex v1, Vertex v2) : base() { this.v0 = v0; this.v1 = v1; this.v2 = v2; ng = v1.p.subNew(v0.p).cross(v2.p.subNew(v0.p)); ng.normalize(); d = -((ng.x() * v0.p.x()) + (ng.y() * v0.p.y()) + (ng.z() * v0.p.z())); if (Math.Abs(ng.y()) > Math.Abs(ng.x())) { dropAxis = (Math.Abs(ng.z()) > Math.Abs(ng.y())) ? 2 : 1; } else { dropAxis = (Math.Abs(ng.z()) > Math.Abs(ng.x())) ? 2 : 0; } switch (dropAxis) { case 0: edge1x = v0.p.y() - v1.p.y(); edge2x = v0.p.y() - v2.p.y(); edge1y = v0.p.z() - v1.p.z(); edge2y = v0.p.z() - v2.p.z(); break; case 1: edge1x = v0.p.x() - v1.p.x(); edge2x = v0.p.x() - v2.p.x(); edge1y = v0.p.z() - v1.p.z(); edge2y = v0.p.z() - v2.p.z(); break; default: edge1x = v0.p.x() - v1.p.x(); edge2x = v0.p.x() - v2.p.x(); edge1y = v0.p.y() - v1.p.y(); edge2y = v0.p.y() - v2.p.y(); break; } double s = 1.0 / ((edge1x * edge2y) - (edge2x * edge1y)); edge1x *= s; edge1y *= s; edge2x *= s; edge2y *= s; }