simpleVectors.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   See Doc/copyright/copyright.txt
00006   or http://www.slicer.org/copyright/copyright.txt for details.
00007 
00008   Program:   3D Slicer
00009   Module:    $RCSfile: simpleVectors.h,v $
00010   Date:      $Date: 2006/05/26 19:59:40 $
00011   Version:   $Revision: 1.3 $
00012 
00013 =========================================================================auto=*/
00014 /*===========================================================
00015   
00016 Authors: Michael McKenna, David Small, Steve Pieper.
00017     Small Design Firm, Inc.,
00018     in association with Isomics, Inc.,
00019     and Partners Health Care.  MA, USA.
00020     June, 2004
00021 
00022 ===========================================================*/
00023 
00024 
00025 #ifndef __simpleVectors_h
00026 #define __simpleVectors_h
00027 
00028 #include "stdio.h"
00029 
00030 template <typename T>
00031 struct Vector2D
00032 {
00033 public:
00034     Vector2D(T x, T y) {
00035         set(x, y); 
00036     }
00037 
00038     Vector2D() {};
00039 
00040     void set(T x, T y) { 
00041         values[0] = x; 
00042         values[1] = y;
00043     }
00044 
00045     void print() {
00046         printf("Vector2D: %g %g\n", values[0], values[1]);
00047     }
00048 
00049     T&  operator [](int i) { 
00050         return values[i];
00051     }
00052 
00053     const T&  operator [](int i) const {
00054         return values[i];
00055     }
00056 
00057     T values[2];
00058 };
00059 
00060 
00061 template <typename T>
00062 struct Vector3D
00063 {
00064 public:
00065     Vector3D(T x, T y, T z) {
00066         set(x, y, z);
00067     }
00068 
00069     Vector3D() {};
00070 
00071     void set(T x, T y, T z) {
00072         values[0] = x;
00073         values[1] = y;
00074         values[2] = z; 
00075     }
00076 
00077     void print() {
00078         printf("Vector3D: %g %g %g\n", values[0], values[1], values[2]);
00079     }
00080 
00081     T&  operator [](int i) {
00082         return values[i];
00083     }
00084 
00085     const T&  operator [](int i) const {
00086         return values[i];
00087     }
00088 
00089     T values[3];
00090 };
00091 
00092 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1