Posts

Showing posts from November, 2015

3.1.0: A Walk Through the View Part 1

Image
Movement in three dimensions is not a quick and easy topic.  There are many difficult concepts involved and a lot of math.  To help us encapsulate the data and make it both easier to understand and to work with, we'll create two new types:  a vector and a matrix.  We will do a basic implementation  for each which we can develop further a later date.  Create a new target (not a duplicate) and call it OnTheMove.  Add our two new types to the SwiftOpenGLView.swift file right after the module imports. Vector3 Above the SwiftOpenGLView class, define a new struct called Vector3.  It will have three properties, numbered 0-2.  These may be used to represent x, y, z coordinates, or pitch, yaw, roll values, etc.  Swift does not have an equivalent Union type per se that allows us to define types whose property names change based upon which is allocated upon creation.  They do have enums which may, arguably, be an appropriate choice to implement such functionality.  In the interest of stay