GLTransform.h
Go to the documentation of this file.
00001 
00002 //      File:           GLTransform.h
00003 //      Author:         Changchang Wu
00004 //      Description : GLTransform tookit for opengl display
00005 //
00006 //
00007 //
00008 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00009 //      All Rights Reserved
00010 //
00011 //      Permission to use, copy, modify and distribute this software and its
00012 //      documentation for educational, research and non-profit purposes, without
00013 //      fee, and without a written agreement is hereby granted, provided that the
00014 //      above copyright notice and the following paragraph appear in all copies.
00015 //      
00016 //      The University of North Carolina at Chapel Hill make no representations
00017 //      about the suitability of this software for any purpose. It is provided
00018 //      'as is' without express or implied warranty. 
00019 //
00020 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00021 //
00023 #if !defined(GL_TRANSFORM_H)
00024 #define GL_TRANSFORM_H
00025 
00026 #include <math.h>
00027 class GlTransform
00028 {
00029 public:
00030         double          cx, cy;
00031         double          q[4];
00032         double          t[3];
00033         double          sc, ds;
00034         GlTransform()
00035         {
00036                 q[0]    =       1.0;
00037                 q[1]    =       q[2]    =       q[3]    =0;
00038                 t[0]    =       t[1]    =       t[2]    =0;
00039                 sc              =       1.0;
00040                 cx              =       cy              = 0;
00041         }
00042         void reset()
00043         {
00044                 q[0]    =       1.0;
00045                 q[1]    =       q[2]    =       q[3]    =0;
00046                 t[0]    =       t[1]    =       t[2]    =0;
00047                 sc              =       1.0;
00048         }
00049          void operator=(GlTransform& v)
00050          {
00051                 q[0]    =       v.q[0];
00052                 q[1]    =       v.q[1];
00053                 q[2]    =       v.q[2];
00054                 q[3]    =       v.q[3];
00055                 t[0]    =       v.t[0];
00056                 t[1]    =       v.t[1];
00057                 t[2]    =       v.t[3];
00058                 sc              =       v.sc;   
00059          }
00060          void operator *=(double scale)
00061          {
00062                 sc      *=      scale;
00063                 t[0]*=  scale;
00064                 t[1]*=  scale;
00065                 t[2]*=  scale;
00066          }
00067          void scaleset(double scale)
00068          {
00069                 double ds = scale/sc;
00070                 t[0]*=  ds;
00071                 t[1]*=  ds;
00072                 t[2]*=  ds;     
00073                 sc  = scale;
00074          }
00075          void scaleup()
00076          {
00077                 double scale;
00078                 if(sc < 6) scale = float(int(sc))+1;
00079                 else scale = sc * 2.0;
00080                 scaleset(scale);
00081          }
00082          void scaledown()
00083          {
00084                 double scale;
00085                 if(sc >1.0 &&sc < 2.0) scale = 1.0;
00086                 else scale = sc*0.5;
00087                 scaleset(scale);
00088          }
00089          void translate(int dx, int dy, int dz =0)
00090          {
00091                 t[0]    +=      dx;
00092                 t[1]    +=      dy;
00093                 t[2]    +=      dz;
00094          }
00095          void setcenter(double x, double y)
00096          {
00097                 cx = x;
00098                 cy = y;
00099                 t[0] = t[1] = t[2] = 0;
00100          }
00101 
00102          void transform(double es = 1.0)
00103          {
00104             double s = sc* es;
00105                 glTranslated(cx*es, cy*es, 0.0);
00106                 glTranslated(t[0] ,t[1] ,t[2]);
00107                 glScaled(s,s,s);
00108                 glTranslated(-cx, - cy, 0);
00109          }
00110 };
00111 
00112 #endif
00113 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


rgbd_registration
Author(s): Ross Kidson
autogenerated on Sun Oct 6 2013 12:00:40