Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

utilityfuncs.cpp

00001 #include <math.h>
00002 #include "utilityfuncs.h"
00003 
00004 sVector3f sVector3f::operator = (sVector3f v)
00005 { 
00006     x = v.x; 
00007     y = v.y;
00008     z = v.z; 
00009     
00010     return *this;
00011 }
00012 
00013 sPoint3f sPoint3f::operator = (sPoint3f p)
00014 { 
00015     x = p.x; 
00016     y = p.y;
00017     z = p.z; 
00018     
00019     return *this;
00020 }
00021 
00022 sPoint3f operator + (sPoint3f c1, sVector3f c2)
00023 {
00024    sPoint3f c;
00025 
00026    c.x = c1.x + c2.x;
00027    c.y = c1.y + c2.y;
00028    c.z = c1.z + c2.z;
00029 
00030    return c;
00031 }
00032 
00033 sPoint3f operator - (sPoint3f c2, sPoint3f c1)
00034 {
00035    sPoint3f c;
00036    c.x = c2.x + c1.x;
00037    c.y = c2.y + c1.y;
00038    c.z = c2.z + c1.z;
00039 
00040    return c;
00041 }
00042 
00043 float dot(sVector3f v1, sVector3f v2)
00044 {
00045     //
00046     //  Input v1 and v2 should be normalized/unit vectors, for phong shading model.
00047     //
00048     return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z);
00049 }
00050 
00051 sGrad sGrad::operator= (sVector3f v)
00052 {
00053     x = v.x;
00054     y = v.y;
00055     z = v.z;
00056 
00057     return *this;
00058 }
00059 
00060 sGrad operator + (sGrad g1, sGrad g2)
00061 {
00062     sGrad c;
00063 
00064     c.x = g1.x + g2.x;
00065     c.y = g1.y + g2.y;
00066     c.z = g1.z + g2.z;
00067 
00068     return c;
00069 }
00070 
00071 sGrad operator / (sGrad g1, float k)
00072 {
00073     sGrad c;
00074 
00075     c.x = g1.x / k;
00076     c.y = g1.y / k;
00077     c.z = g1.z / k;
00078 
00079     return c;
00080 }
00081 
00082 sGrad operator * (sGrad g1, float k)
00083 {
00084     sGrad c;
00085 
00086     c.x = g1.x * k;
00087     c.y = g1.y * k;
00088     c.z = g1.z * k;
00089 
00090     return c;
00091 }
00092 
00093 sRGBA sRGBA::operator+= (sRGBA v)
00094 {
00095     sRGBA c;
00096 
00097     r += v.r;
00098     g += v.g;
00099     b += v.b;
00100     a += v.a;
00101 
00102     return *this;
00103 }
00104 
00105 

Generated on Mon Dec 12 15:20:26 2005 for CCube by  doxygen 1.4.1