Game Basics Game Engine and Game Math 1
GCC Academy
Hello everyone
This is Deukwoo Lee for game maths
In this lecture
we will learn about the structure of numbers and function
First, structure of number is composed of four parts
Visualization of number, binary operation,
properties of binary operation
and field axiom
I also prepared function and function principles
I'll start with the basics of function
and move on to the concept of Cartesian product and calculations related to
function composition
Structure of Number
First let's start with visualization of numbers
Before that, why do we need to know about numbers?
In the game world that we'll eventually make
the basis is a system composed with
something called vector
Based on this system, various content is made
and functions on it
This vector is in fact
something made from
a combination of numbers
To understand this vector
we need to understand what system
and structure numbers have
When we talk about numbers
you might have seen this at school
but there are these many types of numbers
Number was used along
the development of human civilization
when counting, farming, and sailing
and the concept has advanced
There are various concepts of numbers
like natural numbers, integers, rational, irrational
real, and imaginary numbers
The concept has expanded and mathematicians
have used the first letters of each
from a set perspective
From here, the set of numbers that we often use
are real numbers
or the set of real numbers
The definition of this
is the set of numbers no gap between
a number and another
Therefore theoretically
there must be no gap in between numbers
so there are infinite amounts of numbers in between
meaning that there are elements
filling in those spaces
This concept of the set of real numbers
and thinking of numbers as elements
require some practice for you
and this set
will be determined depending on
how we lay out the elements
If each elements were expressed as
dots, having no gaps in between
would make them all be connected
Therefore the real number set
can be visualized into this
straight line that we see in the screen
We call this the number line
On this number line
when we're marking an element
smaller number goes on the left and the larger on the right
within the structure of the number line
this is the way we compare
big and small of numbers
But we'll use vectors
to create systems
and to become familiar with the vector system
the way we perceive numbers
must not be based on just one structure
but based on 0
it will be more convenient to
think of it as two symmetrical structures
on the right and left
From this perspective of numbers
with 0 in the very middle
a number's property
can be summarized into two
First is the distance from the origin
and second is the structure it belongs in
between the two
Those two can be called
size and direction
A size
The size of a number
is the distance from the origin
and the direction, so left or right
there is only two
So if you're looking for the size of a number
you can use the absolute value
to find the distance from the origin
and for direction
we can use the + or - sign
to distinguish them
Now that we know how the express these numbers
what we need to look into next is
about the operation system of numbers
We often call that binary operation
We previously talked about
how numbers are managed in a set concept
but that concept of sets is actually very simple
It's just gathering objects we use
and putting them together into a collection
Just a collection of elements
But as you already know
numbers
so set of numbers
is not just a collection of elements called numbers
but there is also a system called operation within it
Therefore set of numbers
are different from any other normal set
These operations are usually called binary operation
and as you can see in this picture
when you put two elements from the number set
into a machine
there will be one output
through the machine
which is something new
That's what it is
From here, we defined an operation
symbolized by a circle
and these two elements with the circle operation
a new product is made
which is a circle b
and that again belongs to the set
then we say that it's closed in math
These operations, a familiar example would be
elementary arithmetic
Addition, subtraction, multiplication, and division
Let's rethink how we look at
elementary arithmetic as well
Let's first think of addition and subtraction
as a part of the addition and multiplication calculations
instead of two separate procedures
We're switching subtraction
to addition and division
to multiplication
As you can see here, we're thinking of
5-3 as 5+(-3)
and 5/3 as well into 5*1/3
a form of multiplication
Like this let's think of the number system
with the types of calculations simplified
from 4 to 2
And then before getting into the lecture
we also need to know about how we mark multiplication
Usually when we write multiplication
we use the x sign
But using this x sign
makes the expression long
and you might also confuse it with an unknown
so in math, rather than using the x sign
it is more usual to use a center dot
a small dot in the center
So in this course as well when expressing multiplication
we won't use x but use a center dot
for multiplication
Let's look into addition and multiplication
I visualized how
the addition calculation works
As you can see, 1+(-5)
It's 1-5 but turned into addition
What this means is
to 1, we'll move an element with the size of 5
to the - direction, that is, left
parallel
So 1-5 in addition terms
is moving the element 1
by 5 to the left
2+2=4
The calculation on the right
is also the same
Moving the element 2 to the right by 2
parallel
So addition, visually
is a calculation that moves a dot
parallel
Now let's see multiplication
Multiplication
is actually addition repeated many times
But let's rethink it to visualize it
from a vector perspective
Multiplication is a calculation on
how many times we increase
with the size of the number that we have
from the origin
and the concept of direction is added here
As you can see, 1*4 is
increasing 1's size four times
and with the direction that 1 has
so to the same direction, right, four times
Then let's see 2*-1
For this as well, we're taking
the size of 2 one time, so with
no change in the scale
but since there's -1
we're going
the opposite direction
from where we were going
So it's a 180 degree turn
So the concept of rotation
is included in multiplication
So multiplication of positive number
is 0 degree rotation
and multiplication of negative number
is a 180 degree rotation
Now let's also take a look at
the properties of calculations
also visualized this time as well
The set of real numbers that we're using
has the calculation system within it
So the system included in the
set with infinite real numbers
operations, binary operations' properties
can be divided into three
Commutativity, associativity, distributivity
Commutativity is
that when the operation order is reversed
the product is the same
and associativity refers to how
when there are more than three elements
the product is the same no matter which operation is done first
Distributivity
is the property explained here
with this expression
There's something special here
First there are two types of operations used
Addition and multiplication
There's this one and there's this one
This is left-distributive, and right-distributive
Both of these must be satisfied
to be considered to have the property
of distributivity
There could be an operation that satisfies
commutativity, associativity, and distributivity or not
you just need to remember that these properties exist
Next thing we need to know is identity element
It's called identity in English
Identity is an element
for a certain element a
that makes the product of the binary operation
become the same element a
That is
the identity element b
So in addition
we input a number
there is only one element that makes the product a
It will be 0
So addition's identity is 0
and multiplication's identity is 1
If we expand this concept of identity
we can obtain the concept of inverse element
This is a special element that makes the product
the identity
Inverse, it might also help
to know the English
So when we say that the identity of
certain operation is b
and if we say that a special element c
always makes a b
that is the inverse
Then what is the inverse of addition?
The production of an operation with a as the input
must always be 0
so the inverse of addition is -a
Like this, putting the opposite sign to a number
is called the opposite number
We're going to use this expression later on as well
so remember that
and the inverse of multiplication
since the identity of multiplication is 1
a fraction with a as the denominator
makes it 1
Here, a must not be 0
which is a special condition
and taking an element
as the denominator is called the reciprocal
We're also going to use this one often
so remember this
Addition's inverse is opposite number
and multiplication's inverse is reciprocal
And when we mentioned subtraction
Subtraction is
operation of the opposite number
Same goes for division
Division is the multiplication operation
of the reciprocal
So why do we not use subtraction and division
and only use addition and multiplication?
In subtraction, commutativity does not stand
a-b
For example, 3-5
in an subtraction expression
the product is not the same as 5-3
Reversing a subtraction always gives the opposite number
which means that it does not satisfy commutativity
But with addition
if we change 3-5 to 3+(-5)
it gives the same product as (-5)+3
so commutativity is satisfied
Same for multiplication
Therefore we don't use subtraction and division
but use only addition
and multiplication to express all operations
Then using only these two operations
let's analyse the operation structure
of real numbers
When we analyse the structure a number has
we use axiom
This axiom means the most basic proposition
that does not need a proof in a theory structure
So we'll analyse the axioms
and also the set of numbers that satisfy the axioms
to create
a structure of numbers that
satisfy the properties
instead of what we actually use
First there is axiom of group
If there are two operations
on a certain number structure
and if there is a number structure
that satisfies the following axiom
then we say that it has group structure
Let's try addition first
The addition
must be closed
meaning that the product
of the addition must be in the set of numbers used
It must be associative and an identity must exist
The identity of real number is 0
so we can see that this is immediately checked
and inverse as well
There is an opposite number so the inverse of addition exists
Therefore real numbers
have group structure
We use parentheses and a comma
and R, the real number symbol and a + sign
to say that it has group structure
Another condition comes
If it is commutative
it can also be said that it is in the Abelian group
Like this, axioms accumulate
and what comes next is another axiom
for the second operation
Multiplication
Let's see what there is for multiplication
The product of multiplication is always a real number
therefore it's closed
So axiom of ring
means that it satisfies that it's closed
for the second operation
and associativity and distributivity
Distributivity uses two operations
so the first operation in group
and the second operation in ring are combined
and if they satisfy distributivity
it means that this has ring structure
We can also simplicize this
with signs
Then we're adding another
more strict condition here
For the second operation, it must be distributive
and have identity
then we say that it has the commutative ring structure
Lastly, multiplication
If there is inverse
for the second operation
we say that it has field structure
So except for 0
since an inverse cannot be 0
So for all operations except for 0
if there is inverse for the second operation
then it has field structure
So real numbers we normally use
have field structure
because it satisfies all axioms mentioned
So to gather up everything we've talked about
if it's closed for addition and multiplication
satisfies commutativity, associativity, distributivity
and has identity and inverse
so to put it simply
it must be closed for elementary arithmetic and the operation can freely be expanded
The operation order is flexible
The set of numbers satisfying this field structure
include real number and also rational number and complex number
So when dealing with numbers
although we usually are usually in the real number structure
theoretically, rather than limiting it to real number
it is better to say that we use the set of numbers
that have field structure
to expand the theory
And based on that
various systems are expanded
This kind of set with field structure
are expressed as F
and each element of that set
is called scalar
Now we compared the sets
that we use and the theoretical one
For real numbers
I mentioned that we use the symbol R
and the elements are real numbers
But in the concept of field set
from a structural concept
it is called the field set F
and the elements are scalars
Therefore when we see
the operation a+b
it is the addition of real numbers a and b
and this
has a limit in a way since although we are
flexible with the order of operations, the product is always real numbers
But that expression
expressed as the addition of scalar a and scalar b
this means that all sets that fulfill the property of field
No matter rational number, complex number, or real number
satisfying commutativity, associativity, and distributivity
and having identity and inverse becomes the
satisfying condition for the number set that we can
use more freely and commonly
Based on this field set of numbers
we can expand to what we're going to learn next
vector
Function
Before learning the basics of function
let's see why we need to learn function first
The game we're going to make is at the end of the day
very closely related to the transformation of the game space
Creating a game is closely tied to numerous
space transformation processes
and the space transformation here
ultimately stems from
sets
and correspondence of sets
What explains the mechanism of this is function
so wee must know function well
and understand the concept well
so that we can use that as the basis to
understanding the space and transformation of spaces
Then let's get into function
The definition of function can be
When there are two sets, X and Y
a correspondence between the two sets
So element x from the first set X
corresponds to element y of the second set
then that is expressed as y=f(x)
This function
isn't just made from the correspondence only
there are more
First is that all elements of the first set
must be used
Let me try showing you an example of
correspondence that is not a function
As I mentioned
all elements of the first set must be used
That means an element of the first set
having no correspondence
makes that impossible to be considered a function
Next, when an element of the first set
corresponds to two elements of the second set
we also say that that doesn't satisfy the conditions of being a function
Let me explain using this diagram
Here, elements 3 and 4 of the first set X
has no correspondence
so it does not satisfy the conditions of a function
And the element 2 of the first set
corresponds to two elements B and C
of the second set
Therefore this also does not satisfy
the condition of being a function
Here, in this correspondence
what we need to know are function vocabularies
These vocabs are
Since function is a very basic field study
it is used in
very many places
so let's get into the vocabularies
We call the first set
the domain
and the corresponding second set
the codomain
Although all elements of the domain must correspond
the elements of the second set
need not
Therefore there will be cases where
only parts of the second set are corresponded, so
we make another set with only the corresponded elements
and that is called the range
That was the concept of domain
codomain, and range
This function, from a programming or mechanical point of view
similar to binary operation from lecture 1
is a system that gives
a new element
when we input one
So the input is
an element of the domain
and the output is
the corresponded element of the codomain
We can divide functions into group
according to the correspondence type
As you can see here, if the codomain
and the range are the same
So all elements of the codomain are corresponded
This case is called
surjection
Next is when elements of the domain and the codomain
are corresponded 1:1
which is injection
The surjection that I mentioned previously
has the element c which is corresponded
to two elements of the domain, 3, and 4
so this is not a 1:1 correspondence
Therefore this does not have the property of an injection
On the other hand for the injection
element c in the codomain is not corresponded
Therefore the codomain and the range
are different sets
Therefore this does not satisfy
the conditions of a surjection
Then what happens when it satisfies both surjection and injection?
Then all elements of
the domain and all elements of the codomain
are corresponded 1:1
This correspondence is called bijection
This satisfies both properties of
surjection and injection
Then is surjection, injection, and bijection all?
There are also correspondences that are neither of these three
You can see here this is not a surjection
because the codomain and the range is different
so it does not satisfy the condition of a surjection
and for element c
elements 3 and 4 are corresponded
so it also does not satisfy the condition of injection
which makes it just a normal function
Next let's see Cartesian product
Cartesian product
is picking elements from two different sets
and putting them together into an ordered pair
So it's a new set
made with elements from two sets
So like (a,b)
using parentheses and comma to express this
is called a tuple
Here, a is an element from set A
and b over here
is an element from set B
This is a new set
combining two sets
This Cartesian product
uses the multiplication sign, x
to the used sets
Let's see an example
Set a has two elements a and b
and set B has two elements 1 and 2
Using these sets to make a Cartesian product
will correspond 1 and 2 to a
so there will be new elements
(a,1) and (a,2)
For the second element b of set A
1 and 2 is corresponded again
which makes (b,1) and (b,2)
So the set composed of four elements in total
is made
and this is called the Cartesian product
Using the two sets
we write it as AxB
A good example of Cartesian product is
I brought this from Wikipedia
You can think of the Trump cards
The number on the Trump cards
can be one set
and the sign another set
These two sets R and S
made into a Cartesian product
which makes the Trump cards
composed of 52 cards
This Cartesian product concept
is used later on when we learn coordinate system
but it can be used in the binary operation concept as well
When we were learning function
there was only one input
but in binary operation
that we learned in the previous lecture
there were two inputs
So you might think that binary operation can be hard
to express in function forms
but if we use Cartesian products
on the domains
we can put two elements as inputs
so making one product with two inputs
is possible from binary operation to function as well
So for operations like a+b
done in real number set
the domain is made with a Cartesian product of real number set
R x R, like this
we make a ordered pair of two
and put each elements as inputs
to create the output
and we have a perfect system that does binary operation
as a function
Next is composition function
Composition is when there are two functions
and three sets
Here, from set X to set Z
exists a correspondence
In the case of element 4
it first corresponds to element D of the second set
through the first function f(x)
and then through g(y) it corresponds to
alpha of the third set
It proceeds step by step
If we get rid of the middle part
all elements 4, 3, and 2
correspond to alpha
So getting rid of the middle part
and going straight to
the last step
is what composition is
and this means that
two functions were composed
and the order is important here
First function f
and the second function g
but we write the first function on the right
so it becomes g ∘ f
Using parentheses
it performs f(x) first and then g(x)
so it's correct to have g on the left
but when we use this sign
you might confuse that g is performed first
But what's on the right is what's performed first
I hope you remember this so you don't get confused
Before getting into the properties of composite functions
let's first learn about some correspondence types
Codomain and domain
In bijection where domain and codomain are corresponded
So the elements of the domain, codomain, and range are the same
This correspondence is called
identity function
and uses i as the symbol
But identity was also mentioned before
It's the same, identity function
And we had also learned about the inverse
There is also a similar concept
in function
and this is called
inverse function
It is the same concept as inverse
This holds for bijection
So conversing a correspondence from the domain to the codomain
to one from the codomain to the domain
is the inverse function
This has some conditions
so let's take a look
First is when it's a surjection
Let's say that A,B, and C in the codomain
are conversely being corresponded to the domain
Then A is corresponded to 1 and B to 2
but C is corresponded to both 3 and 4
In this case, this does not satisfy the condition of a function
so an inverse function does not exist
Let's see the case of an injection
Here, A is corresponded to 1 and B to 2
but C doesn't have a correspondence
This again does not satisfy the condition of a function
so injection also does not have an inverse function
It does not exist
Lastly when it's a bijection
all elements are corresponded 1:1
and without anything left
so a bijection always
has its inverse function
So to make an inverse function
the function must be a
bijection
Remembering this condition
will help so I'll keep mentioning this
And when there is a function and its inverse function
this function must be a bijection as mentioned just before
When there is a bijection
what happens when we compose the inverse function?
This is the correspondence
that went to the codomain
coming back to the domain again
so it comes back to itself
therefor it has the same result
as the previously mentioned identity function
Therefore the composition of a bijection and its inverse function
always becomes an identity function
So this in symbols is
f ∘ f^-1 = i
Then let's see the inverse function
of composite function
Let's say we have two bijections
We said that performing f first and then g
was written as g ∘ f
The inverse of this composite function
as you can see in the diagram
is performing the inverse of g first
and then performing
the inverse of f
which is obvious
Therefore the inverse of g ∘ f
What's performed first is g^-1
so it must come on the right
and what's done second is f^-1
so it becomes
f^-1 ∘ g^-1
Why do we need to know the correspondence of composite functions?
Later when we deal with space transformations
we will use matrix
and matrix multiplication is
basically composite function
So understanding the mechanism
of composite function
becomes the basis for understanding
the complex mechanism of matrix multiplication
Therefore from basic knowledge
from sets and correspondence of sets
then composing them and how inverse works
learning these during this lecture
was for that reason
This is it for this lecture
Good job
Thank you
Structure of number Visualization of numbers Vectors, combinations of numbers compose game content system therefore understanding numbers is needed
Types of numbers: natural, integers, rational, irrational, real, complex numbers Must get used to the systems based on the origin to left and right
Binary operation Reconfiguration by replacing subtraction with addition and division with multiplication of the elementary arithmetics
Visualization of Addition: move points in parallel Visualization of multiplication: adjusting the fold and direction of increase from the origin
Properties of binary operations Commutativity, associativity, distributivity Identity: makes a's product a Inverse: makes a's product the identity
Field axiom Axiom: the most basic proposition that doesn not need proof Used axiom to analyse and build number structures
Real, rational, complex numbers satisfy field structure All numbers satisfying the field structure can be used
Function Basics of function Only when the concept of function is established can the transformation of space be understood correctly
Function: Correspondence of two sets Domain: First set Codomain: the corresponding second set Range: a set of corresponding elements in the codomain
Surjection: all elements of codomain are in the range Injection: domain and codomain correspond 1:1 Bijection: all elements correspond 1:1
Cartesian product Set of ordered pairs of elements from both two sets Using this as the domain allows binary operation to be expressed as functions
Composition Identity function: all elements correspond to itself Inverse function: inverse correspondence Bijection condition for inverse function
Transformations of space use matrices and matrix multiplication correspond to composite functions, making such knowledge necessary