(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



BeginPackage["WedgeMOI`"];


masswedge::usage="masswedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the mass of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


xCOMwedge::usage="xCOMwedge[R,t,f,{wabh,wafh},{wabv,wafv}] calculates the x COM position relative the coordinate origin for a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


yCOMwedge::usage="yCOMwedge[R,t,f,{wabh,wafh},{wabv,wafv}] calculates the y COM position relative the coordinate origin for a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


zCOMwedge::usage="zCOMwedge[R,t,f,{wabh,wafh},{wabv,wafv}] calculates the z COM position relative the coordinate origin for a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


xMOIwedge::usage="xMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the x MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


yMOIwedge::usage="yMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the y MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


zMOIwedge::usage="zMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the z MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


xyMOIwedge::usage="xyMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the x-y MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


yzMOIwedge::usage="yzMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the y-z MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


zxMOIwedge::usage="zxMOIwedge[rho,R,t,f,{wabh,wafh},{wabv,wafv}] calculates the z-x MOI of a wedged optic with density rho, radius R, centre thickness t, flat height f, and wedge slopes wabh, wafh, wabv and wafv.";


Begin["`Private`"];


usepreintegrated = True;


powerfix=(x_^2)^Rational[n_,2]:>x^n;


wedgeintegrate[fn_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}] := Integrate[
	fn,
{y,-Sqrt[R^2-(f/2)^2],Sqrt[R^2-(f/2)^2]},
{z,-Sqrt[R^2-y^2],Sqrt[R^2-y^2]},
{x,-t/2+wabh*y+wabv*z,t/2+wafh*y+wafv*z}
]/.powerfix/.(Re[R/Sqrt[-(f^2/4)+R^2]]>=1->True)


masswedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}] = If[usepreintegrated,
1/2 rho t (f Sqrt[-f^2+4 R^2]+4 R^2 ArcCot[f/Sqrt[-f^2+4 R^2]]),
rho*wedgeintegrate[1,R,t,f,{wabh,wafh},{wabv,wafv}]
]


xCOMwedge[R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  = If[usepreintegrated,
(f (Sqrt[-f^2+4 R^2] (f^2 (3 wabh^2-wabv^2-3 wafh^2+wafv^2)+6 R^2 (-wabh^2-wabv^2+wafh^2+wafv^2))-(24 R^4 (wabh^2+wabv^2-wafh^2-wafv^2) ArcCot[f/Sqrt[-f^2+4 R^2]])/f))/(48 t (f Sqrt[-f^2+4 R^2]+4 R^2 ArcCot[f/Sqrt[-f^2+4 R^2]])),
wedgeintegrate[x,R,t,f,{wabh,wafh},{wabv,wafv}]/m[1,R,t,f,{wabh,wafh},{wabv,wafv}] 
]


yCOMwedge[R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  = If[usepreintegrated,
(f^3 Sqrt[-f^2+4 R^2] wabh-2 f R^2 Sqrt[-f^2+4 R^2] wabh-f^3 Sqrt[-f^2+4 R^2] wafh+2 f R^2 Sqrt[-f^2+4 R^2] wafh-8 R^4 wabh ArcTan[Sqrt[-f^2+4 R^2]/f]+8 R^4 wafh ArcTan[Sqrt[-f^2+4 R^2]/f])/(8 t (f Sqrt[-f^2+4 R^2]+4 R^2 ArcCot[f/Sqrt[-f^2+4 R^2]])),
wedgeintegrate[y,R,t,f,{wabh,wafh},{wabv,wafv}]/m[1,R,t,f,{wabh,wafh},{wabv,wafv}] 
]


zCOMwedge[R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  = If[usepreintegrated,
-(((wabv-wafv) (f Sqrt[-f^2+4 R^2] (f^2+6 R^2)+24 R^4 ArcCot[f/Sqrt[-f^2+4 R^2]]))/(24 t (f Sqrt[-f^2+4 R^2]+4 R^2 ArcCot[f/Sqrt[-f^2+4 R^2]]))),
wedgeintegrate[z,R,t,f,{wabh,wafh},{wabv,wafv}]/m[1,R,t,f,{wabh,wafh},{wabv,wafv}] 
]


xMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
1/24 rho t (-f (f^2-6 R^2) Sqrt[-f^2+4 R^2]+24 R^4 ArcCot[f/Sqrt[-f^2+4 R^2]]),
rho wedgeintegrate[y^2+z^2,R,t,f,{wabh,wafh},{wabv,wafv}]
]


yMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
1/96 f rho t (Sqrt[-f^2+4 R^2] (4 t^2+f^2 (2-3 wabh^2+wabv^2-3 wafh^2+wafv^2)+6 R^2 (2+wabh^2+wabv^2+wafh^2+wafv^2))+(8 R^2 (2 t^2+3 R^2 (2+wabh^2+wabv^2+wafh^2+wafv^2)) ArcCot[f/Sqrt[-f^2+4 R^2]])/f),
rho wedgeintegrate[x^2+z^2,R,t,f,{wabh,wafh},{wabv,wafv}]
]


zMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
1/96 f rho t (Sqrt[-f^2+4 R^2] (4 t^2+f^2 (-6-3 wabh^2+wabv^2-3 wafh^2+wafv^2)+6 R^2 (2+wabh^2+wabv^2+wafh^2+wafv^2))+(8 R^2 (2 t^2+3 R^2 (2+wabh^2+wabv^2+wafh^2+wafv^2)) ArcCot[f/Sqrt[-f^2+4 R^2]])/f),
rho wedgeintegrate[x^2+y^2,R,t,f,{wabh,wafh},{wabv,wafv}]
]


xyMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
-(1/32) rho t (wabh+wafh) (f (f^2-2 R^2) Sqrt[-f^2+4 R^2]-8 R^4 ArcCot[f/Sqrt[-f^2+4 R^2]]),
rho wedgeintegrate[x y,R,t,f,{wabh,wafh},{wabv,wafv}]
]


yzMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
0,
rho wedgeintegrate[y z,R,t,f,{wabh,wafh},{wabv,wafv}]
]


zxMOIwedge[rho_,R_,t_,f_,{wabh_,wafh_},{wabv_,wafv_}]  =  If[usepreintegrated,
1/96 rho t (wabv+wafv) (f Sqrt[-f^2+4 R^2] (f^2+6 R^2)+24 R^4 ArcCot[f/Sqrt[-f^2+4 R^2]]),
rho wedgeintegrate[x z,R,t,f,{wabh,wafh},{wabv,wafv}]
]


End[];
EndPackage[ ];
Null
