@Test public void testNormalize() { Vector4 x = new Vector4(3, 4, 5, 6); Vector4 y = x.normalize(); doAssertDouble(0.323, y.x); doAssertDouble(0.431, y.y); doAssertDouble(1, y.length()); }
/** * Call the shader to determine the color a the point of intersection determined by the ray and * parameter minT * * @param ray ray that determines the point * @param minT value of parameter t * @return Colour determined by the shader for this point */ public Colour callShader(Ray ray, double minT) { Point point = ray.evaluate(minT); Vector4 normal = new Vector4(center, point); normal.normalize(); return Shader.computeColor(point, normal, material); }
/** * Returns the normal of the sphere at point p. Point p is assumed to be at the surface of the * sphere * * @param p point at the surface * @return normal at point p */ public Vector4 computeNormal(Point p) { Vector4 normal = new Vector4(center, p); normal.normalize(); return normal; }