Introduction to Anaglyph Stereoscopy in Excel – part #5: adding a joystick to control the yaw and pitch rates of the 3D cube

In this section, a joystick is added to the model which controlls the  yaw rate and the pitch rate (not the angles!) of the stereoscopic cube. This joystick was used before in a dedicated tutorial and in the flight simulator tutorial. Its importance in future models can not be underestimated, hence I decided to cover this virtual device again. Use your 3D glasses while running the model.

[sociallocker][/sociallocker]

This article has 4 Comments

  1. Don, I don’t want that. I initially made it like that but I prefer to give the cube the feel of a vehicle control, better say an anti-airctaft cannon. About the internals of the macro, I want to keep it very simple and do the rest in the worksheet. Don’t forget, this is an beginner tutorial.
    Thanks for the input, good stuff! I never used matrices in VBA. Readers might be quite interested in your version. George

  2. Oh, I also forgot to mention that you have to convert the “azimuth” and “altitude” rotation matrices to values as well, so start with unit matrix values {{1,0,0},{0,1,0},{0,0,1}} in both.
    Cheers,
    Don

  3. Hi George,
    I tried a modification to your spreadsheet by converting the “azimuth*altitude*roll” range I7:K9 to values and adding a reset button at well that runs the code:

    Private Sub resetButton_Click()
    [I7] = 1
    [J8] = 1
    [K9] = 1
    [I8:I9] = 0
    [J7] = 0
    [J9] = 0
    [K7:K8] = 0
    End Sub

    and changing your code for the Joystick to input increments to the rotation angles relative to the screen. That way the joystick will behave like you’re manipulating the cube in your hands rather than like you’re flying thecube and viewing it from a 3rd person perspective. Both styles of rotation are valid and it depends on your purposes as to which is the most appropriate to use.

    Note that this implementation also drops the “roll” rotation input altogether.

    The modified joystick code is:

    Dim Pt0 As POINTAPI
    Dim Pt1 As POINTAPI

    RunPause = Not RunPause
    GetCursorPos Pt0
    Do While RunPause = True
    DoEvents
    GetCursorPos Pt1
    [B50] = Pt1.X – Pt0.X
    DoEvents
    [C50] = -Pt1.Y + Pt0.Y
    DoEvents
    [B1] = [B52] / 1500
    [I7:K9] = WorksheetFunction.MMult([E2:G4], [I7:K9])
    DoEvents
    [B3] = [C52] / 1500
    [I7:K9] = WorksheetFunction.MMult([I2:K4], [I7:K9])
    Loop

Leave a Reply

Your email address will not be published. Required fields are marked *