Package lighting

Class LightSource

java.lang.Object
lighting.Light
lighting.LightSource
Direct Known Subclasses:
DirectionalLight, PointLight

public abstract class LightSource
extends Light
Abstract base class for all lights which have a source.
  • Field Summary

    Fields inherited from class lighting.Light

    colour
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected LightSource​(Colour colour)
    Set the colour of the light source.
  • Method Summary

    Modifier and Type Method Description
    abstract Colour colourAt​(Point point)
    Calculate the colour of the light that this light source is projecting onto a given point.
    abstract double squareDistance​(Point point)
    Return the squared distance between the light source and the given point.
    abstract NormalizedVector vectorTo​(Point point)
    Calculate a NormalizedVector from the source of the light to the given point.

    Methods inherited from class java.lang.Object

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

    • LightSource

      protected LightSource​(Colour colour)
      Set the colour of the light source.
      Parameters:
      colour - The colour of the light source.
  • Method Details

    • colourAt

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

      public abstract NormalizedVector vectorTo​(Point point)
      Calculate a NormalizedVector from the source of the light to the given point.
      Parameters:
      point - The point the vector will point to from the light source.
      Returns:
      The normalized vector from the light source to the given point.
    • squareDistance

      public abstract double squareDistance​(Point point)
      Return the squared distance between the light source and the given point.
      Parameters:
      point - The point whose squared distance from the light source is to be calculated.
      Returns:
      The square of the distance between the light source and the given point.