001/*
002
003*/
004
005package renderer.models;
006
007/**
008   Create a wireframe model of a right circular cylinder
009   with its axis along the y-axis.
010<p>
011   See <a href="https://en.wikipedia.org/wiki/Cylinder" target="_top">
012                https://en.wikipedia.org/wiki/Cylinder</a>
013<p>
014   This model can also be used to create right k-sided polygonal prisms.
015<p>
016   See <a href="https://en.wikipedia.org/wiki/Prism_(geometry)" target="_top">
017                https://en.wikipedia.org/wiki/Prism_(geometry)</a>
018
019   @see CylinderSector
020*/
021public class Cylinder extends CylinderSector
022{
023   /**
024      Create a right circular cylinder with radius 1 and its
025      axis along the y-axis from {@code  y = -1} to {@code  y = 1}.
026   */
027   public Cylinder( )
028   {
029      this(1, 1, 15, 16);
030   }
031
032
033   /**
034      Create a right circular cylinder with radius {@code  r} and
035      its axis along the y-axis from {@code  y = -h} to {@code  y = h}.
036
037      @param r  radius of the cylinder
038      @param h  height of the cylinder (from -h to h along the y-axis)
039   */
040   public Cylinder(double r, double h)
041   {
042      this(r, h, 15, 16);
043   }
044
045
046   /**
047      Create a right circular cylinder with radius {@code  r} and
048      its axis along the y-axis from {@code  y = -h} to {@code  y = h}.
049   <p>
050      The last two parameters determine the number of lines of longitude
051      and the number of circles of latitude in the model.
052   <p>
053      Notice that if there are {@code  n} circles of latitude in the model
054      (including the top and bottom edges), then each line of longitude will
055      have {@code  n+1} line segments. If there are {@code  k} lines of longitude,
056      then each circle of latitude will have {@code  k} line segments.
057   <p>
058      There must be at least three lines of longitude and at least
059      two circles of latitude.
060   <p>
061      By setting {@code  k} to be a small integer, this model can also be used
062      to create k-sided polygonal prisms.
063
064      @param r  radius of the cylinder
065      @param h  height of the cylinder (from -h to h along the y-axis)
066      @param n  number of circles of latitude around the cylinder
067      @param k  number lines of longitude
068   */
069   public Cylinder(double r, double h, int n, int k)
070   {
071      this(r, -h, h, n, k);
072   }
073
074
075   /**
076      Create a right circular cylinder with radius {@code  r} and
077      its axis along the y-axis from {@code  y = h1} to {@code  y = h2}.
078   <p>
079      The last two parameters determine the number of lines of longitude
080      and the number of circles of latitude in the model.
081   <p>
082      Notice that if there are {@code  n} circles of latitude in the model
083      (including the top and bottom edges), then each line of longitude will
084      have {@code  n+1} line segments. If there are {@code  k} lines of longitude,
085      then each circle of latitude will have {@code  k} line segments.
086   <p>
087      There must be at least three lines of longitude and at least
088      two circles of latitude.
089   <p>
090      By setting {@code  k} to be a small integer, this model can also be used
091      to create k-sided polygonal prisms.
092
093      @param r   radius of the cylinder
094      @param h1  height (on the y-axis) of the base of the cylinder
095      @param h2  height (on the y-axis) of the top of the cylinder
096      @param n   number of circles of latitude around the cylinder
097      @param k   number lines of longitude
098   */
099   public Cylinder(double r, double h1, double h2, int n, int k)
100   {
101      super(r, h1, h2, 0, 2*Math.PI, n, k);
102   }
103}//Cylinder