Package geometries

Class Cylinder

java.lang.Object
geometries.Geometry
geometries.Cylinder
All Implemented Interfaces:
Intersectible

public class Cylinder
extends Geometry
This class represents a cylinder, which is a three-dimensional tube with a height, and closed disks on either end.
  • Field Summary

    Fields inherited from class geometries.Geometry

    material
  • Constructor Summary

    Constructors
    Constructor Description
    Cylinder​(Material material, Ray ray, double radius, double height)
    This constructs a Cylinder.
  • Method Summary

    Modifier and Type Method Description
    geometries.Boundary boundary()
    Get the Boundary of this intersectible.
    java.util.List<Intersection> intersect​(LineSegment line)
    Calculates all the intersections between a given LineSegment and this object.
    NormalizedVector normal​(Point p)
    This function returns the normal vector relative to the Point p.

    Methods inherited from class geometries.Geometry

    intersection

    Methods inherited from class java.lang.Object

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

    • Cylinder

      public Cylinder​(Material material, Ray ray, double radius, double height)
      This constructs a Cylinder.
      Parameters:
      material - The Material the cylinder is made from.
      ray - The ray that makes up the center of the Cylinder.
      radius - A positive double that represents the radius.
      height - A positive double that represents the height of the Cylinder.
      Throws:
      java.lang.IllegalArgumentException - if the radius is zero or the height is not positive.
  • Method Details

    • normal

      public NormalizedVector normal​(Point p)
      This function returns the normal vector relative to the Point p. p is assumed to be on the surface of the Cylinder. Anything else is undefined behavior.
      Specified by:
      normal in class Geometry
      Parameters:
      p - The point at which to find the normal vector.
      Returns:
      A NormalizedVector perpendicular to the surface of the shape at the given Point.
    • intersect

      public java.util.List<Intersection> intersect​(LineSegment line)
      Description copied from interface: Intersectible
      Calculates all the intersections between a given LineSegment and this object.
      Parameters:
      line - The LineSegment to check for intersections.
      Returns:
      A list of all the intersections with the given LineSegment.
    • boundary

      public geometries.Boundary boundary()
      Description copied from interface: Intersectible
      Get the Boundary of this intersectible.
      Returns:
      The bounding box of this intersectible.