Ferris Wheel

Introductory Notes

This notebook creates a Ferris wheel complete with rocking seats. You will need to move the camera manually to obtain this view. The initialization cells will create the model and run the animation.

Initialization

<< DynamicVisualizer`General::"spell1"  // Off

ClearVisualizer[];

Define the Graphics

Set the Object Parameters

nCarriages = 9; bigWheelAngleStep = ((2.  π)/nCarriages); bigWheelRadius = 10; bigWheelSmallRadius = 0.6 bigWheelRadius; bigWheelCentreRadius = 0.02 bigWheelRadius; bigWheelHalfHeight = 2 + bigWheelRadius; bigWheelHalfWidth = 2;
supportHalfLength=0.6 bigWheelHalfHeight;
supportHalfWidth = 1.1 bigWheelHalfWidth; groundHalfWidth = 8; groundHalfLength = 8;

Define the Ground Graphics

\($DisplayFunction\  = \ Identity; 

    gGround = 
      Plot3D[\((1 + Random[])\)\ 
          \((\((x\/groundHalfWidth)\)\^2 + \((y\/groundHalfWidth)\)\^2)\), {
          x, \(-groundHalfWidth\), groundHalfWidth}, {y, 
          \(-groundHalfLength\), groundHalfLength}, 
        ColorFunction -> \((RGBColor[0, Random[], Random[]\/2]&)\), 
        SphericalRegion -> True, PlotPoints -> 16]; \)

Define Ferris Wheel and Support Struts

Module[{angle, iStrut},strutUnitVectors = 
            Table[angle = ((2 π i)/nCarriages); 
              N[{0, Cos[angle], Sin[angle]}], {i, nCarriages}];gSupports=Graphics3D[{Hue[ .7],(Line[{{#1,-supportHalfLength,0},{#1, 0, bigWheelHalfHeight},{#1,supportHalfLength,0}}]&)/@(supportHalfWidth {-1, 1})}];]

Module[{angle, iStrut}, 
      strutUnitVectors = 
        Table[angle = ((2 π i)/nCarriages); 
          N[{0, Cos[angle], Sin[angle]}], {i, nCarriages}]; 
      gWheel = Graphics3D[{Thickness[0.01], 
            Function[{side}, {RGBColor[1, 0, 0], 
                  (Line[{{side, 0, 0}, {side, 0, 0} + bigWheelRadius #1}]&)
                      /@strutUnitVectors, RGBColor[1, 1, 0], 
                  Table[radius
                       = {bigWheelSmallRadius, bigWheelRadius}
                          [[circle]]; 
                    Line[({side, 0, 0} + radius #1&)/@
                        (Append[#1, First[#1]]&)[strutUnitVectors]], {
                      circle, 2}]}]/@(bigWheelHalfWidth {-1, 1}), 
            Table[{radius
                   = {bigWheelCentreRadius, bigWheelSmallRadius, 
                      bigWheelRadius}[[circle
                    ]]; {Hue[.0], Hue[.4], Hue[.6]}
                    [[circle]], 
                MapIndexed[
                  Function[{strut}, {
                      RGBColor[1, 
                        Mod[#2[[1]], 2], 
                        0], Line[
                        (radius strut + #1 {bigWheelHalfWidth, 0, 0}&)
                            /@{-1, 1}]}], strutUnitVectors]}, {circle, 
                3}]}]];

Create the Carriage Graphics

Module[{BackHeight, HalfWidth, LegHeight, FootDepth, HalfSeatDepth}, 
      BackHeight = 0.9; HalfWidth = 0.95 bigWheelHalfWidth; LegHeight = 0.5; 
      FootDepth = 0.3; HalfSeatDepth = 0.4; sideDepth = 1.8 HalfSeatDepth; 
      sideHeight = 0.3; 
      gCarriage = 
        Graphics3D[{Hue[-.1], 
            Polygon[(#1 {HalfWidth, HalfSeatDepth, 0}&)
                  /@{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {
                    -1, 1, 0}}], 
            Polygon[({0, HalfSeatDepth, 0} + #1
                         {HalfWidth, 0, -LegHeight}&)
                  /@{{-1, 0, 0}, {1, 0, 0}, {1, 0, 1}, {-1, 0, 
                    1}}], Hue[-.1, .6, .6], 
            Polygon[({0, HalfSeatDepth, -LegHeight} + #1
                         {HalfWidth, FootDepth, 0}&)
                  /@{{-1, 0, 0}, {1, 0, 0}, {1, 1, 0}, {-1, 1, 
                    0}}], Hue[-0.3], 
            Polygon[({0, -HalfSeatDepth, 0} + #1
                         {HalfWidth, 0, BackHeight}&)
                  /@{{-1, 0, 0}, {1, 0, 0}, {1, 0, 1}, {-1, 0, 
                    1}}], Hue[.1], 
            Table[Polygon[
                ({HalfWidth iside, -HalfSeatDepth, 0} + #1
                           {0, sideDepth, sideHeight}&)
                    /@{{0, 0, 0}, {0, 0, 1}, {0, 1, 1}, {0, 1, 0}}], {
                iside, -1, 1, 2}], Thickness[0.02], Hue[0.4, 0.4, 0.4], 
            Line[({0, sideDepth - HalfSeatDepth, sideHeight}
                         + {#1 HalfWidth, 0, 0}&)/@{-1, 1}]}]; ]

Put the Objects in Dynamic Visualizer

Initialize the Dynamic Visualizer Model

SetOptions[$DefaultModel3D, 
      ModelRange -> {{-13, -13, -13}, {13, 13, 13}}];

Clear[carAngle, carPosition, carVertical]carAngle[car_, t_] := 
      bigWheelAngleStep (car - 1) + t bigWheelTurningSpeed; carPosition[car_, t_] := 
      Module[{angle = carAngle[car, t]}, 
        N[{0, 0, bigWheelHalfHeight + .1} + 
            bigWheelRadius {0, Cos[angle], -Sin[angle]}]]; carSwing[car_, t_] := 
      Module[{angle = carAngle[car, t]}, N[0.5 Sin[2 angle - 1.5]]];

Clear[resetModel]; \(resetModel[] := 
      SetOptions[$DefaultModel3D, Location -> Automatic, 
        YawPitchRoll -> {\(6\ π\)\/7, 0, 0}]; 
\(resetModel[]; 
    \)\)

SetOptions[Camera[{VisualizerUniverse, "Camera"}], 
      Location -> {0, -1, 0.7}, 
      YawPitchRoll -> {0, -(π/12), 0}];

Create all the Objects in Dynamic Visualizer

\(\(theGround = 

      CreateObject[Object3D["Ground"], gGround, \ 
        InteractiveMovement\  -> False]; \)\)

\(\(theWheel = 

      CreateObject[Object3D["Big Wheel"], gWheel, \ 
        InteractiveMovement\  -> False]; \)\)

\(\(theSupports = 

      CreateObject[Object3D["Supports"], gSupports, \ 
        InteractiveMovement\  -> False]; \)\)

\(theCarriages = {}; 

    Do[Visualize[gCarriage]; \(AppendTo[theCarriages, $LastVisualizerObject]; 
      \), {nCarriages}]; \)

\(allObjects = Join[{theGround, theWheel, theSupports}, theCarriages]; 

    
SetOptions[allObjects[\([1]\)], InteractiveMovement -> False]; 

    SetOptions[$DefaultModel3D, BoundingBox -> False]; \)

Put the Objects in Their Correct Places and Set Their Surface Characteristics

Clear[resetObjects]resetObjects[] := 
      (SetOptions[theWheel, Location -> {0, 0, bigWheelHalfHeight}]; 
        SetOptions[theGround, Specular -> 0, Ambient -> .3, 
          Diffuse -> 0, Scale -> {8, 8, 3}, Opacity -> 1]; 
        MapIndexed[
          SetOptions[#1, 
              Location -> 
                carPosition[#2[[1]], 
                  0]]&, theCarriages]; );

\(resetObjects[]; 
resetModel[]; \)

Animation

\(animFrames = 48; 
    bigWheelTurningSpeed = \(2\ π\)\/\((animFrames + 1)\); 


    animWheel = 
      N[Table[{MapIndexed[
              DV`SetOptions[#1, 
                  Location -> 
                    carPosition[#2[[1]], 
                      frame], 
                  YawPitchRoll 
                    -> {0, 
                      carSwing[#2[[1]], 
                        frame], 0}]&, theCarriages], 
            DV`SetOptions[theWheel, 
              YawPitchRoll 
                -> {0, \(-bigWheelTurningSpeed\)\ frame, 0}]}, {frame, 
            animFrames}]]; \)

\(resetObjects[]; 
Visualize[animWheel]; \)