Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford


This notebook plots the function from the "perspective division" step in the viewing pipeline. It demonstrates how points in eye coordinates get mapped to NDC coordinates.

See Chapter 16: Background: Computer Graphics for details.

Updated May 2008

(* (<<"BarCharts`";<<"Histograms`";<<"PieCharts`") *)

(* Output results to folder that this file lives in *)
(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];) 

(* Create example near and far plane distances *)
(near=0.1`;) 
(far=4.`;) 

(* Define the function that maps eye to NDC z-coordinates *)
(zc[z_]=near+far-((near far)/z);) 

(* Plot the function for z behind and in front of the eye *)

Plot[zc[z],{z,-5,5},BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11},PlotStyle->{Thickness[0.009`]},AxesLabel->{"z-eye","z-NDC"}] 

(* Ouput plot to postscript *)
Export["persp_division.eps",%]