(* ::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.                                                         *)
(************************************************************************)



(* ::Section:: *)
(*Rotation matrices for yaw, pitch roll system *)
(*(see Goldstein, 2nd Ed.,  p. 609)*)


(* ::Text:: *)
(*RotationMatrixXYZBS[yaw, pitch, roll] gives a rotation matrix which transforms body to space coordinates when used to left multiply a vector. RotateX[roll], RotateY[pitch] and RotateZ[yaw] give the individual components. These are defined righthandedly about the +X, +Y and +Z axes and are applied in roll-pitch-yaw order so the total matrix is equivalent to rotateZ[yaw].rotateY[pitch].rotateX[roll]. *)


BeginPackage["RotationsXYZ`"]



EulerB::usage = "EulerB[yaw_, pitch_, roll_]";
EulerC::usage = "EulerC[yaw_, pitch_, roll_]";
EulerD::usage = "EulerD[yaw_, pitch_, roll_]";

RotationMatrixXYZSB::usage = "RotationMatrixXYZSB[yaw, pitch, roll]";

RotationMatrixXYZBS::usage = "RotationMatrixXYZBS[yaw, pitch, roll]";

RotateX::usage "RotateX[roll]";
RotateY::usage "RotateY[pitch]";
RotateZ::usage "RotateX[yaw]";



Begin["`Private`"]



(* ::Text::Closed:: *)
(*Partial transformation matrices - set 1: active body to space matrices for rotating vectors.*)


rotateX[theta_] := {
	{
		1,
		0,
		0
	},
	{
		0,
		Cos[theta],
		-Sin[theta]
	},
	{
		0,
		Sin[theta],
		Cos[theta]
	}
};


rotateY[theta_] := {
	{
		Cos[theta],
		0,
		Sin[theta]
	},
	{
		0,
		1,
		0
	},
	{
		-Sin[theta],
		0,
		Cos[theta]
	}
};


rotateZ[theta_] := {
	{
		Cos[theta],
		-Sin[theta],
		0
	},
	{
		Sin[theta],
		Cos[theta],
		0
	},
	{
		0,
		0,
		1
	}
};


(* ::Text::Closed:: *)
(*Partial transformation matrices - set 2: passive (space to body) matrices.*)


EulerB[yaw_, pitch_, roll_] := {
	{
	1,
	0,
	0
	},
	{
	0,
	Cos[roll],
	Sin[roll]
	},
	{
	0,
	-Sin[roll],
	Cos[roll]
	}
}



EulerC[yaw_, pitch_, roll_] := {
	{
	Cos[pitch],
	0,
	-Sin[pitch]
	},
	{
	0,
	1,
	0
	},
	{
	Sin[pitch],
	0,
	Cos[pitch]
	}
}



EulerD[yaw_, pitch_, roll_] := {
	{
	Cos[yaw],
	Sin[yaw],
	0
	},
	{
	-Sin[yaw],
	Cos[yaw],
	0
	},
	{
	0,
	0,
	1
	}
}


(* ::Text::Closed:: *)
(*General transformation from space coordinates to body coordinates*)


RotationMatrixXYZSB[yaw_, pitch_, roll_] = EulerB[yaw, pitch, roll].EulerC[yaw, pitch, roll].EulerD[yaw, pitch, roll]



(* ::Text::Closed:: *)
(*General transformation from body coordinates to space coordinates*)


RotationMatrixXYZBS[yaw_, pitch_, roll_] = Transpose[RotationMatrixXYZSB[yaw, pitch, roll]]


End[]   (* Graphics`Shapes`Private` *)



EndPackage[]   (* Graphics`Shapes` *)

