gov.nist.microanalysis.NISTMonte
Class Sphere

java.lang.Object
  extended by gov.nist.microanalysis.NISTMonte.Sphere
All Implemented Interfaces:
ITransform, MonteCarloSS.Shape, TrajectoryVRML.IRender

public class Sphere
extends java.lang.Object
implements MonteCarloSS.Shape, ITransform, TrajectoryVRML.IRender

Implements the MonteCarloSS.Shape interface for a sphere.

Copyright: Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain

Company: National Institute of Standards and Technology

Version:
1.0
Author:
Nicholas W. M. Ritchie

Constructor Summary
Sphere(double[] center, double radius)
          Sphere - Constructs a Sphere object with the specified center and radius.
 
Method Summary
 boolean contains(double[] pos)
          contains - Is the specified point inside the item represented by this Shape interface? A point on the interface between two Shapes is considered to be inside both Shapes.
 double getFirstIntersection(double[] pos0, double[] pos1)
          getFirstIntersection - Consider a ray starting at pos0 towards pos1.
 double[] getInitialPoint()
          getInitialPoint - Used when Sphere represents the chamber region.
 double[] getPointAt(double phi, double theta, double frac)
          getPointAt - Returns the coordinates of the boundary point at the specified zenith (phi) and azimuthal (theta) angles.
 double getRadius()
          getRadius - Returns the sphere's radius
 void render(TrajectoryVRML.RenderContext vra, java.io.Writer wr)
          render - Renders the object.
 void rotate(double[] pivot, double phi, double theta, double psi)
          rotate - Rotate the object around the specified point by phi about the z-axis followed by theta round the y-axis followed by psi around the z-axis.
 void translate(double[] distance)
          translate - Translate this object by the distance specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere(double[] center,
              double radius)
Sphere - Constructs a Sphere object with the specified center and radius.

Parameters:
center - double[] - The x,y & z coordinates of the center of the sphere (meters)
radius - double - The radius of the sphere in meters.
Method Detail

contains

public boolean contains(double[] pos)
Description copied from interface: MonteCarloSS.Shape
contains - Is the specified point inside the item represented by this Shape interface? A point on the interface between two Shapes is considered to be inside both Shapes.

Specified by:
contains in interface MonteCarloSS.Shape
Parameters:
pos - double[] - a three item array
Returns:
boolean

getRadius

public double getRadius()
getRadius - Returns the sphere's radius

Returns:
double

getFirstIntersection

public double getFirstIntersection(double[] pos0,
                                   double[] pos1)
Description copied from interface: MonteCarloSS.Shape
getFirstIntersection - Consider a ray starting at pos0 towards pos1. If the ray does not intersect this shape return Double.MAX_VALUE. If the ray does intersect the Shape, return the u such that p(u)=pos0+u*(pos1-pos0) is the point at which the intersection occurs. If u is greater or equal to 0 but less than or equal to 1, the intersection occurs on the interval [pos0,pos1]. This indicates that a full step from pos0 to pos1 will not remain entirely inside Shape. In fact, the longest possible step is between pos0 and p(u). Intersections before pos0 (ie u<0.0) are not relevant and should be ignored. You may optimize getFirstIntersection in the case that u is greater than 1.0. Since the distance between pos0 and pos1 represents a single step and u=1.0 represents taking the full step, you may return a number greater than 1.0 but less than the real u when the real u is greater than one and it would require additional computation to discover the actual value of u.

Specified by:
getFirstIntersection in interface MonteCarloSS.Shape
Parameters:
pos0 - double[] - three element array
pos1 - double[] - three element array
Returns:
double - The fraction of the length from pos0 to pos1 at which the first intersection occurs. Otherwise Double.MAX_VALUE.

getInitialPoint

public double[] getInitialPoint()
getInitialPoint - Used when Sphere represents the chamber region. The initial point is the location of the electron gun.

Returns:
double[]

getPointAt

public double[] getPointAt(double phi,
                           double theta,
                           double frac)
getPointAt - Returns the coordinates of the boundary point at the specified zenith (phi) and azimuthal (theta) angles.

Parameters:
phi - double
theta - double
frac - double fraction of the total radius
Returns:
double[] - A spatial 3 vector

rotate

public void rotate(double[] pivot,
                   double phi,
                   double theta,
                   double psi)
Description copied from interface: ITransform
rotate - Rotate the object around the specified point by phi about the z-axis followed by theta round the y-axis followed by psi around the z-axis. These is the standard Euler angle rotation. The rotation matrix is...
[ cos(phi)*cos(th)*cos(psi)-sin(phi)*sin(psi) -sin(phi)*cos(th)*cos(psi)-cos(phi)*sin(psi) sin(th)*cos(psi) ]
[ sin(phi)*cos(psi)+cos(phi)*cos(th)*sin(psi) -sin(phi)*cos(th)*sin(psi)+cos(phi)*cos(psi) sin(th)*sin(psi) ]
[ -cos(phi)*sin(th) sin(th)*sin(phi) cos(th) ]

Specified by:
rotate in interface ITransform
Parameters:
pivot - double[] - a three-vector specifying the point around which the rotation is performed
phi - double
theta - double
psi - double

translate

public void translate(double[] distance)
Description copied from interface: ITransform
translate - Translate this object by the distance specified.

Specified by:
translate in interface ITransform
Parameters:
distance - double[] - A three-vector specifying how much to translate

render

public void render(TrajectoryVRML.RenderContext vra,
                   java.io.Writer wr)
            throws java.io.IOException
Description copied from interface: TrajectoryVRML.IRender
render - Renders the object. Use the scale translation 1.0 micrometer equals 1.0 VRML unit.

Specified by:
render in interface TrajectoryVRML.IRender
Parameters:
vra - The RenderContext object
wr - The Writer into which to output the results
Throws:
java.io.IOException