3 /**************************************************************************
5 * Java Grande Forum Benchmark Suite - Version 2.0 *
9 * Java Grande Benchmarking Project *
13 * Edinburgh Parallel Computing Centre *
15 * email: epcc-javagrande@epcc.ed.ac.uk *
17 * Original version of this code by *
18 * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
19 * and Wilfried Klauser (wklauser@acm.org) *
21 * This version copyright (c) The University of Edinburgh, 1999. *
22 * All rights reserved. *
24 **************************************************************************/
28 public class Sphere extends Primitive
29 //implements java.io.Serializable
33 //Vec v,b; // temporary vecs used to minimize the memory load
36 public Sphere(Vec center, float radius) {
45 public float dot(float x1, float y1, float z1, float x2, float y2, float z2){
47 return x1*x2 + y1*y2 + z1*z2;
51 public Isect intersect(Ray ry) {
61 b=dot( x, y, z, ry.D.x, ry.D.y, ry.D.z);
62 disc = (float) (b*b -dot(x,y,z,x,y,z) + r2);
66 disc = (float) Math.sqrtf((float)disc);
67 t = (b - disc < 1e-6) ? b + disc : b - disc;
73 ip.enter = dot(x,y,z,x,y,z) > r2 + 1e-6 ? 1 : 0;
74 // ip.enter = Vec.dot(v, v) > r2 + 1e-6 ? 1 : 0;
81 public Vec normal(Vec p) {
88 public String toString() {
89 return "Sphere {" + c.toString() + "," + r + "}";
92 public Vec getCenter() {
95 public void setCenter(Vec c) {