Package lighting

Class Spotlight

java.lang.Object
Direct Known Subclasses:
NarrowSpotlight

public class Spotlight
extends PointLight
This class is represents an directional light source that attenuates with respect to distance.
  • Field Summary

    Fields inherited from class lighting.Light

    colour
  • Constructor Summary

    Constructors
    Constructor Description
    Spotlight​(Colour colour, Point position, NormalizedVector direction, double q, double l, double c)
    Construct a Spotlight from a Colour, a direction, and 3 doubles that represent the attenuation constants.
  • Method Summary

    Modifier and Type Method Description
    Colour colourAt​(Point point)
    Calculate the colour of the light that this light source is projecting onto a given point.
    protected double factor​(Point point)
    Calculate the factor by which to scale the colour at a given point, based on the direction of the spotlight.

    Methods inherited from class lighting.PointLight

    squareDistance, vectorTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Spotlight

      public Spotlight​(Colour colour, Point position, NormalizedVector direction, double q, double l, double c)
      Construct a Spotlight from a Colour, a direction, and 3 doubles that represent the attenuation constants.
      Parameters:
      colour - The colour of the light
      position - The position in space of the light source
      direction - The direction of the spot light
      q - The quadratic factor
      l - The linear factor
      c - The constant factor
  • Method Details

    • colourAt

      public Colour colourAt​(Point point)
      Calculate the colour of the light that this light source is projecting onto a given point.
      Overrides:
      colourAt in class PointLight
      Parameters:
      point - The point at which to calculate the colour of the light.
      Returns:
      The colour of the light at the given point.
    • factor

      protected double factor​(Point point)
      Calculate the factor by which to scale the colour at a given point, based on the direction of the spotlight.
      Parameters:
      point - The intersection point of the light at which to calculate the factor.
      Returns:
      The factor to scale the colour at a point.