Linear Algebra Essentials: Part 2

We conclude our chapter on the Adjoint of a linear operator.

Our main theorems

THEOREM:

Let V be an inner product space and T,U be linear operators on V. Then:

  • (T+U)^* = T^* + U^*
  • (cT)^* = \bar{c}T^*
  • (TU)^* = U^* T^*
  • (T^*)^* = T
  • I^* = I

The proof of this theorem is based on the definition of the adjoint: \langle T(x), y \rangle = \langle x, T^*(y) \rangle.

COROLLARY

The above properties hold for matrices too (through the L_A operator)

APPLICATION: Least Squares Approximation

The definition of the problem is classic: Given n points (t_1, y_1), (t_2, y_2), . . . , (t_n, y_n), we are trying to minimize \sum\limits_{i=1}^n (y_i-ct_i-d)^2, with c being the line of best-fit slope and d is its offset. If

A = \left [ \begin{array}{cc} t_1 & 1 \\ t_2 & 1 \\ . & .\\.&.\\.&.\\ \\ t_n & 1 \end{array} \right ], x = \left[\begin{array}{cc}c\\d\end{array}\right]   and y = \left[\begin{array}{cc}y_1\\y_2\\.\\.\\.\\y_n\end{array}\right]

then we are basically trying to minimize ||y-Ax||^2. We will study a general method of solving this minimization problem when A is an m\times n matrix. This allows for fitting of general polynomials of degree n-1 as well. We assume that m \geq n.

If we let x \in \mathbb{R}^n and y \in \mathbb{R}^m, then it is easy to see that \langle Ax, y \rangle = \langle x, A^*y \rangle from the properties of the adjoint studied thus far. We also know that rank(A^* A) = rank (A) by the dimension theorem, because the nullities of the two matrices are the same (this is straightforward to see). Thus, if A has rank n, then A^* A is invertible.

Using these observations, our norm minimization problem can be solved through the minimality of orthogonal projections: Since m \geq n, the range of L_A is a subspace of \mathbb{R}^n. The projection of y \in \mathbb{R}^m onto W is a vector u = Ax_0 and it is such that ||Ax_0 - y|| \leq ||Ax-y|| for all x \in \mathbb{R}^n. To find x_0, let us note that u-y lies in W^{\perp}, so \langle Ax, Ax_0 - y \rangle = 0 for all x \in \mathbb{R}^n. In other words, \langle x, A^*(Ax_0 - y) \rangle = 0 so x_0 solves the equation A^* A x_0 = A^* y. If additionally the rank of A is n, we get that:

x_0 = (A^*A)^{-1} A^* y

APPLICATION: Minimal solutions to Systems of Linear Equations

How do we find minimal norm solutions to systems of linear equations? We prove the following theorem:

Theorem

Let A \in M_{m \times n}(F), b \in F^m and suppose that the system Ax=b is consistent. Then:

  • There exists exactly one minimal solution s to Ax=b and s\in R(L_A^*).
  • The vector s is the only solution to Ax=b that lines in R(L_A^*). So, if u satisfies (A A^*)u = b, then s = A^* u.

In other words, finding minimal norm solutions to systems like Ax=b can be done by finding any solution to the system AA^* u = b and letting x = A^* u.

Proof

The theorem follows relatively easily from the minimality of the projection onto a subspace (like before). We do, however, need that N(L_A) = (R(L_A^*))^{\perp}, a fact which holds for all linear transformations. This fact can be easily established, so we leave it as an exercise.

VR/MR/AR, C# and Unity – DAY 7

Picking up from where I left off last time, my problem today is mainly hardware related. I cannot get the VivePro and Zed to agree in Unity and so the display is just black!

The solution which I found was using ZED_Rig_Stereo, instead of ZED_Rig_Mono (later confirmed by staff in StereoLabs), because the latter simply uses just the left camera, while the headset needs input from both cameras to function. But then my problem was immense glitching and jumping in the image!

I tried so many things: installing new NVIDIA drivers, changing GPU settings, clearing up memory in the disk etc… But nothing really worked. And I also had problems with the Vive not connecting easily.

With the help of a staff member at StereoLabs, I finally reached a working solution: disable tracking in the ZEDManager. That means that all the tracking info which the Zed uses come from the VivePro, whose tracking is actually much better, given that it has two points of reference (base-stations). But my VivePro has been having a lot of difficulties tracking. So, after looking online at forums of people with similar problems, I got the idea that maybe the windows, which I opened to let more light in for the sake of the Zed, actually reflect the lasers emitted from the base stations and prevent tracking. Truly, as soon as I shut the blinds, tracking with the VivePro became easier again and I could produce a working demo of my code.

Success!


Plans for the week to come:

  • Ensure that the ZED+VivePro is working smoothly and pinpoint conditions in different environments which cause problems or that work particularly well.
  • Attach the 3D printed mount on the VivePro in a stable way.
  • Run the 3D avatar on VR and then on MR and customize it so that it provides a good teaching experience. Also add some textual instructions around it.
  • Research how you can infer the relative position of the hands through the ZED.

 

VR/AR/MR, C# and Unity – DAY 6

Today’s goal is bringing together the work we did in the previous days and produce a working demo of the AR/MR capabilities of the ZEDMini. I don’t imagine it will be a daunting task, but I shall proceed carefully. I also want to crop the videos I made last time and also make one or two more in order to have a journal of results I have gotten these past few days.

Right off the bat, I’m facing issues with the VivePro again. It really doesn’t want to track with the base stations and its giving me a lot of trouble. I redid the room setup, elevated my desk and base stations and found out that a slight shake makes connecting sometimes happen. I’m really getting annoyed by these glitches though.

My sample scene with the rotating sphere works but the sphere is too large and sometimes gets sucked into walls. I also noticed that testing it standing up and without my chair in the way, the ZED AR demos are much better. I actually had a fun AR experience with it!


So the ball rotates fine with the RotateSphere script I wrote. Maybe I’ll turn up the speed and adjust position and things like that a little.

Text is very frustrating to place correctly. Unity is glitching a little bit, the equipment is annoying me a lot with it taking a million years to load and there is some window which hides anything i put behind it. I don’t know what kind of window that is.

Some positive results come from using ZED_Rig_Mono (not stereo) and disabling depth occlusion.

For some reason, two TextMeshPro instances cannot be placed in the scene. One really behaves absurdly and isn’t even show in the Game View. We’ll just make due with one instance then.

Now I’ll make a C# script modifying the textPro instance so that it is a timer and counts the sphere’s rotations.

After some time, I finally did code up the scripts and everything is running smoothly! That was my first complete, autonomous experience scripting with C# on Unity. Essentially, I implemented the timer by adding Time.deltaTime each time at the Update() function (even though I also considered System.Timers.Timer as an alternative). I used the Math.Floor() function extensively and also investigated C#’s Property system. Further, I learned about getting components and game objects amongst scripts and objects, which was very helpful in my endeavor to exchange information between different parts of the scene.

Another script counted how many times the ball rotates around the central axis. I store an angle variable which holds the total angle (mod 360) which the ball traverses. Every time the angle passes 360, I increment a counter and modify the TextMeshPro’s text accordingly.

Everything works smoothly with the Camera and I am very satisfied but I am still very frustrated and annoyed by the Vive’s connectivity. It seriously cannot connect. It takes it minutes! I have as clean a setup as I can, I removed the chair and restarted the computer many times. I just can’t get the camera to work with the Vive for my scene! It has made me quite angry this thing. The only error (warning) message I do get is:

If your machine has multiple graphics adapters, Unity may have created a WindowContext on the wrong adapter. If you experience a black screen when playing, please restart the Editor.

I don’t know what this means but it not the case that the specific scene has never worked! It just decided not to work now. I think I’ll call it quits for the day and try again tomorrow. Lots were gained today but this Vive issue has annoyed me plenty.