arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

simPow.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     3-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 
00019 /// simPow.h
00020 
00021 /// some power of two stuff
00022 
00023 #ifndef __SIMIAN_POWERS_DOT_H
00024 #define __SIMIAN_POWERS_DOT_H
00025 
00026 #include <mathGutz.h>
00027 
00028 ///////////////////////////////////////////////////////////////////////////
00029 /// next pow 2, unsigned int
00030 ///////////////////////////////////////////////////////////////////////////
00031 inline 
00032 unsigned int getNextPow2(unsigned int v)
00033 {
00034    unsigned int curv = 1;
00035    while(curv < v) curv = curv << 1;
00036    return curv;
00037 }
00038 
00039 ///////////////////////////////////////////////////////////////////////////
00040 /// next pow 2, vec3ui
00041 ///////////////////////////////////////////////////////////////////////////
00042 inline
00043 gutz::vec3ui getNextPow2(gutz::vec3ui v)
00044 {
00045    return gutz::vec3ui(getNextPow2(v.x),getNextPow2(v.y),getNextPow2(v.z));
00046 }
00047 
00048 inline
00049 gutz::vec3i getNextPow2(gutz::vec3i v)
00050 {
00051    return gutz::vec3i(getNextPow2(v.x),getNextPow2(v.y),getNextPow2(v.z));
00052 }
00053 
00054 ///////////////////////////////////////////////////////////////////////////
00055 /// is pow 2, unsigned int
00056 ///////////////////////////////////////////////////////////////////////////
00057 inline 
00058 bool isPow2(unsigned int v)
00059 {
00060    return (getNextPow2(v) == v);
00061 }
00062 
00063 ///////////////////////////////////////////////////////////////////////////
00064 /// is pow 2, vec3ui
00065 ///////////////////////////////////////////////////////////////////////////
00066 inline
00067 bool isPow2(gutz::vec3ui v)
00068 {
00069    return (isPow2(v.x) && isPow2(v.y) && isPow2(v.z));
00070 }
00071 
00072 #endif
00073 

Send questions, comments, and bug reports to:
jmk