(*:Title: DRUMPLOT *)

(*:Author: Alfred Gray *)

(* Copyright 1994  by Alfred Gray *)

(*:Package Version: 1.0 *)

(*:Mathematica Version: 2.2 *)

(*:Summary: 
	This package consists of definitions of parametrizations, plotting
programs and animations of square and circular membranes.
*)

(*:Keywords:
circularmembrane, circularmembranemovie, circularmembraneplot, squaremembrane, 
squaremembranemovie, squaremembraneplot
*)

Print["For a list of commands type drumplot."]

BeginPackage["DRUMPLOT`","NumericalMath`BesselZeros`"]

    drumplot:=Print[Select[Names["DRUMPLOT`*"],#!="drumplot"&]]

    circularmembrane::usage="{r,theta}->circularmembrane[m,n,t][r,theta]
is a parametrization of a circular membrane of degree {m,n} at
time t."

    circularmembraneplot::usage="circularmembraneplot[m,n,t] plots a
circular membrane of degree {m,n} at time t."

    circularmembranemovie::usage="
circularmembranemovie[m,n,{t,tmin,tmax,numf}] animates a circular membrane
of degree {m,n} from tmin to tmax with numf frames."

    squaremembrane::usage="{u,v}->squaremembrane[m,n,t][u,v]
is a parametrization of a square membrane of degree {m,n} at
time t."

    squaremembraneplot::usage="squaremembraneplot[m,n,t] plots a
square membrane of degree {m,n} at time t."

    squaremembranemovie::usage="
squaremembranemovie[m,n,{t,tmin,tmax,numf}] animates a square membrane
of degree {m,n} from tmin to tmax with numf frames."

Begin["`Private`"]

    circularmembrane[m_,n_,t_][r_,theta_]:=
        Flatten[{r*Cos[theta],r*Sin[theta],
            BesselJ[m,r*BesselJZeros[m,{n,n}]]*
            Cos[m*theta]*
            Cos[t*BesselJZeros[m,{n,n}]]}]

      circularmembraneplot[m_,n_,t_,opts___]:=
        Module[{zzz},
             zzz=circularmembrane[m,n,t][r,theta];
             ParametricPlot3D[Evaluate[zzz],
                 {r,0,1},{theta,0,2Pi},opts]]

      circularmembranemovie[m_,n_,{t_,tmin_,tmax_,numf_},
          opts___]:=
          Do[Module[{zzz},
             zzz=circularmembrane[m,n,t][r,theta];
             ParametricPlot3D[Evaluate[zzz],
                 {r,0,1},{theta,0,2Pi},opts]],
                 {t,tmin,tmax,numf-1}]

      squaremembrane[m_,n_,t_][u_,v_]:=
             {u,v,Sin[m*u]*Sin[n*v]*Cos[Sqrt[m^2+n^2]*t]}

      squaremembraneplot[m_,n_,t_,opts___]:=
             ParametricPlot3D[Evaluate[
                squaremembrane[m,n,t][u,v]],
                 {u,0,Pi},{v,0,Pi},opts]

      squaremembranemovie[m_,n_,{t_,tmin_,tmax_,numf_},
          opts___]:=
             Do[ParametricPlot3D[Evaluate[
                squaremembrane[m,n,t][u,v]],
                 {u,0,Pi},{v,0,Pi},opts],
                 {t,tmin,tmax,numf-1}]

(*
gcurvature[squaremembrane[m_,n_,t_]][u_,v_]:=
-(m^2*n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*
     (Cos[2*m*u] + Cos[2*n*v]))/
  (2*(-(m^2*n^2*Cos[(m^2 + n^2)^(1/2)*t]^4*Cos[m*u]^2*
          Cos[n*v]^2*Sin[m*u]^2*Sin[n*v]^2) + 
       (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
           Sin[m*u]^2)*(1 + 
          m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[m*u]^2*
           Sin[n*v]^2))^2)

mcurvature[squaremembrane[m_,n_,t_]][u_,v_]:=
(-2*m^2*n^2*Cos[(m^2 + n^2)^(1/2)*t]^3*Cos[m*u]^2*
     Cos[n*v]^2*Sin[m*u]*Sin[n*v] - 
    m^2*Cos[(m^2 + n^2)^(1/2)*t]*Sin[m*u]*
     (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
        Sin[m*u]^2)*Sin[n*v] - 
    n^2*Cos[(m^2 + n^2)^(1/2)*t]*Sin[m*u]*Sin[n*v]*
     (1 + m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[m*u]^2*
        Sin[n*v]^2))/
  (2*(-(m^2*n^2*Cos[(m^2 + n^2)^(1/2)*t]^4*Cos[m*u]^2*
          Cos[n*v]^2*Sin[m*u]^2*Sin[n*v]^2) + 
       (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
           Sin[m*u]^2)*(1 + 
          m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[m*u]^2*
           Sin[n*v]^2))^(3/2))

mcurvature[squaremembrane[m_,n_,t_]][u_,v_]:=
{-((m*Cos[(m^2 + n^2)^(1/2)*t]*Cos[m*u]*Sin[n*v])/
     (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
         Sin[m*u]^2 + m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*
         Cos[m*u]^2*Sin[n*v]^2)^(1/2)), 
  -((n*Cos[(m^2 + n^2)^(1/2)*t]*Cos[n*v]*Sin[m*u])/
     (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
         Sin[m*u]^2 + m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*
         Cos[m*u]^2*Sin[n*v]^2)^(1/2)), 
  (1 + n^2*Cos[(m^2 + n^2)^(1/2)*t]^2*Cos[n*v]^2*
      Sin[m*u]^2 + m^2*Cos[(m^2 + n^2)^(1/2)*t]^2*
      Cos[m*u]^2*Sin[n*v]^2)^(-1/2)}

gcurvature[circularmembrane[m_,n_,t_]][u_,v_]:=
((r^2*(BesselJ[-2 + m, r*BesselJZeros[m, {n, n}]] - 
         2*BesselJ[m, r*BesselJZeros[m, {n, n}]] + 
         BesselJ[2 + m, r*BesselJZeros[m, {n, n}]])*
       BesselJZeros[m, {n, n}]^2*
       (-2*m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]] + 
         r*BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}] - 
         r*BesselJ[1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}])*Cos[m*theta]^2*
       Cos[t*BesselJZeros[m, {n, n}]]^2)/8 - 
    (m^2*(2*BesselJ[m, r*BesselJZeros[m, {n, n}]] - 
          r*BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]]*
           BesselJZeros[m, {n, n}] + 
          r*BesselJ[1 + m, r*BesselJZeros[m, {n, n}]]*
           BesselJZeros[m, {n, n}])^2*
       Cos[t*BesselJZeros[m, {n, n}]]^2*Sin[m*theta]^2)/4
    )/(-(m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]^2*
         (BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]] - 
            BesselJ[1 + m, r*BesselJZeros[m, {n, n}]])^
          2*BesselJZeros[m, {n, n}]^2*Cos[m*theta]^2*
         Cos[t*BesselJZeros[m, {n, n}]]^4*Sin[m*theta]^2
         )/4 + (Cos[theta]^2 + 
        ((BesselJ[-1 + m, 
               r*BesselJZeros[m, {n, n}]] - 
              BesselJ[1 + m, 
               r*BesselJZeros[m, {n, n}]])^2*
           BesselJZeros[m, {n, n}]^2*Cos[m*theta]^2*
           Cos[t*BesselJZeros[m, {n, n}]]^2)/4 + 
        Sin[theta]^2)*(r^2*Cos[theta]^2 + 
        r^2*Sin[theta]^2 + 
        m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]^2*
         Cos[t*BesselJZeros[m, {n, n}]]^2*Sin[m*theta]^2)
     )^2

mcurvature[circularmembrane[m_,n_,t_]][u_,v_]:=
((r*(-2*m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]] + 
         r*BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}] - 
         r*BesselJ[1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}])*Cos[m*theta]*
       Cos[t*BesselJZeros[m, {n, n}]]*
       (Cos[theta]^2 + 
         ((BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])^2*
            BesselJZeros[m, {n, n}]^2*Cos[m*theta]^2*
            Cos[t*BesselJZeros[m, {n, n}]]^2)/4 + 
         Sin[theta]^2))/2 + 
    (m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
       (BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]] - 
         BesselJ[1 + m, r*BesselJZeros[m, {n, n}]])*
       BesselJZeros[m, {n, n}]*
       (2*BesselJ[m, r*BesselJZeros[m, {n, n}]] - 
         r*BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}] + 
         r*BesselJ[1 + m, r*BesselJZeros[m, {n, n}]]*
          BesselJZeros[m, {n, n}])*Cos[m*theta]*
       Cos[t*BesselJZeros[m, {n, n}]]^3*Sin[m*theta]^2)/2\
      + (r*(BesselJ[-2 + m, r*BesselJZeros[m, {n, n}]] - 
         2*BesselJ[m, r*BesselJZeros[m, {n, n}]] + 
         BesselJ[2 + m, r*BesselJZeros[m, {n, n}]])*
       BesselJZeros[m, {n, n}]^2*Cos[m*theta]*
       Cos[t*BesselJZeros[m, {n, n}]]*
       (r^2*Cos[theta]^2 + r^2*Sin[theta]^2 + 
         m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]^2*
          Cos[t*BesselJZeros[m, {n, n}]]^2*Sin[m*theta]^2)
       )/4)/
  (2*(-(m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]^2*
           (BesselJ[-1 + m, 
               r*BesselJZeros[m, {n, n}]] - 
              BesselJ[1 + m, r*BesselJZeros[m, {n, n}]])
             ^2*BesselJZeros[m, {n, n}]^2*Cos[m*theta]^2*
           Cos[t*BesselJZeros[m, {n, n}]]^4*
           Sin[m*theta]^2)/4 + 
       (Cos[theta]^2 + 
          ((BesselJ[-1 + m, 
                 r*BesselJZeros[m, {n, n}]] - 
                BesselJ[1 + m, 
                 r*BesselJZeros[m, {n, n}]])^2*
             BesselJZeros[m, {n, n}]^2*Cos[m*theta]^2*
             Cos[t*BesselJZeros[m, {n, n}]]^2)/4 + 
          Sin[theta]^2)*
        (r^2*Cos[theta]^2 + r^2*Sin[theta]^2 + 
          m^2*BesselJ[m, r*BesselJZeros[m, {n, n}]]^2*
           Cos[t*BesselJZeros[m, {n, n}]]^2*Sin[m*theta]^2
          ))^(3/2))
unitnormal[circularmembrane[m_,n_,t_]][u_,v_]:=
{(-(r*(BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]] - 
           BesselJ[1 + m, r*BesselJZeros[m, {n, n}]])*
         BesselJZeros[m, {n, n}]*Cos[theta]*
         Cos[m*theta]*Cos[t*BesselJZeros[m, {n, n}]])/2 \
      - m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
      Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta]*
      Sin[m*theta])/
   (r^2 + (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])*
             BesselJZeros[m, {n, n}]*Cos[m*theta]*
             Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta])
           /2 + m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
          Cos[theta]*Cos[t*BesselJZeros[m, {n, n}]]*
          Sin[m*theta])^2 + 
      (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])*
             BesselJZeros[m, {n, n}]*Cos[theta]*
             Cos[m*theta]*Cos[t*BesselJZeros[m, {n, n}]]
             )/2 - m*BesselJ[m, 
           r*BesselJZeros[m, {n, n}]]*
          Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta]*
          Sin[m*theta])^2)^(1/2), 
  (-(r*(BesselJ[-1 + m, r*BesselJZeros[m, {n, n}]] - 
           BesselJ[1 + m, r*BesselJZeros[m, {n, n}]])*
         BesselJZeros[m, {n, n}]*Cos[m*theta]*
         Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta])/2 + 
     m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*Cos[theta]*
      Cos[t*BesselJZeros[m, {n, n}]]*Sin[m*theta])/
   (r^2 + (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])*
             BesselJZeros[m, {n, n}]*Cos[m*theta]*
             Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta])
           /2 + m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
          Cos[theta]*Cos[t*BesselJZeros[m, {n, n}]]*
          Sin[m*theta])^2 + 
      (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])*
             BesselJZeros[m, {n, n}]*Cos[theta]*
             Cos[m*theta]*Cos[t*BesselJZeros[m, {n, n}]]
             )/2 - m*BesselJ[m, 
           r*BesselJZeros[m, {n, n}]]*
          Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta]*
          Sin[m*theta])^2)^(1/2), 
  (r*Cos[theta]^2 + r*Sin[theta]^2)/
   (r^2 + (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, 
                r*BesselJZeros[m, {n, n}]])*
             BesselJZeros[m, {n, n}]*Cos[m*theta]*
             Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta])/
          2 + m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
          Cos[theta]*Cos[t*BesselJZeros[m, {n, n}]]*
          Sin[m*theta])^2 + 
      (-(r*(BesselJ[-1 + m, 
                r*BesselJZeros[m, {n, n}]] - 
               BesselJ[1 + m, r*BesselJZeros[m, {n, n}]]
               )*BesselJZeros[m, {n, n}]*Cos[theta]*
             Cos[m*theta]*Cos[t*BesselJZeros[m, {n, n}]])
           /2 - m*BesselJ[m, r*BesselJZeros[m, {n, n}]]*
          Cos[t*BesselJZeros[m, {n, n}]]*Sin[theta]*
          Sin[m*theta])^2)^(1/2)}
*)
End[]

EndPackage[]
