Notes for April 21 class: Various topics

 Overview of what we discussed in class In class we talked through how to connect with IMU from within HTML, and we looked at three examples (more on that below). Then we had a discussion about two link IK. Here is the source code for my two link IK function. Note that it assumes you have already implemented a function `dot()` to perform an inner product between two length-three vectors. ``` /* Usage: The shoulder is assumed to be at the origin [0,0,0]. a is the length of the forearm. b is the length of the lower arm. C is the [x,y,z] location of the wrist. D starts out as an [x,y,z] "hint location" for the elbow, and is overwritten by the exact location of the elbow. */ function ik(a, b, C, D) { var cc = dot(C,C), x = (1 + (a*a - b*b)/cc) / 2, y = dot(C,D)/cc; for (var i = 0 ; i < 3 ; i++) D[i] -= y * C[i]; y = Math.sqrt(Math.max(0,a*a - cc*x*x) / dot(D,D)); for (var i = 0 ; i < 3 ; i++) D[i] = x * C[i] + y * D[i]; } ``` We also had a discussion about Lance Williams' ingenious texture anti-aliasing algorithm Mip Mapping, which he first published in 1983, and which you are still using in your computer and SmartPhone GPUs today. At the end of the class, we showed Karl Simms' 1990 seminal computer animated short Panspermia.

 Your computer as a web server for textures and virtual reality In order to see your textures while running on your own computer, you need to run a server. To do that, you just need to go to the folder where you have an index.html file containing your graphics homework, and run the following from the command line: `python -m SimpleHTTPServer` In order to be able to run the above command, you will need to install python, which you can do by following the instructions at: `https://www.python.org` Once your server process is running, then you will be able to see your textures, because Chrome will think it is getting the info from a server, not from local files. Now you are ready to see your homework example with textures, using your own computer as a server, by typing the following into Chrome's address line: `http://localhost:8000` The ":8000" specifies the server port. 8000 is the default port number for the Python server. As long as you got this far, you can also use your server to run VR on your SmartPhone, using your computer as a server, the way I did it in class. To do that, you need to open Chrome on your SmartPhone and type the following into the address line: `http://:8000` In the above, you need to replace by your computer's actual IP address. On a MacBook you can find that under the Apple logo on the top-left of your screen, in the System Preferences → Network dropdown. Or you can use the following little shell command in a terminal window (which I wrote just for this purpose): `ifconfig | grep broadcast | sed 's/.*inet //' | sed 's/ .*//'` Now you can use your SmartPhone's IMU to compute direction and tilt, like I showed in class. The examples we looked at in class, which make use of that capability, are in imucode.zip. Remember that you need to be in the `imucode/` directory when you start the Python server. Note that the version of `CT_Modeler.js` in the `imucode/` directory is the most up to date version. In particular, it will handle stereo viewing properly.