Ray Tracking in C# and .NET Updated
In this article, the author adds (fixes) new features to the code.
In the c# section: graphics, the article Ray Tracing in C# and .NET the author Mike Gold does an excellent job of demonstrating a small non-recursive ray trace program using a single simple object (sphere or plane).
The example program has at least the following errors:
Does draw the specified background color correctly ( When a ray does not intersect the sphere the value of vector v is undefined and is used to position the background color).
Does not properly center the object in the window and uses a hand-coded-fudge-factor to scale the image to the window.
Does not draw the shading on the correct side of the object (draws backside color in the wrong quadrant of the circle)
It is necessary to computer t=min(t1,t2) rather than just set t = t2 (see code) This corrects selecting wrong side of object to draw.
TheCamera object, all instances of from should be replaced with to object
Other minor items :
The code submitted with this article corrects all these errors in the code related to drawing the sphere.