Airplane Example

Introductory Notes

This notebook creates a simple airplane in Dynamic Visualizer and provides a visual insight into the YawPitchRoll option.
To ensure that the YawPitchRoll option corresponds to the normal yaw, pitch, and roll of an airplane, the aircraft is created with the symmetry axis along the x axis. 

Run the Initialization cells to execute all the cells in this notebook

Initialization

Off[General::"spell1"]; \(Off[General::"spell"]; 
<< Graphics`\)<< DynamicVisualizer`

ClearVisualizer[];

Define the Graphics

yFront = 0; yBack = -8; yWingMid = -2; yWingHWidth = 1; zWingThickness = 0.2; zWingStart = 1.8; xWingHalfLength = 5; yBackWingLength = 1; xWing2HalfLength = 3; gPlane = 
      Graphics3D[{Hue[0], 
          Cuboid[{-0.5, yBack, -0.5}, {0.5, yFront, 0.5}], Hue[ .7], 
          Cuboid[{-xWingHalfLength, yWingMid - yWingHWidth, zWingStart}, {
              xWingHalfLength, yWingMid + yWingHWidth, 
              zWingStart + zWingThickness}], Hue[0.2], 
          Cuboid[{-xWing2HalfLength, yBack, -0.1}, {xWing2HalfLength, 
              yBack + yBackWingLength, 0.1}], Hue[ .3], 
          Cuboid[{0.1, yBack, 0}, {-0.1, yBack + yBackWingLength, 
              zWingStart}], Hue[0], 
          Line[{{ .3 xWingHalfLength, yWingMid -  .3 yWingHWidth, 
                zWingStart}, {0, yWingMid, 0}, { .3 xWingHalfLength, 
                yWingMid +  .3 yWingHWidth, zWingStart}}], 
          Line[{{- .3 xWingHalfLength, yWingMid -  .3 yWingHWidth, 
                zWingStart}, {0, yWingMid, 0}, {- .3 xWingHalfLength, 
                yWingMid +  .3 yWingHWidth, zWingStart}}]}];

Create the Airplane

SetOptions[$DefaultModel3D , 
        ModelRange -> 6 {{-1, 1}, {-1, 1}, {-1, 1}}];
\(CreateObject[\ Object3D["Plane"]
, gPlane, 
        InvariantPoint -> {0, 0, 0}]\);

Animations

Yaw for the Heading

\(anim = 
      Table[{DV`SetOptions[Object3D["Plane"], 
            YawPitchRoll -> {2\ π\ t, 0, 0}, 
            Location -> {0, 0, 0}]}, {t, 0, 1, 1\/40}]; 

    Visualize[anim]; \)

Pitch for the Landing

pitchAngle = 15 Degree; \(anim = 
      Table[DV`SetOptions[Object3D["Plane"], 
          YawPitchRoll -> {0, pitchAngle, 0}, 
          Location -> {0, Cos[pitchAngle], Sin[pitchAngle]}\ 30\ t], {t, 
          0, 1, 1\/40}]; 
Visualize[anim]; \)

Victory Roll and Fly Past

\(anim = 
      Table[DV`SetOptions[Object3D["Plane"], 
          YawPitchRoll -> {π\/2, 0. , 2\ π\ t}, 
          Location -> {20\ \((t -  .2)\), 0, 0}], {t, 0, 1, 1\/40}]; 

    Visualize[anim]; \)

Yaw Pitch Roll for the Camera

\(anim = 
      Table[DV`SetOptions[Camera[{VisualizerUniverse, "Camera"}], 
          YawPitchRoll -> {0, \(π\ t\)\/16, 2\ π\ t}, 
          Location -> {0, \(-4\) + 4\ t, 0}], {t, 0, 1, 1\/40}]; 

    Visualize[anim]; \)

Fly Around

direction[yaw_, pitch_] := {Cos[pitch] Sin[yaw], 
        Cos[pitch] Cos[yaw], Sin[pitch]};

\(\( (*\ Reset\ the\ location\ and\ orientation\ of\ the\ object, \ 
      model, \ and\ the\ camera\ *) 

    \(Visualize@
      DV`SetOptions[\ VisualizerObjects[], \ 
        TransformationMatrix -> Automatic
	]; \)\)\)

location = {0, 0, 0}; yaw = -0.7; pitch = 0; roll = 0; \(anim = 
      Table[roll += 0.09; pitch = 0.2\ Sin[0.075\ t] + 0.2\ Sin[0.07\ t]; 
        yaw += 0.17; location += direction[yaw, pitch]; 
        DV`SetOptions[Object3D["Plane"], Location -> location, 
          YawPitchRoll -> {yaw, pitch, roll}], {t, 80}]; 

    Visualize[anim]; \)