de.grogra.ray.physics
Class Spectrum3f

java.lang.Object
  extended by javax.vecmath.Tuple3f
      extended by javax.vecmath.Color3f
          extended by de.grogra.ray.physics.Spectrum3f
All Implemented Interfaces:
Spectrum, DoubleToDouble, java.io.Serializable, java.lang.Cloneable

public class Spectrum3f
extends Color3f
implements Spectrum

This class implements a spectrum which is represented by three float values which are interpreted as the red, green and blue part of the spectrum. Specta of this class are compatible with each other and with spectra of class Spectrum3d.

Author:
Ole Kniemeyer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.vecmath.Tuple3f
x, y, z
 
Constructor Summary
Spectrum3f()
           
Spectrum3f(float x, float y, float z)
           
 
Method Summary
 void add(Spectrum s)
          Adds the function spec to this function.
 void clampMinZero()
           
 Spectrum3f clone()
          Returns a clone of this spectrum.
 void div(Spectrum s)
          Performs an componentwise division of this spectrum by spec.
 void div(Tuple3d t)
          Performs a pointwise division of this spectrum by the given RGB spectum factor.
 void div(Tuple3f t)
          Performs a pointwise division of this spectrum by the given RGB spectum factor.
 void dot(Spectrum s, Tuple3d out)
          Computes the scalar product of this spectrum with spec, i.e., the integral of the pointwise product of both spectra over all frequencies.
 double evaluateDouble(double nu)
          Evaluates the spectrum at frequency nu (measured in Hz).
 void get(Tuple3d out)
          Computes the RGB spectrum color for this spectrum.
 double getMax()
           
 double integrate()
          Returns the integral over all frequencies of this spectrum.
 void mul(Spectrum s)
          Performs an componentwise multiplication of this spectrum by spec.
 void mul(Tuple3d t)
          Performs a pointwise multiplication of this spectrum by the given RGB spectum factor.
 void mul(Tuple3f t)
          Performs a pointwise multiplication of this spectrum by the given RGB spectum factor.
 Spectrum3f newInstance()
          Returns a new instance of the class of this spectrum.
 void scale(double factor)
          Scales this spectrum by the given factor.
 void set(Spectrum s)
          Sets this spectrum to spec.
 void setIdentity()
          Sets this spectrum to the identity, i.e., its value is 1 everywhere.
 void setZero()
          Sets this spectrum to the zero function.
 void sub(Spectrum s)
          Subtracts the function spec from this function.
 double sum()
          Computes the spectrum sum
 
Methods inherited from class javax.vecmath.Color3f
get, set
 
Methods inherited from class javax.vecmath.Tuple3f
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, epsilonEquals, equals, equals, get, get, hashCode, interpolate, interpolate, 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
get, set, set
 

Constructor Detail

Spectrum3f

public Spectrum3f()

Spectrum3f

public Spectrum3f(float x,
                  float y,
                  float z)
Method Detail

add

public void add(Spectrum s)
Description copied from interface: Spectrum
Adds the function spec to this function. spec has to be compatible with this spectrum (usually this means that it has to be of the same class).

Specified by:
add in interface Spectrum
Parameters:
s - the spectrum to add

clampMinZero

public void clampMinZero()
Specified by:
clampMinZero in interface Spectrum

clone

public Spectrum3f clone()
Description copied from interface: Spectrum
Returns a clone of this spectrum.

Specified by:
clone in interface Spectrum
Overrides:
clone in class Color3f
Returns:
clone of this spectrum

div

public void div(Spectrum s)
Description copied from interface: Spectrum
Performs an componentwise division of this spectrum by spec. spec has to be compatible with this spectrum (usually this means that it has to be of the same class). The result of each component is stored in this spectrum. Note that a factor with 0 causes a ArithmeticException

Specified by:
div in interface Spectrum
Parameters:
s - the spectrum to divide with

div

public void div(Tuple3d t)
Description copied from interface: Spectrum
Performs a pointwise division of this spectrum by the given RGB spectum factor. Note that a factor with 0 causes a ArithmeticException

Specified by:
div in interface Spectrum
Parameters:
t - the divisor

div

public void div(Tuple3f t)
Description copied from interface: Spectrum
Performs a pointwise division of this spectrum by the given RGB spectum factor. Note that a factor with 0 causes a ArithmeticException

Specified by:
div in interface Spectrum
Parameters:
t - the divisor

dot

public void dot(Spectrum s,
                Tuple3d out)
Description copied from interface: Spectrum
Computes the scalar product of this spectrum with spec, i.e., the integral of the pointwise product of both spectra over all frequencies. The integration is split into three parts: The first part ranges over the red part of the spectrum, its result is stored in out.x. The second part ranges over the green part of the spectrum and is stored in out.y, the third part ranges over the blue part and is stored in out.z.

Specified by:
dot in interface Spectrum
Parameters:
s - another spectrum
out - result of dot product, split into three integration domains

evaluateDouble

public double evaluateDouble(double nu)
Description copied from interface: Spectrum
Evaluates the spectrum at frequency nu (measured in Hz).

Specified by:
evaluateDouble in interface Spectrum
Specified by:
evaluateDouble in interface DoubleToDouble
Parameters:
nu - frequency in Hz
Returns:
function value at nu

get

public void get(Tuple3d out)
Description copied from interface: Spectrum
Computes the RGB spectrum color for this spectrum.

Specified by:
get in interface Spectrum
Parameters:
out - RGB spectrum will be placed in here

getMax

public double getMax()
Specified by:
getMax in interface Spectrum

integrate

public double integrate()
Description copied from interface: Spectrum
Returns the integral over all frequencies of this spectrum.

Specified by:
integrate in interface Spectrum
Returns:
integrated spectrum over all frequencies

mul

public void mul(Spectrum s)
Description copied from interface: Spectrum
Performs an componentwise multiplication of this spectrum by spec. spec has to be compatible with this spectrum (usually this means that it has to be of the same class). The result of each component is stored in this spectrum.

Specified by:
mul in interface Spectrum
Parameters:
s - the spectrum to multiply with

mul

public void mul(Tuple3d t)
Description copied from interface: Spectrum
Performs a pointwise multiplication of this spectrum by the given RGB spectum factor.

Specified by:
mul in interface Spectrum
Parameters:
t - the multiplicator

mul

public void mul(Tuple3f t)
Description copied from interface: Spectrum
Performs a pointwise multiplication of this spectrum by the given RGB spectum factor.

Specified by:
mul in interface Spectrum
Parameters:
t - the multiplicator

newInstance

public Spectrum3f newInstance()
Description copied from interface: Spectrum
Returns a new instance of the class of this spectrum. It is initialized to the zero function.

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

scale

public void scale(double factor)
Description copied from interface: Spectrum
Scales this spectrum by the given factor.

Specified by:
scale in interface Spectrum
Parameters:
factor - scaling factor

set

public void set(Spectrum s)
Description copied from interface: Spectrum
Sets this spectrum to spec. spec has to be compatible with this spectrum (usually this means that it has to be of the same class).

Specified by:
set in interface Spectrum
Parameters:
s - another spectrum

setIdentity

public void setIdentity()
Description copied from interface: Spectrum
Sets this spectrum to the identity, i.e., its value is 1 everywhere.

Specified by:
setIdentity in interface Spectrum

setZero

public void setZero()
Description copied from interface: Spectrum
Sets this spectrum to the zero function.

Specified by:
setZero in interface Spectrum

sub

public void sub(Spectrum s)
Description copied from interface: Spectrum
Subtracts the function spec from this function. spec has to be compatible with this spectrum (usually this means that it has to be of the same class).

Specified by:
sub in interface Spectrum
Parameters:
s - the spectrum to subtract

sum

public double sum()
Description copied from interface: Spectrum
Computes the spectrum sum

Specified by:
sum in interface Spectrum