## quinta-feira, 5 de dezembro de 2013

### Why would we like dot product? Part 1.

Hello there! My first series of posts will be about math; or, to be clearer, about dot product. Since I've started developing games, every once in a while I would need to solve a spatial problem. For my unhappiness, the solution usually involved math. As many other programmers in the world, I'm not really fond of calculations using angles, trigonometry, vectors, matrices and so on – however this is a knowledge that will more and more bind you down whenever you try to make something cool. Here, I will assume that you already understand the basic of vectors. Math vectors. Yes, we will dive into boring math a little bit.

So, where is a good starting point? The dot product. The dot product is composed of simple calculations using two vectors of the same dimension. Let's say that we have two vectors, A = [a0, a1, ... , an] and B = [b0, b1, ... , bn]. The dot product is defined as:

$$$$A\cdot B = \sum^n_{i = 0} a_ib_i = a_0b_0 + a_1b_1 + ... + a_nb_n$$$$
The dot product is nothing more than the sum of the multiplications of the elements that share the same index in each vector, and thus we are happy with it. Computers are really good with sums and multiplications - good enough to do them a lot faster than even other simple calculations such as divisions. We don't want to jump into premature optimization here, but I think that this is a really useful fact to know (after all, in a few months you might be doing math on thousands of vectors that need to finish in a really short time window, or even programming your own graphics shader). But still, we don't have any clue on what or why use dot product. Before thinking on that, we need to know two small facts:

$$$$A \cdot B = B \cdot A$$$$
The dot product has the commutative property. This is a mathematical way to say that you don't need to go through the burden of carefully ordering your vectors to reach the correct solution. Of course dot product has other interesting properties, but they I won't be listing them in this post, as we wont use them right now. What we need to know best is the following:

$$$$A \cdot B = |A| |B| cos \theta$$$$
Given that we have the means to calculate the length of the A and B vectors - and usually we DO - and we know the angle $\theta$ between both, we can also calculate the dot product. What is interesting in this fact is that now we have two ways of calculating the dot product of two vectors. And better yet, one of the equations has a cosine!

If you look at it, assuming we know both vectors A and B, we can calculate their dot product. Since we can calculate the length of a  vectors we know the vector, this means we just have found a way to magically discover the cosine of the angle $\theta$ between them!

$$$$cos \theta = \cfrac{A \cdot B}{|A| |B|}$$$$
Calculating this cosine is what will make the dot product so useful. The cosine. For practical programming, sometimes we won't care about the angle $\theta$ itself - for that, we could simply use a math function called atan2 that exists for your programming language of choice. One last note, though. If we normalize the vectors, their length will become 1, so the equation will be simplified:

$$$$cos \theta =A \cdot B$$$$
By normalizing both vectors, calculating the cosine between two vectors became only sums of multiplications.

In this post, I just talked a bit about the math on dot products. There is a lot more to it, but we can really get started with what we have now. Next post, I'll write about some ways of using the dot product in game development. Some of them will use the resulting cosine while others won't. Till next time!

## quinta-feira, 31 de outubro de 2013

### Reflexus has been updated!

It's been a while! I've been quite busy and ended up forgetting to post it here: Reflexus has been updated! This update adds six achievements to the game. Most of them are quite simple to unlock so you can give it a try. The game now also allows you to sign in with you g+ account (if any), making it possible to compete with your friends and the world - if the world is not your friend yet - on acquiring the best overall time. Have fun!

Right now I'm working on a new project, but this does not mean that Reflexus is dead. I will eventually come back to make further polishments and more challenging levels.

## sexta-feira, 4 de outubro de 2013

### Reflexus is out on Google Play!

Koffee Bird is proud with it's very first game! Reflexus is a simple game designed to have quick gameplay (you can play a round in under 2 minutes) but still try to impose some challenge. All you need to do is to tap the correct node of a wheel and get a good average time – however, new symbols on the wheel will appear, adding meaning to the nodes and potentially changing the correct one. Are you fast enough to accept this challenge?

There are a few updates planned, but I'm not sure how long they will take or how big they will be yet.

## terça-feira, 1 de outubro de 2013

### And then there was coffee

Hello, world! Finally came to light the Koffee Bird group. Well, I call it a group but so far it is only me – however, that does not mean I am alone, since I am receiving help from some great people! Setting up everything has been a running mess with no end in sight, but finally there is a site to Koffee Bird... Actually, a blog, since I'm a starter.

I'm not used to all this stuff yet, but I sure do hope to learn how to be professional over the time. Even though the future is still unclear, Koffee Bird was created as a indie game developer, naturally not necessarily about coffee or birds. If everything goes in a happy rhythm, the very first one might be released pretty soon. Stay with us!

I'll start working with the theme and other stuff on the blog when I get the time and enough knowledge to do so.