Module raytracer

Class Spectrum3f

All Implemented Interfaces:
Spectrum, DoubleToDouble, Serializable, 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:
  • Constructor Details

    • Spectrum3f

      public Spectrum3f()
    • Spectrum3f

      public Spectrum3f(float x, float y, float z)
  • Method Details

    • clampMinZero

      public void clampMinZero()
      Specified by:
      clampMinZero in interface Spectrum
    • 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 DoubleToDouble
      Specified by:
      evaluateDouble in interface Spectrum
      Parameters:
      nu - frequency in Hz
      Returns:
      function value at nu
    • setZero

      public void setZero()
      Description copied from interface: Spectrum
      Sets this spectrum to the zero function.
      Specified by:
      setZero in interface 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • sum

      public double sum()
      Description copied from interface: Spectrum
      Computes the spectrum sum
      Specified by:
      sum in interface Spectrum
    • getMax

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