Package lighting

Class PointLight

java.lang.Object
Direct Known Subclasses:
Spotlight

public class PointLight
extends LightSource
This class is represents an omni-directional light source that attenuates with respect to distance, similar to a light bulb.
  • Field Summary

    Fields inherited from class lighting.Light

    colour
  • Constructor Summary

    Constructors
    Constructor Description
    PointLight​(Colour colour, Point position, double q, double l, double c)
    Construct a PointLight from a Colour 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.
    double squareDistance​(Point point)
    Return the squared distance between the light source and the given point.
    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

    • PointLight

      public PointLight​(Colour colour, Point position, double q, double l, double c)
      Construct a PointLight from a Colour and 3 doubles that represent the attenuation constants.
      Parameters:
      colour - The colour of the light
      position - The position in space of the light source
      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.
      Specified by:
      colourAt in class LightSource
      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 NormalizedVector vectorTo​(Point point)
      Calculate a NormalizedVector from the source of the light to the given point.
      Specified by:
      vectorTo in class LightSource
      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 double squareDistance​(Point point)
      Description copied from class: LightSource
      Return the squared distance between the light source and the given point.
      Specified by:
      squareDistance in class LightSource
      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.