Point.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file Point.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date Fall 2008 00005 00006 @brief 00007 Provides basic functionality for a homogeneous point 00008 <!-------------------------------------------------------------------->**/ 00009 00010 // Point.h can be found in /course/cs123/include/algebra 00011 #include <Point.h> 00012 #include <math.h> 00013 00014 /// Homogenizes the point passed in such that the Nth value ("w") is one 00015 void homogenize(Point3 &p) { 00016 const real_t w = p[3]; 00017 00018 if (w == 0) { 00019 cerr << "\nError: " << "Attempting to homogenize a point when w = 0" << endl << endl; 00020 } else if (w != 1) { 00021 for(unsigned i = 3; i--;) 00022 p[i] /= w; 00023 00024 // Set w to 1 explicitly instead of dividing by itself to avoid errors 00025 // in floating point precision 00026 p[3] = 1; 00027 } 00028 } 00029 00030 template class Point<4, real_t>; 00031
Generated on 28 Feb 2009 for Milton by
1.5.6