Friday, 17 October 2014

Continuation




Error Handling 

Error handling is the anticipation, detection and resolution of errors. The best types of error handling systems are able to recover from errors and return information on how those errors happened. You can also use breakpoints to find errors. While this does not return the specific error it help you to find the approximate point in which the error occurs.


There are three kinds of errors. Syntax errors are caused by the improper use of a function or character. Logic errors are caused through being given undesired results. These take a lot of time and effort to fix. Run time errors are caused through invalid input data in a function such as giving it and object to operate on that does not exist or is of an incorrect type.


Exception throwing is when a function cannot do what it is designed to do. It is known as an execution failure. Exceptions do not return error code but instead report errors in your framework.


 ex: if (b==0) throw Ad::Exception(“Divide by Zero”); c = a/b;


If an exception is thrown than it cannot be ignored. The exception will unwind the program stack until it finds the portion of the program that knows what to do with it. If nothing is found then the program will terminate, otherwise the program will continue to run.


 Try not to throw an exception but instead use an assertion.



Iterators (Basic Reminder)

An iterator is an object that points to something in a range of element. This can be something like a vector, and array or any other kind of container. It gets its name because it iterates through the elements of that range.

Wrappers

Wrappers are needed for many reasons. Using them we can change our interface, make our program more user friendly, hide low level code, change the internals of a program without altering the software and guarantee function behavior across multiple platforms. Is something is wrapped it also allows for new functions to use it in their functions.

Singleton

A singleton is something that exists as itself that cannot be multiple things. It is bad for code because you cannot have more than one of them.



Global Variables are Bad

Global variables are bad as they pollute your code, especially in a header. Also everybody has access to it and therefore can alter it making it a higher chance to bugger up your code.

Camera

Cameras have three vectors: direction, up and left. These are all perpendicular unit vectors. When you rotate a camera there are two methods. Assuming the up vector is right and assuming its wrong. In the second method you take the world up as your up vector. This will not work if you are looking directly up

Affine Transforms

An affine transformation is a function that keeps the ration between points, lines and planes. When an object goes through an affine transformation it is  identical to the original in its ratios between all the distances of each point. An affine transformation can be a translation, scale, reflection or rotation in any combination, order or sequence. This means that, for example, ever linear transformation would be an affine transformation, but not ever affine transformation would be a linear transformation. 


Affine Transformation (as reflection)




Homogeneous Co-ordinates


Homogeneous coordinates allow us to project 3D geometry in an euclidean space into our projective space

See:
http://deltaorange.com/2012/03/08/the-truth-behind-homogenous-coordinates/

No comments:

Post a Comment