de.grogra.ray.physics
Class Collector3d

java.lang.Object
  extended by javax.vecmath.Tuple3d
      extended by de.grogra.ray.physics.Spectrum3d
          extended by de.grogra.ray.physics.Collector3d
All Implemented Interfaces:
Collector, Spectrum, DoubleToDouble, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Collector3dList

public class Collector3d
extends Spectrum3d
implements Collector, java.io.Serializable

This class stores some useful information about incoming rays of an corresponding object, which has received a certain ray. This class extended all properties of Spectrum3d. It means that this Collector is also a Spectrum.

Author:
Stephan Rogge
See Also:
Serialized Form

Field Summary
protected  boolean asCollector
           
protected  long rayCount
           
protected  double squareSumDirectionX
           
protected  double squareSumDirectionY
           
protected  double squareSumDirectionZ
           
protected  double squareSumSpectrumX
           
protected  double squareSumSpectrumY
           
protected  double squareSumSpectrumZ
           
protected  double sumDirectionX
           
protected  double sumDirectionY
           
protected  double sumDirectionZ
           
protected  double sumSpectrumX
           
protected  double sumSpectrumY
           
protected  double sumSpectrumZ
           
 
Fields inherited from class javax.vecmath.Tuple3d
x, y, z
 
Constructor Summary
Collector3d()
          Just a new instance of this class.
Collector3d(double x, double y, double z)
          This constructor creates a Collector-instance with a certain Spectrum.
Collector3d(Spectrum spectrum)
          This constructor creates a Collector-instance with a certain Spectrum.
 
Method Summary
 void add(Collector col)
          To combine two Collector-instances.
 void add(Spectrum spectrum)
          Add the newSpectrum to the spectrum of this Collector-instance and update the statistics.
 void addToStatistic(Tuple3d rayOrigin, Spectrum3d spectrum, double scaleFactor, boolean isPrimary)
          Add the Vector of the origin of a certain ray, which hits the object for this corresponding Collector-instance.
 void addToStatistic(Tuple3d rayOrigin, Spectrum spectrum, double scaleFactor, boolean isPrimary)
          Here the information of LightModel computation are stored.
 Collector3d clone()
          Creates a copy of the Spectrum or a deep-copy of this instance.
 void getCollectedValues(Tuple3d sumDir, Tuple3d sumSquareDir, Tuple3d sumSpec, Tuple3d sumSquareSpec)
           
 void getDirectionArithmeticMean(Tuple3d tuple)
          Set the arithmetic mean of all directions (not normalized) to vector.
 void getDirectionArithmeticMean(Tuple3f tuple)
           
 void getDirectionVariance(Tuple3d tuple)
          This methods returns the variance of the light-direction (not normalized).
 void getDirectionVariance(Tuple3f tuple)
           
 long getRayCount()
          Returns the number of rays which hit the corresponding object of this instance.
 void getSpectrumArithmeticMean(Spectrum spectrum)
          Set the arithmetic mean of all spectra to spectrum.
 void getSpectrumVariance(Spectrum spectrum)
          This methods returns the variance of the spectrums.
 boolean isCollector()
          If the collector should works like a Spectrum, this method returns false, otherwise true.
 Collector3d newInstance()
          Returns a new instance of this class.
static void normalize(Tuple3d t)
           
static void normalize(Tuple3f t)
           
 void setAsCollector()
          The initial value of asCollector is false.
 void setZero()
          Sets all values the instance to zero.
 
Methods inherited from class de.grogra.ray.physics.Spectrum3d
clampMinZero, div, div, div, dot, evaluateDouble, get, getMax, integrate, mul, mul, mul, set, setIdentity, sub, sum
 
Methods inherited from class javax.vecmath.Tuple3d
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, epsilonEquals, equals, equals, get, get, hashCode, interpolate, interpolate, max, min, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, sub, sub, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.ray.physics.Spectrum
clampMinZero, div, div, div, dot, evaluateDouble, get, get, getMax, integrate, mul, mul, mul, scale, set, set, set, setIdentity, sub, sum
 

Field Detail

asCollector

protected boolean asCollector

rayCount

protected long rayCount

squareSumDirectionX

protected double squareSumDirectionX

squareSumDirectionY

protected double squareSumDirectionY

squareSumDirectionZ

protected double squareSumDirectionZ

squareSumSpectrumX

protected double squareSumSpectrumX

squareSumSpectrumY

protected double squareSumSpectrumY

squareSumSpectrumZ

protected double squareSumSpectrumZ

sumDirectionX

protected double sumDirectionX

sumDirectionY

protected double sumDirectionY

sumDirectionZ

protected double sumDirectionZ

sumSpectrumX

protected double sumSpectrumX

sumSpectrumY

protected double sumSpectrumY

sumSpectrumZ

protected double sumSpectrumZ
Constructor Detail

Collector3d

public Collector3d()
Just a new instance of this class.


Collector3d

public Collector3d(double x,
                   double y,
                   double z)
This constructor creates a Collector-instance with a certain Spectrum.

Parameters:
x - Red-component of Spectrum3d
y - Green-component of Spectrum3d
z - Blue-component of Spectrum3d

Collector3d

public Collector3d(Spectrum spectrum)
This constructor creates a Collector-instance with a certain Spectrum.

Parameters:
spectrum - Spectrum, which is used by the LightModel
Method Detail

add

public void add(Collector col)
To combine two Collector-instances. All values of col added to the values of this instance.

Specified by:
add in interface Collector
Parameters:
col - To added Collector-instance.

add

public void add(Spectrum spectrum)
Add the newSpectrum to the spectrum of this Collector-instance and update the statistics.

Specified by:
add in interface Spectrum
Overrides:
add in class Spectrum3d
Parameters:
newSpectrum - New to added spectrum.

addToStatistic

public void addToStatistic(Tuple3d rayOrigin,
                           Spectrum3d spectrum,
                           double scaleFactor,
                           boolean isPrimary)
Add the Vector of the origin of a certain ray, which hits the object for this corresponding Collector-instance. Notice: The direction and the weight of the direction doesn't depends on the absorbed power but on the intensity of the incoming ray.

Parameters:
rayOrigin - Where the light comes from.
scale - The factor for weighting this direction (usually intensity of incoming light)

addToStatistic

public void addToStatistic(Tuple3d rayOrigin,
                           Spectrum spectrum,
                           double scaleFactor,
                           boolean isPrimary)
Description copied from interface: Collector
Here the information of LightModel computation are stored.

Specified by:
addToStatistic in interface Collector
Parameters:
rayOrigin - May this contains a certain vector (direction for example).
spectrum - To added Spectrum.
scaleFactor - For the added Spectrum.
isPrimary - To distinguish from primary or secondary rays.

clone

public Collector3d clone()
Creates a copy of the Spectrum or a deep-copy of this instance.

Specified by:
clone in interface Collector
Specified by:
clone in interface Spectrum
Overrides:
clone in class Spectrum3d
Returns:
Copy of this instance.

getCollectedValues

public void getCollectedValues(Tuple3d sumDir,
                               Tuple3d sumSquareDir,
                               Tuple3d sumSpec,
                               Tuple3d sumSquareSpec)
Specified by:
getCollectedValues in interface Collector

getDirectionArithmeticMean

public void getDirectionArithmeticMean(Tuple3d tuple)
Set the arithmetic mean of all directions (not normalized) to vector. The parameter vector should be initialized before.

Specified by:
getDirectionArithmeticMean in interface Collector
Parameters:
vector - Returns the arithmetic mean of all direction for this Collector-instance.

getDirectionArithmeticMean

public void getDirectionArithmeticMean(Tuple3f tuple)

getDirectionVariance

public void getDirectionVariance(Tuple3d tuple)
This methods returns the variance of the light-direction (not normalized). The calculation for this is: sigma^2 = 1/N * ((sum of all directions^2) - (N * x^2)) N ... The number of rays x ... The arithmetic mean of all direction To get the standard deviation, just extract the root of the variance. For more information see .

Specified by:
getDirectionVariance in interface Collector

getDirectionVariance

public void getDirectionVariance(Tuple3f tuple)

getRayCount

public long getRayCount()
Returns the number of rays which hit the corresponding object of this instance.

Specified by:
getRayCount in interface Collector
Returns:
Number of rays.

getSpectrumArithmeticMean

public void getSpectrumArithmeticMean(Spectrum spectrum)
Set the arithmetic mean of all spectra to spectrum. The parameter spectrum should be initialized before.

Specified by:
getSpectrumArithmeticMean in interface Collector
Parameters:
spectrum - Returns the arithmetic mean of all spectra for this Collector-instance.

getSpectrumVariance

public void getSpectrumVariance(Spectrum spectrum)
This methods returns the variance of the spectrums. The calculation for this is: sigma^2 = 1/N * ((sum of all spectra^2) - (N * x^2)) N ... The number of rays x ... The arithmetic mean of all direction To get the standard deviation, just extract the root of the variance. For more information see .

Specified by:
getSpectrumVariance in interface Collector

isCollector

public boolean isCollector()
If the collector should works like a Spectrum, this method returns false, otherwise true.

Specified by:
isCollector in interface Collector
Returns:

newInstance

public Collector3d newInstance()
Returns a new instance of this class.

Specified by:
newInstance in interface Collector
Specified by:
newInstance in interface Spectrum
Overrides:
newInstance in class Spectrum3d
Returns:
new instance of same class

normalize

public static void normalize(Tuple3d t)

normalize

public static void normalize(Tuple3f t)

setAsCollector

public void setAsCollector()
The initial value of asCollector is false. It means that the collector works like a Spectrum. Thats useful when this Collector-instance is used for the calculations in LightModel.

Specified by:
setAsCollector in interface Collector

setZero

public void setZero()
Sets all values the instance to zero. Useful when the instance is still used as container for information/ results of the LightModel computation.

Specified by:
setZero in interface Spectrum
Overrides:
setZero in class Spectrum3d