Sidebar Menu

Projects

  • Dashboard
  • Research Project
  • Milestones
  • Repository
  • Tasks
  • Time Tracking
  • Designs
  • Forum
  • Users
  • Activities

Login

  • Login
  • Webmail
  • Admin
  • Downloads
  • Research

Twitter

Posts by stumathews
Stuart Mathews
  • Home
  • Blog
  • Code
  • Running
  • Gaming
  • Research
  • About
    • Portfolio
    • Info

A lot of doing a lot

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
26.Dec
25 December 2018
Last Updated: 30 December 2018
Hits: 2520
  • C++
  • Math
  • DirectX

The last couple of days have seen me working mostly on learning the math involved DirectX 12. I've gotten to a point where I've got a good inkling as to how and more importantly why vertices have to be transformed from local coordinate space to world coordinate space. Less obvious however is the transformation to view and projection space but for now, I'm happy to know just how and why it needs to be done. I've formulated my thinking around Matrix algebra and other theory in DirectX math, coursework and some films

I took a bit of a break from my 3D graphics study and did some study of learning theories presented in my CPD coursework and also continued somewhat with my Software Engineering coursework. A good strategy I always find with this stuff is to read through it all first to get a general idea, then re-read it with more focus next time around. In this way, my speed reading capabilities have increased wonderfully. So I'm happy that I was able to be productive with my studies in this regard.

I went to the gym as per usual, albeit a little later than usual(seeing that have the time to go later) and I've rather enjoyed this. I also took out an interesting book Maths Ideas Really Need Know which is quite fun and has helped me appreciate a lot of stuff.

I've very recently(Christmas Eve) started reading my humongous Dietel C++ How to Program book which I'm really enjoying and it must be said that its a lot of fun to read because it's so exacting. The only thing is that its so big and I've had to change physical positions between each chapter. I've only got through the first 5 chapters and it's late now so I really must go to bed. I gave up an opportunity, though not begrudgingly, to watch Jurassic World for a little foray into arrays and pointers(what a life, eh?).

So it really has been a good holiday in general, I've done a lot but I've also rested a lot while doing a lot.

Just before I started reading the Dietel book, I started messing around with my tablet again(I recently replaced its SSD) and found that Ubuntu 14.04 was crashing a lot. I spend a lot of time(and bandwidth) trying to fix the problem, ultimately resorting to upgrading it which then ultimately failed and effectively 'bricked' the damned thing.

So I bit the bullet and downloaded Fedora 29 after an initial failed download of 1.7Gb! Fedora ultimately got installed and is currently running very well indeed. I've not given it the same time that Ubuntu had - so it still could reveal problems if indeed the problems are not software related - which I hope they are... But so far, so good - perhaps the latest software has remedied it. Silly bloody thing. I had my dad on call to give me Linux advice which is a privileged position to be for most children!

I suspect however that my tablet will not see much action, as it hasn't featured much in my time thus far.

An interesting development. which has luckily passed now was I strained my back a little during deadlifts on Monday, I felt it was a bit tight and strained on a few lifts and after my workout, I was a little tender. Doing this is kinda unusual for me, as I usually am quite careful and attentive to my body's messaging so that why I though that this was so interesting. Anyway, thankfully the rest I had took paid off.

 I've finally finished reading the bulk of the Dietel book having covered STL. I've Covered control structures, Functions, Arrays, Pointer and C-style strings, Classes and data abstraction, operator overloading. polymorphism, templates, Streams, Exceptions. Files, Strings, Preprocessor and the Standard Template Library. So I've got a good handle on the theory, now I just need to get stuck into making my C++ Library which used Autotools however I might consider CMake this time.

To infinity... and beyond!

DirectX math, coursework and some films

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
18.Dec
17 December 2018
Last Updated: 28 December 2018
Hits: 4037
  • Math
  • DirectX

The last couple of days have been fairly interesting. I decided to learn about Vectors and the Math behind working with them. Things like what the dot product, unit vectors are and I did a bit of cursory trigonometry. Math has become a lot more fun for me since learning about games and 3d programming. Also I learnt how to embed math equasitions in by blog:

\[ det A = \sum_{j=1}^{n} A_{ij}(-1)^{i+j} det \bar{A}_{ij} \\ \tag{Determinant of A} \\ \]

The interesting thing about learning this stuff is not that I need it to work Direct X, which I do, but more so because it's nice to know what they mean and why it works. I think that's always been by a problem: sometimes I'm more interested in the concept sometimes than actually using it. But I think it does affect a lot of people too -  only they don't spend as much time on it as I do I think.

 

I remember when one of our Australian developers went to town converting all his C++ code to use templates... I think he loved the idea of templates more than perhaps the readability or productivity that the code might afford. All because templating in C++ was interesting. I sympathise. 

Anyway, I've also started reading more up on the Software Engineering coursework I have, it actually a lot more interesting than the CPD course, probably because I'm more familiar with it. I'm hoping the CPD becomes more interesting and fun... The thing about the CPD course is that it's all just a bit fluffy, you have to reflect on your past activities and apply theory to it and its all a bit 'mushy'. My last degree was more in-your-face:  here is a database, run this python query on it and send the bytes to that file etc. much more measured and hands-on, I guess that's why I like programming and maybe why I apprciate the math I'm learning at the moment.(a bit more than Continous Professional Development!)

I hit the gym yesterday and did quite a long and extended session focusing on my legs and having run in, I decided to run back and boy was that a test of endurance. My plans to be a little more varied in my workout haven't yet come into fruition yet. 

I watched the new Aquaman Film which I actually really enjoyed. I thought that perhaps this would be a watered down superhero film because it's not a well-known character but it was good. I quite like the co-star Amber Hurd, she's beautiful. Always helps. 

I watched my favourite film, Gladiator last night and I never get used to it - its a great film. 

Anyway back to my Direct X studies, whilst reading this new book about direct X 12... I've learned about the fundamental behind Vector arithmetic, basically observing the geometric results of adding, subtracting and multiplying vectors or forces.

I also noticed that the initialization and basic start-up code I learned about in DirectX11 has been replaced with a concept of queues and lists and commands that you send and prioritise graphics instructions to the GPU. This is new.

Some interesting facts are that negating a vector flips its direction, multiplying one, extends or rather scales its magnitude in the same direction and if you add two vectors (or forces) you can see the resulting displacement of an object or just the resultant vector by parallel extending the opposite vectors(I'll look for a good picture soon).

Translation in 3d Graphics terminology merely refers to taking a vector and putting it somewhere else - the direction and magnitude of the vector remain the same. Oh, and of course, a vector is represented geometrically as [x, y, z] and if you use the coordinate system, then you can see which direction this represents.

Some of the interesting things you can do on vectors is determining the vector magnitude using a special formula(which I can't show you right now because I can't get latex to work right on my blog). No wait I can:

\[ ||u|| = \sqrt{x^2 + y^2 + z^2} \\ \tag{eq.1.1 Magnitude of vector} \\ \]

The other is normalising the vector(which creates what is called a unit vector) which can be worked-out by applying a formula which basically just reduces the magnitude of the vector to 1 but the direction is still the same but obviously if you reduce the vector's magnitude, it's x, y, z coordinates will change, and that formula works out the newly adjusted values for them .

The other interesting thing you can do with two vectors is to determine if the angle between two vectors is acute, obtuse or perpendicular. This can be done by getting the scalar product (or the dot product) which is a sort of combination of two Vectors.

The other combination is the cross-product which allows you to determine a new vector which is orthogonal to the two vectors concerned - this is also called the left-hand rule, as the left hand rule also shows you(on your hand) where the orthogonal vector will be when given the direction of the first vector(which you aim your fingers at) and then curl your fingers towards to 2nd vector and then your thumb shows you where the perpendicular vector is. Kinda cool. 

The other thing you can do with unit vectors(magnitude is 1) is that you can easily determine the angle between the vectors (but not by using the dot product as that only tells you if the angle will be perpendicular, acute or obtuse) but by using cosine if both vectors are unit vectors. The equation for doing that is

\[ uv = ||u||||v|| \cos \theta \] and ||u|| and ||v|| just mean the magnitude of the vector and as these will both be 1, you can solve for the angle which will be the angle between the two vectors. 

My mind started to have a collapse when we started going over orthogonalising vectors which is something I'll have to look into at a later stage but basically its a formula to determine perpendiculars to vectors (like the left-hand rule) but with math. And the other brain-freezer was orthogonal projection, which I'm sure is all easy but I need an alternative perspective before my brain lets these ideas in!

These are the general equasions I learnt about when using vectors:

\[ ||u|| = \sqrt{x^2 + y^2 + z^2} \\ \tag{eq.1.1 Magnitude of vector} \\ \]

\[ \hat{u} = \frac{u}{||u||} = \frac{x}{||u||} + \frac{y}{||u||} + \frac{z}{||u||} \\ \tag{eq 1.2 Unit vector} \\ \]

\[ u \cdot v = u_{x}v_{x} + u_{y}v_{y} + u_{z} + v_{z} \\ \tag{eq 1.3 dot product} \\\]

\[ u \cdot v = cos \theta  \rightarrow ||u||||v|| = 1 (unit vectors) \\ \tag{eq 1.4 angle between vectors u and v} \\ \]

\[ w = u \times v = u_yv_z - u_zv_y, u_zv_x -u_xv_z, u_xv_y - y_yv_x \\ \tag{eg 1.5 cross product of two vectors} \\  \] 

I also learned about how to store Vectors in C++/DirectX using the SIMD registers that are part of SSE2 using the XMVECTOR Structure to store 4 32-bit floating point numbers which can represent a vector's parts ie [x, y, z] and the 4th float is not used. The other key idea was that use should only use this structure if you're storing these structures globally as this ensures some alignment requirements to be enforced. When this is not the case, Ie you want to store a vector in a class, you should use the XMFLOAT2,3,4 structure to store a Vector as it holds 2,3,4 floating point numbers which can represent your vector.

The cool thing about these structures is that they are 128-bit structures and one SIMD register is 128-bit and you can do one complete SIMD operation using 128bits stored in a SIMD register which is what DirectX does with these structures that you pass in. This is for efficiency purposes. Quite interesting.

A lot of the stuff I learnt was quite interesting because the proofs were solved, not just merely stating the equations but explaining the reasons behind the equations which is the right way to do it in my opinion.

Today I read up on Matrices, which are compact forms in which you can store Vectors or any 3 or 4 valued number(such as triangle vertices!). There are also some interesting things you can do on matrices. Basically, you can add/subtract and combine matrices too. There are generic equations which allow you to do this in a compact way but I was shown how these equations were derived from their geometric interpretations which were fun.

These were the ideas behind :

  • Multiplying matrices,
  • Vector-matrix multiplication - basically combining a vector with a matrix

\[ uA = xA_{1,*} + yA_{2,*} + zA_{3,*} \\ \tag{vector matrix multimplication} \\ \]

  • Transposing of a matrix - swapping a matrices columns with its rows
  • The identity matrix - a matrix that when multiplied by a matrix does not change the matrix
  • The determinant of  a matrix - which is a number which helps determine the inverse of a matrix

\[ det A = \sum_{j=1}^{n} A_{ij}(-1)^{i+j} det \bar{A}_{ij} \\ \tag{Determinant of A} \\ \]

  • Matrix Minors - a subset of a matrix which helps find the determinant of the matrix
  • Adjoint of a matrix - also helps to find the inverse of a matrix
  • The inverse of a matrix - which is used to help find another matrix when all others are provided in an equasion (so thats why its so useful.)

Equations:  (TODO)


\[ \left[
\begin{array}{ c c }
1 & 2 \\
3 & 4
\end{array} \right]
\]

Just like with Vectors most of the concepts mentioned above can be automatically calculated using DirectX helper functions (but where is the fun in doing that!)  but I'm thankful I know what that math behind it all is. The must say the Author Frank D Luna did a great job of explaining it. 

With Matrices, you can use a XMMATRIX instead of a  XMVECTOR and again you use this only for global variables of this type. To represent matrices in classes you would represent them as XMFLOAT4x4 which allows the storage of 4x4 Floats, which is the Matrix format most used in Direct X 12

 No I'm not sure I'll remember it all, but its probably going to start making sense when we start trying to translate, rotate, scale models that themselves are represented as vertices which are 3-valued structures and thus can be stored singularly as a Vector or an array of them, or indeed an array of Matrices. 

Tomorrow I'm going to read up about transformations(translate, rotate, scale) of these structures but first I'll need to figure out how orthogonal projection works - so let me get that out of the way first.

 

 

Kim Kardashians butt and other stuff

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
08.Dec
07 December 2018
Last Updated: 28 December 2018
Hits: 3481
  • Game development
  • C++
  • Math
  • DirectX

This is mostly about other stuff and not about Kim Kardashian's butt.

I've had about 7 days off from exercise due to my coming down with a cold. I loathe it when this happens but its actually quite good to take a break from something you do so often. I think psychologically as much as physically. This has meant that I've pulled back from the gym in the mornings and missed my long run on Wednesday.  I always wonder if there was something I could have done to prevent getting sick - could I have not been eating correctly, or was it that I didn't wash my hands enough or am I not sleeping enough? Can you really prevent being ill?

This does coincide with it starting to become colder and I think there is a theory that this helps in getting ill. I've not really thought about why but there you are.

I'm also thinking that when I go back to training, that I'll switch my training program.

I'll switch from what has mainly been a heavily resistance-orientated program to a more well-rounded program. This means that I'll be focusing on a balanced set of training exercises that improve the various areas in fitness, not just strength. So this will include Flexibility, Endurance, Skill, Stamina, Strength, Speed and Power etc. My usual routine is normally doesn't include power moves, agility and speed and it's these that I'll focus on. Currently, I do 3 days of 1.5 hours of resistance exercise and 20 minutes of running and on a Saturday I do around 2h of resistance training. Usually what I do is after my main training session, is to go for a 20-minute run which sort of helps me with my endurance(and helps me get home!)

The other things that have been on my mind are finishing my next assignments for Software Engineering and Continuing Professional Development,(CPD)  both of which have deadlines in December. I've effectively had to rewrite my one assignment which was a bit of pain. The reason was that as part of the CPD I have to study a theory of learning an apply it to past CPD activities I'd done. As it turns out, I wanted to reflect on my past software development activities and projects and work etc as I thought this would be a great way to assess what I've done. Turns out, that I had far too much stuff to reflect on and the Tutor was uncomfortable accepting so much work.

So I did a whole bunch of writing for nothing in this respect. In another respect, I actually enjoyed doing it but that meant that I had to do it again but this time on a much more narrower form of CPD - My degree. That being said, I was able to reference some of the other personal projects I did so all was not lost.

I've found some time to study Understanding how the Linq query syntax works because there is a difference in understanding how it works and just using it because it works. I also found an interesting use of an extension method on a nullable type which I describe in Nullable checking in the Wild-West which was interesting. And I've also been working on my Game Engine ideas with regards to Direct X programming.

I'm also looking potentially at rewriting my C library because I don't use it anymore which is mostly because I don't write as much C and C++ as I used to and because I don't like some of the ways I implemented it. For example, I don't need the threading layer now because C11 now includes a cross-platform implementation of threading. And I also don't like my naming conventions and I'd like to add more data structures like black-red trees which is heavily used in the Linux kernel. I also started thinking maybe I should write it in C++ which lead me to write about C++ in Complex or Elaborate

I've not been able to be as productive in my programming side-projects as I'd otherwise like to these days because of the studies, training and work but I'm getting there. I drew up some pictures of some of the concepts I'm grappling within Direct X mostly to do with the idea of defining vertex data, writing that to vertex buffers and having those buffers sent through the 3D graphics pipeline to have them interpreted by vertex and pixel shaders. Pretty interesting stuff but without pictures, my mind usually goes to sleep.

I ordered a 9-cell battery for my laptop because I find that a 1-hour session on the train in the morning to work and back tends to deplete me and my battery by about between Rayners lane and Ruislip. I got it on Friday night and plugged it in and my laptop almost fainted with its new-found power(it couldn't believe it!). I'm just wondering now if I can taking something that will revitalise me at around Rayners Lane too... Anyway, its now got a big, fat bum, (a bit like Kim Kardashian's butt) see here if you like (a picture of the battery, that is)

I also ordered a new SSD drive for my ageing tablet, which I think is so old that the SSD started to fail. After spending like 4 hours figuring out how to get into the guts of my tablet, I was able to see that the SSD was one of these mini-chip-like peripherals about the size of a watch face. I inherited this tablet from a colleague who got it for free by attending a Microsoft Build event - I used it at the time to research Metro and Windows 8 Algorithms for App-DNA back in the day. It's a bit old now but seeing that I can quite happily work on any machine with an SSH connection, it's just absolutely fine. 

So, I took down the serial and looked it up on eBay and found a supplier for a 128Gb card for around 30 pounds. This I thought was reasonable and it that would be double the space I had...bonus! Turns out, it works great, fitted it and installed Ubuntu 14. Not bad, so now I'm getting some good use out of it on my desk at home.

These two are the only computer's I own - the laptop and the tablet. Though, I do have a Rasberry Pi too, which now that I think about would be a perfect project to write a game for. It's a restricted environment so I'd have to use C++ and be careful with my memory and loops. Cool!

In other news, I watched Deadpool, Office Space, Idiocracy and I'm busy reliving my childhood and watching MacGyver which is pretty awesome. I used to watch that every Friday night at 7 pm when I was a kid. Someone at work brought in season 5 DVD for me to watch which I thought was very good of him. I didn't think much of Idiocracy however it was perspective-inducing I guess. Office space was quite enjoyable and Deadpool was OK. 

I've finished playing Fable II and this has been quite a bit of fun, but finding the time do anything apart from studying and work has been difficult which I guess is why doing them is so satisfying. I'll probably move so play Metro: Last light or Dantes Inferno, however, I think its unlikely that I'll have another good attempt until I've finished my assignments..or now that I come to think about it, take some time off.

I watched the new Wreck-it Ralph at the cinema last weekend and I enjoyed it - quite like the first one. It's nice to see how my early childhood fascination with technology is now becoming mainstream as shown in this movie: Its how Ralph breaks the internet and it's cool to see topics like YouTube, Amazon, Instagram, eBay are now embraced in everyday life. This is my life, these are my friends!

Also what I really need to do is find a way to use my Perl knowledge because I've not found a good use for it of late not ever since I finished reading the Camel book earlier this year.

I've also been studying more interesting math facts recently about how to interpret really large numbers like 3212345678998765. Which, is equal to 3 Quadrillion 212 Trillion, 345 Billion, 678 Million, 9998, 765 ! But why?

Legend for the table below:

TH = Thousands, H = Hundreds, T = Tens, U = Units

TH H T                              
TH TH TH TH H T                        
TH TH TH TH TH TH TH H T                  
TH TH TH TH TH TH TH TH TH TH H T            
TH TH TH TH TH TH TH TH TH TH TH TH TH H T U    
3 2 1 2 3 4 5 6 7 8 9 9 8 7 6 5    
Quadrillion     Trillion     Billion     Million                

1000×10004=10005
   
1000×10003=10004
   
1000×10002=10003
   
1000×1000=10002

So it becomes obvious how, where and why occurrences of TH x TH x TH ...n form the named numbers Quadrillion, Trillion, Billion, Million appear in the decimal system and its the iteration of 1000x1000 n.where n is Bi, Tr, Quad etc... Pretty interesting.

The key that is missing for many students is how Bi(2) meaning 2, Tri(3) meaning 3 , Quad(4) meaning 4, relate to the number it represents.  For example, if you are told that a Quintillion(6) is 1018 , which you often are, this's not obvious that this is because of 1000x10006 which is 1018!! I think its a failure of teaching, in general, to explain why certain things are certain things - like this video demonstrates which awesomely demonstrate this failure of teaching: A negative x negative = positive.

The decimal system, in general, is a brilliant system and its all credit to the Indians! Here is something I drew up which puts this system into perspective.

That's pretty much most of what I've been up to recently. Now back to essays and word counts... 

 

More Articles …

  1. The value of life
  2. A dangerous miracle
  3. Software change, its needs and the rise of the MD
  4. Perhaps Coincidental, Perhaps Not
  5. Running, Coffee, Chocolate and Pizza
  6. Army Curious
  7. A commentary on Leadership
  8. IExtensibleDataObject and ExtensionDataObject
  9. Disposable and extra
  10. The potential of the future and an interesting thing.
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

Page 32 of 182