Module raytracer

Class Collector3dDirectDiffuse

All Implemented Interfaces:
Collector, Spectrum, DoubleToDouble, Serializable, Cloneable

public class Collector3dDirectDiffuse extends Collector3d
A Collector3d that separates incoming rays into direct (first-order, depth == 0) and diffuse (higher-order, depth > 0) contributions.

The combined statistics of all rays are maintained by the parent Collector3d; getDirect() and getDiffuse() give access to the per-category sub-collectors.

Author:
MH at YNL 2026 (based on Collector3dList by adge-k)
See Also:
  • Constructor Details

    • Collector3dDirectDiffuse

      public Collector3dDirectDiffuse()
      Creates an empty instance in spectrum mode.
    • Collector3dDirectDiffuse

      public Collector3dDirectDiffuse(double x, double y, double z)
      Creates an instance initialised with the given RGB spectrum values.
      Parameters:
      x - red component
      y - green component
      z - blue component
    • Collector3dDirectDiffuse

      public Collector3dDirectDiffuse(Spectrum spectrum)
      Creates an instance initialised from the given spectrum.
      Parameters:
      spectrum - initial spectrum to accumulate
  • Method Details

    • addToStatistic

      public void addToStatistic(Tuple3d rayOrigin, Spectrum3d spectrum, double scaleFactor, boolean isPrimary)
      Description copied from class: Collector3d
      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.
      Overrides:
      addToStatistic in class Collector3d
      Parameters:
      rayOrigin - Where the light comes from.
    • scaleAll

      public void scaleAll(double factor)
      Description copied from class: Collector3d
      Scales the spectral power (x/y/z) AND all accumulated statistics by factor. Must be used instead of Tuple3d.scale(double) whenever the statistics should remain consistent with the scaled spectral values. Linear sums scale by factor; square sums scale by factor * factor.
      Overrides:
      scaleAll in class Collector3d
    • add

      public void add(Spectrum collector)
      Description copied from class: Collector3d
      Add the newSpectrum to the spectrum of this Collector-instance and update the statistics.
      Specified by:
      add in interface Spectrum
      Overrides:
      add in class Collector3d
      Parameters:
      collector - the spectrum to add
    • getDirect

      public Collector3d getDirect()
      Returns a clone of the direct (first-order) sub-collector.
    • getDiffuse

      public Collector3d getDiffuse()
      Returns a clone of the diffuse (higher-order) sub-collector.
    • setZero

      public void setZero()
      Description copied from class: Collector3d
      Sets all values the instance to zero. Useful when the instance is still used as container for information/ results of the
      invalid reference
      LightModel
      computation.
      Specified by:
      setZero in interface Spectrum
      Overrides:
      setZero in class Collector3d
    • newInstance

      public Collector3dDirectDiffuse newInstance()
      Description copied from class: Collector3d
      Returns a new instance of this class.
      Specified by:
      newInstance in interface Collector
      Specified by:
      newInstance in interface Spectrum
      Overrides:
      newInstance in class Collector3d
      Returns:
      new instance of same class
    • clone

      public Collector3dDirectDiffuse clone()
      Description copied from class: Collector3d
      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 Collector3d
      Returns:
      Copy of this instance.