Showing posts with label notions.Algorithm. Show all posts
Showing posts with label notions.Algorithm. Show all posts

Thursday, August 11, 2016

Define: How to transform normal vector from local to eye space :-)

Define


In order to understand how normal vectors are transformed to eye space, think the normals as coefficients of Plane-Equations, which are perpendicular to the planes

Imagine a triangle polygon with 3 vertices;v1-v2-v3,and the normal of this surface is (Nx,Ny,Nz,Nw) as a homogeneous plane (for euclidean space, the normal is (Nx,Ny,Nz)). If we think of the triangle as a homogeneous plane, then the plane equation becomes;(by replacing x,y,z to X/W,Y/W,Z/W, then multiplying on both sides)


XNx + YNy + ZNz + WNw = 0

Since 3 vertices lie on this plane, the plane equation is also true when we substitute these vertices to the equation.For example, for
V1=(x1,y1,z1,w1), it satisfies:


x1Nx + y1Ny + z1Nz + w1Nw = 0

The equivalent matrix form of the plane equation is:



The Plane equation is multiplying the transposed normal (NT) and the vertex together..

Now, we modify the above equation to acquire normal vector transformation formula by inserting GL_MODELVIEW matrix (M-1M)  in between.



As you can see, the right part of the above equation  is transforming vertex to eye space, and the left part  is going to be the normal vector in eye space because the plane equation is also transformed.

It reads as "The transformed vertex  lies on the transformed plane  in eye coordinates space".


Therefore, transforming normal from object space to eye space with GL_MODELVIEW matrix M is; 



Or, by converting pre-multiplication to post-multiplication form, we get:





Sunday, June 5, 2016

Binary.Trees

Cited Tutorial
https://www.cs.cmu.edu/~adamchik/15-121/lectures/Trees/trees.html



More tree terminology:
  • The depth of a node is the number of edges from the root to the node.
  • The height of a node is the number of edges from the node to the deepest leaf.
  • The height of a tree is a height of the root.
  • A full binary tree.is a binary tree in which each node has exactly zero or two children.
  • A complete binary tree is a binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right.