1 /**************************************************************************
3 * Java Grande Forum Benchmark Suite - Version 2.0 *
7 * Java Grande Benchmarking Project *
11 * Edinburgh Parallel Computing Centre *
13 * email: epcc-javagrande@epcc.ed.ac.uk *
15 * Original version of this code by *
16 * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
17 * and Wilfried Klauser (wklauser@acm.org) *
19 * This version copyright (c) The University of Edinburgh, 1999. *
20 * All rights reserved. *
22 **************************************************************************/
26 public class Sphere extends Primitive
27 //implements java.io.Serializable
31 //Vec v,b; // temporary vecs used to minimize the memory load
34 public Sphere(Vec center, float radius) {
43 public float dot(float x1, float y1, float z1, float x2, float y2, float z2){
45 return x1*x2 + y1*y2 + z1*z2;
49 public Isect intersect(Ray ry) {
59 b=dot( x, y, z, ry.D.x, ry.D.y, ry.D.z);
60 disc = (float) (b*b -dot(x,y,z,x,y,z) + r2);
64 disc = (float) Math.sqrtf((float)disc);
65 t = (b - disc < 1e-6) ? b + disc : b - disc;
71 ip.enter = dot(x,y,z,x,y,z) > r2 + 1e-6 ? 1 : 0;
72 // ip.enter = Vec.dot(v, v) > r2 + 1e-6 ? 1 : 0;
79 public Vec normal(Vec p) {
86 public String toString() {
87 return "Sphere {" + c.toString() + "," + r + "}";
90 public Vec getCenter() {
93 public void setCenter(Vec c) {