Package lighting
Class Spotlight
java.lang.Object
lighting.Light
lighting.LightSource
lighting.PointLight
lighting.Spotlight
- 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
-
Constructor Summary
-
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 aSpotlight
from aColour
, a direction, and 3 doubles that represent the attenuation constants.- Parameters:
colour
- The colour of the lightposition
- The position in space of the light sourcedirection
- The direction of the spot lightq
- The quadratic factorl
- The linear factorc
- The constant factor
-
-
Method Details
-
colourAt
Calculate the colour of the light that this light source is projecting onto a given point.- Overrides:
colourAt
in classPointLight
- Parameters:
point
- The point at which to calculate the colour of the light.- Returns:
- The colour of the light at the given point.
-
factor
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.
-