Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATPoint.h Source File

CATPoint.h

Go to the documentation of this file.
00001 /// \file CATPoint.h
00002 /// \brief Point class, mainly for small sets for clarity of code.
00003 /// \ingroup CAT
00004 ///
00005 /// Copyright (c) 2002-2008 by Michael Ellison.
00006 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00007 ///
00008 // $Author: mikeellison $
00009 // $Date: 2008-01-19 19:19:35 -0600 (Sat, 19 Jan 2008) $
00010 // $Revision:   $
00011 // $NoKeywords: $
00012 #ifndef CATPOINT_H
00013 #define CATPOINT_H
00014 
00015 #include "CATTypes.h"
00016 #include <math.h>
00017 
00018 /// \class CATPoint
00019 /// \brief 2d point class w/size, mainly for small sets for clarity of code.
00020 /// \ingroup CAT
00021 class CATPoint
00022 {
00023     public:
00024         CATPoint( const CATPoint& point)
00025         {
00026             x=point.x;
00027             y=point.y;
00028             size=point.size;
00029         }
00030 
00031         CATPoint( CATFloat64 xp, CATFloat64 yp, CATFloat64 sizep=0.0)
00032         {
00033             x = xp;
00034             y = yp;
00035             size = sizep;
00036         }
00037 
00038         CATPoint()
00039         {
00040             Clear();
00041         }
00042 
00043         void Clear()
00044         {
00045             x = 0.0;
00046             y = 0.0;
00047             size = 0.0;
00048         }
00049 
00050         virtual ~CATPoint() 
00051         {
00052         
00053         }
00054 
00055         
00056         CATPoint operator+(const CATPoint& npoint)
00057         {
00058             CATPoint point(*this);
00059             point.x += npoint.x;
00060             point.y += npoint.y;
00061             // size doesn't change.
00062             return point;
00063         }
00064 
00065         CATPoint operator-(const CATPoint& npoint)
00066         {
00067             CATPoint point(*this);
00068             point.x -= npoint.x;
00069             point.y -= npoint.y;
00070             // size doesn't change.
00071             return point;
00072         }
00073 
00074         CATPoint& operator=(const CATPoint& npoint)
00075         {
00076             x = npoint.x;
00077             y = npoint.y;
00078             size = npoint.size;
00079             return *this;
00080         }
00081 
00082         CATPoint operator*(CATFloat64 scaler)
00083         {
00084             CATPoint point(*this);
00085             point.x *= scaler;
00086             point.y *= scaler;
00087             // size doesn't change.
00088             return point;
00089         }
00090 
00091         CATPoint operator/(CATFloat64 scaler)
00092         {
00093             CATPoint point(*this);
00094             point.x /= scaler;
00095             point.y /= scaler;
00096             // size doesn't change.
00097             return point;
00098         }
00099 
00100         CATPoint operator*(const CATPoint& npoint)
00101         {
00102             CATPoint point(*this);
00103             point.x *= npoint.x;
00104             point.y *= npoint.y;
00105             // size doesn't change.
00106             return point;
00107         }
00108         
00109     public:
00110         CATFloat64 x;
00111         CATFloat64 y;
00112         // Size has a variety of uses - right now, using for size of lines in line checks
00113         CATFloat64 size;        
00114 };
00115 
00116 /// \class CATScanPoint
00117 /// \brief Cartesian 3D point, used in 3d scanner and the like. Has color
00118 /// \ingroup CAT
00119 class CATScanPoint
00120 {
00121     public:
00122         CATScanPoint( const CATScanPoint& point)
00123         {
00124             y           =   point.y;
00125             z           =   point.z;
00126             rotation =  point.rotation;
00127             color       =   point.color;
00128         }
00129 
00130         CATScanPoint( CATFloat64 yp, CATFloat64 zp, CATFloat64 rot_deg = 0, CATUInt32 colorp = 0)
00131         {           
00132             y           = yp;
00133             z           = zp;
00134             rotation = rot_deg;
00135             color       = colorp;           
00136         }
00137 
00138         CATScanPoint()
00139         {           
00140             y           = 0.0;
00141             z           = 0.0;
00142             color       = 0;
00143             rotation = 0.0;         
00144         }
00145 
00146         virtual ~CATScanPoint() 
00147         {
00148         
00149         }
00150     
00151         CATScanPoint& operator=(const CATScanPoint& npoint)
00152         {           
00153             y           = npoint.y;
00154             z           = npoint.z;
00155             rotation = npoint.rotation;
00156             color       = npoint.color;         
00157             return *this;
00158         }
00159 
00160     public:
00161         CATFloat64 y;
00162         CATFloat64 z;
00163         CATFloat64 rotation;
00164         CATUInt32 color;        
00165 };
00166 
00167 
00168 /// \class CAT3DPoint
00169 /// \brief 3D point, with color and size
00170 /// \ingroup CAT
00171 class CATC3DPoint
00172 {
00173     public:
00174         CATC3DPoint( const CATC3DPoint& point)
00175         {
00176             x       =   point.x;
00177             y       =   point.y;
00178             z       =   point.z;
00179             color = point.color;
00180             size  =  point.size;            
00181         }
00182 
00183         CATC3DPoint( CATFloat64 xp, CATFloat64 yp, CATFloat64 zp, CATFloat64 sizep = 0, CATUInt32 colorp = 0)
00184         {
00185             x = xp;
00186             y = yp;
00187             z = zp;
00188             color = colorp;
00189             size = sizep;           
00190         }
00191 
00192         CATC3DPoint()
00193         {
00194             x       = 0.0;
00195             y       = 0.0;
00196             z       = 0.0;
00197             color = 0;
00198             size  = 0.0;            
00199         }
00200 
00201         virtual ~CATC3DPoint() 
00202         {
00203         
00204         }
00205     
00206         CATC3DPoint& FromScannedPolar( CATFloat64 yp, CATFloat64 zp, CATFloat64 theta_degrees, CATUInt32 colorp)
00207         {   
00208             // color remains unchanged
00209             color = colorp;
00210 
00211             // our y axis will remain unchanged (y does not change as the stage rotates)
00212             y = yp;
00213             
00214             // x is 0 for each scan - the theta changes
00215             CATFloat64 x1 = 0.0;
00216 
00217             // Our data is all set with 6.0 as the center... should probably fix that elsewhere, but for now...         
00218             // z1 is our calulated position on the stage
00219             CATFloat64 z1 = zp - 6.0;   
00220 
00221             // convert degrees to rads 
00222             CATFloat64 thetaRads = theta_degrees*kCATDEGTORAD;
00223 
00224             // Now rotate around y axis
00225             x = z1*sin(thetaRads);
00226             z = z1*cos(thetaRads);
00227             // size doesn't change
00228             return *this;
00229         }
00230         
00231         // Right now, arithmetics don't affect color.
00232         CATC3DPoint operator+(const CATC3DPoint& npoint)
00233         {
00234             CATC3DPoint point(*this);
00235             point.x += npoint.x;
00236             point.y += npoint.y;
00237             point.z += npoint.z;
00238             // size doesn't change
00239             return point;
00240         }
00241 
00242         CATC3DPoint operator-(const CATC3DPoint& npoint)
00243         {
00244             CATC3DPoint point(*this);
00245             point.x -= npoint.x;
00246             point.y -= npoint.y;
00247             point.z -= npoint.z;
00248             // size doesn't change
00249             return point;
00250         }
00251 
00252         CATC3DPoint& operator=(const CATC3DPoint& npoint)
00253         {
00254             x = npoint.x;
00255             y = npoint.y;
00256             z = npoint.z;
00257             color = npoint.color;
00258             size = npoint.size;
00259             return *this;
00260         }
00261 
00262         CATC3DPoint operator*(CATFloat64 scaler)
00263         {
00264             CATC3DPoint point(*this);
00265             point.x *= scaler;
00266             point.y *= scaler;
00267             point.z *= scaler;
00268             // size doesn't change
00269             return point;
00270         }
00271 
00272         CATC3DPoint operator/(CATFloat64 scaler)
00273         {
00274             CATC3DPoint point(*this);
00275             point.x /= scaler;
00276             point.y /= scaler;
00277             point.z /= scaler;
00278             // size doesn't change
00279             return point;
00280         }
00281 
00282         CATC3DPoint operator*(const CATC3DPoint& npoint)
00283         {
00284             CATC3DPoint point(*this);
00285             point.x *= npoint.x;
00286             point.y *= npoint.y;
00287             point.z *= npoint.z;
00288             // size doesn't change
00289             return point;
00290         }
00291         
00292     public:
00293         CATFloat64 x;
00294         CATFloat64 y;
00295         CATFloat64 z;
00296         CATFloat64 size;
00297         CATUInt32 color;        
00298 };
00299 #endif // CATPOINT_H

Generated on Mon Feb 11 04:09:46 2008 for Game Accessibility Suite by doxygen 1.5.4