DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_point.h00001 /*****************************************************************************/ 00002 // Copyright 2006 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/workarea/stern/camera_raw/dng_sdk/source/dng_point.h#5 $ */ 00010 /* $DateTime: 2008/11/03 15:23:07 $ */ 00011 /* $Change: 518613 $ */ 00012 /* $Author: stern $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_point__ 00017 #define __dng_point__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_types.h" 00022 #include "dng_utils.h" 00023 00024 /*****************************************************************************/ 00025 00026 class dng_point 00027 { 00028 00029 public: 00030 00031 int32 v; 00032 int32 h; 00033 00034 public: 00035 00036 dng_point () 00037 : v (0) 00038 , h (0) 00039 { 00040 } 00041 00042 dng_point (int32 vv, int32 hh) 00043 : v (vv) 00044 , h (hh) 00045 { 00046 } 00047 00048 bool operator== (const dng_point &pt) const 00049 { 00050 return (v == pt.v) && 00051 (h == pt.h); 00052 } 00053 00054 bool operator!= (const dng_point &pt) const 00055 { 00056 return !(*this == pt); 00057 } 00058 00059 }; 00060 00061 /*****************************************************************************/ 00062 00063 class dng_point_real64 00064 { 00065 00066 public: 00067 00068 real64 v; 00069 real64 h; 00070 00071 public: 00072 00073 dng_point_real64 () 00074 : v (0.0) 00075 , h (0.0) 00076 { 00077 } 00078 00079 dng_point_real64 (real64 vv, real64 hh) 00080 : v (vv) 00081 , h (hh) 00082 { 00083 } 00084 00085 dng_point_real64 (const dng_point &pt) 00086 : v ((real64) pt.v) 00087 , h ((real64) pt.h) 00088 { 00089 } 00090 00091 bool operator== (const dng_point_real64 &pt) const 00092 { 00093 return (v == pt.v) && 00094 (h == pt.h); 00095 } 00096 00097 bool operator!= (const dng_point_real64 &pt) const 00098 { 00099 return !(*this == pt); 00100 } 00101 00102 dng_point Round () const 00103 { 00104 return dng_point (Round_int32 (v), 00105 Round_int32 (h)); 00106 } 00107 00108 }; 00109 00110 /*****************************************************************************/ 00111 00112 inline dng_point operator+ (const dng_point &a, 00113 const dng_point &b) 00114 00115 00116 { 00117 00118 return dng_point (a.v + b.v, 00119 a.h + b.h); 00120 00121 } 00122 00123 /*****************************************************************************/ 00124 00125 inline dng_point_real64 operator+ (const dng_point_real64 &a, 00126 const dng_point_real64 &b) 00127 00128 00129 { 00130 00131 return dng_point_real64 (a.v + b.v, 00132 a.h + b.h); 00133 00134 } 00135 00136 /*****************************************************************************/ 00137 00138 inline dng_point operator- (const dng_point &a, 00139 const dng_point &b) 00140 00141 00142 { 00143 00144 return dng_point (a.v - b.v, 00145 a.h - b.h); 00146 00147 } 00148 00149 /*****************************************************************************/ 00150 00151 inline dng_point_real64 operator- (const dng_point_real64 &a, 00152 const dng_point_real64 &b) 00153 00154 00155 { 00156 00157 return dng_point_real64 (a.v - b.v, 00158 a.h - b.h); 00159 00160 } 00161 00162 /*****************************************************************************/ 00163 00164 inline real64 DistanceSquared (const dng_point_real64 &a, 00165 const dng_point_real64 &b) 00166 00167 00168 { 00169 00170 dng_point_real64 diff = a - b; 00171 00172 return (diff.v * diff.v) + (diff.h * diff.h); 00173 00174 } 00175 00176 /*****************************************************************************/ 00177 00178 inline dng_point Transpose (const dng_point &a) 00179 { 00180 00181 return dng_point (a.h, a.v); 00182 00183 } 00184 00185 /*****************************************************************************/ 00186 00187 inline dng_point_real64 Transpose (const dng_point_real64 &a) 00188 { 00189 00190 return dng_point_real64 (a.h, a.v); 00191 00192 } 00193 00194 /*****************************************************************************/ 00195 00196 #endif 00197 00198 /*****************************************************************************/ |