On DevMaster.net I found a series of tutorials: Software Rendering School.
I’ve read first two parts – it is really amazing, everything is explained is a very simple language and does not require to remember the University mathematics.
Few nice things from the beginning:
- You may find an explanation what is the difference between the points and vertices – the points are simply random positions set by their coordinates, and vertices may have more data bound to them, vertices are positions bound to primitives like triangle.
- The basic operations you can perform with the points are translation, scaling and rotation.
- Translation is a simple movement:
new.x = point.x + translate.x;
new.y = point.y + translate.y;
new.z = point.z + translate.z
- The scaling is also a kind of a movement, but we multiply the coordinates:
new.x = point.x * scale.x;
new.y = point.y * scale.y;
new.z = point.z * scale.z;
- The most complex operation is the rotation:
//X-Rotation
new.x = v.x
new.y = v.y * cos(a) – v.z * sin(a)
new.z = v.y * sin(a) + v.z * cos(a)
//Y-Rotation
new.x = v.x * cos(a) – v.z * sin(a)
new.y = v.y
new.z = v.x * sin(a) + v.z * cos(a)
//Z-Rotation
new.x = v.x * cos(a) – v.y * sin(a)
new.y = v.y * sin(a) + v.x * cos(a)
new.z = v.z
- Vector, in the simplest way, can be described by its position, direction and magnitude.
- Dot product is cos of the angle between two vectors:
dot = v1.x * v2.x + v1.y + v2.y + v1.z * v2.z
dot = cos(a)
More about Dot Product: http://mathworld.wolfram.com/DotProduct.html
- Cross product of two vectors is another vector, which is perpendicular to both source vectors:
new.x = v1.y * v2.z – v2.z – v1.z
new.y = v2.x * v1.z – v1.x * v2.z
new.z = v1.x * v2.y – v2.x * v2.y
More about Cross Product: http://mathworld.wolfram.com/CrossProduct.html
And here is a joke about the subject:
Question: What do you get if you will cross an elephant and a grape?
Answer: elephant grape sine-of-theta
- Matrix is an object with a given number of rows and columns.
- Parallel projection:
x2 = x1 + viewportWidth / 2
y2 = –y1 + viewportHeight / 2
z2 = 0
- Perspective projection is clear when you know that
y2 / y1 = z2 / z1 = d / z
or
x2 / x1 = z2 / z1 = d / z
where d is the distance to the projection plane.
No comments:
Post a Comment