Skip to content

unitycoder/Math-For-Games-using-Unity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Math-For-Games-using-Unity

Mathematics for Computer Games Development using Unity

1. Introduction and Welcome

Properties of Right Angle Triangles

right angle triangle

A right angle triangle has three sides denoted the hypotenuse for the longest side (the side opposite the right angle) and two others known as the adjacent or opposite depending on their relationship to the angles. For example, for the angle β, b would be opposite and a would be adjacent. For the other angle the roles of a and b would be reversed.

The formula are:

formulas

2. Bitwise Operations

basicbitwice

  • Example of use this:

example1

Bit Packing

For example: We have a three values A = 1001111, B = 10110, C = 0011 (Length of these values = 16); And we want to pack these values into 16-bit value X:

  • A = 1001111 packing into 16-bit X value:

packingA

  • B = 10110 packing into 16-bit X Value:

packingB

  • C = 0011 packing into 16-bit X value:

packingC

  • Another Example: put three values into INTEGER (32-bit value):

packingInt

Bit UnPacking

For unpacking bits we need create a mask that will get all of the you're interested in for each value, and shifting to right. Example:

  • UnPack to A(7-bit) from X(16-bit):

UnpackingA

UnpackingA2

  • UnPack to B(5-bit) from X(16-bit):

packingB

  • UnPack to C(4-bit) from X(16-bit):

packingC

  • If you need to Toggling of Bits, you need use XOR (^) operation

togglinXOR

About

Mathematics for Computer Games Development using Unity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.8%
  • Other 0.2%