jitter.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 1999-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Wed Apr  7 13:46:41 1999
00010 // commit: $Id: jitter.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/visx/jitter.cc $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_VISX_JITTER_CC_UTC20050626084016_DEFINED
00035 #define GROOVX_VISX_JITTER_CC_UTC20050626084016_DEFINED
00036 
00037 #include "visx/jitter.h"
00038 
00039 #include "geom/vec3.h"
00040 
00041 #include "gfx/canvas.h"
00042 
00043 #include "io/ioproxy.h"
00044 #include "io/reader.h"
00045 #include "io/writer.h"
00046 
00047 #include "rutz/rand.h"
00048 
00049 #include "rutz/trace.h"
00050 #include "rutz/debug.h"
00051 GVX_DBG_REGISTER
00052 
00053 namespace
00054 {
00055   const io::version_id JITTER_SVID = 3;
00056 }
00057 
00059 //
00060 // Jitter member functions
00061 //
00063 
00064 Jitter* Jitter::make()
00065 {
00066 GVX_TRACE("Jitter::make");
00067   return new Jitter;
00068 }
00069 
00070 Jitter::Jitter () :
00071   GxTransform(),
00072   itsXJitter(0.0), itsYJitter(0.0), itsRJitter(0.0),
00073   itsXShift(0.0), itsYShift(0.0), itsRShift(0.0)
00074 {
00075 GVX_TRACE("Jitter::Jitter");
00076   // empty
00077 }
00078 
00079 Jitter::~Jitter () throw()
00080 {
00081 GVX_TRACE("Jitter::~Jitter");
00082   // empty
00083 }
00084 
00085 io::version_id Jitter::class_version_id() const
00086 {
00087 GVX_TRACE("Jitter::class_version_id");
00088   return JITTER_SVID;
00089 }
00090 
00091 void Jitter::read_from(io::reader& reader)
00092 {
00093 GVX_TRACE("Jitter::read_from");
00094 
00095   reader.ensure_version_id("Jitter", 3,
00096                            "Try cvs tag xml_conversion_20040526",
00097                            SRC_POS);
00098 
00099   reader.read_value("jitterX", itsXJitter);
00100   reader.read_value("jitterY", itsYJitter);
00101   reader.read_value("jitterR", itsRJitter);
00102 
00103   reader.read_base_class("GxTransform", io::make_proxy<GxTransform>(this));
00104 }
00105 
00106 void Jitter::write_to(io::writer& writer) const
00107 {
00108 GVX_TRACE("Jitter::write_to");
00109 
00110   writer.ensure_output_version_id("Jitter", JITTER_SVID, 3,
00111                               "Try groovx0.8a4", SRC_POS);
00112 
00113   writer.write_value("jitterX", itsXJitter);
00114   writer.write_value("jitterY", itsYJitter);
00115   writer.write_value("jitterR", itsRJitter);
00116 
00117   writer.write_base_class("GxTransform", io::make_const_proxy<GxTransform>(this));
00118 }
00119 
00121 // actions //
00123 
00124 void Jitter::rejitter() const
00125 {
00126 GVX_TRACE("Jitter::rejitter");
00127   itsXShift = rutz::rand_range(-itsXJitter, itsXJitter);
00128   itsYShift = rutz::rand_range(-itsYJitter, itsYJitter);
00129   itsRShift = rutz::rand_range(-itsRJitter, itsRJitter);
00130 }
00131 
00132 void Jitter::draw(Gfx::Canvas& canvas) const
00133 {
00134 GVX_TRACE("Jitter::draw");
00135   rejitter();
00136   // Translate
00137   canvas.translate(translation +
00138                    geom::vec3<double>(itsXShift, itsYShift, 0.0));
00139 
00140   // Scale
00141   canvas.scale(scaling);
00142 
00143   // Rotate
00144   canvas.rotate(rotationAxis, itsRotationAngle+itsRShift);
00145 }
00146 
00147 static const char __attribute__((used)) vcid_groovx_visx_jitter_cc_utc20050626084016[] = "$Id: jitter.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00148 #endif // !GROOVX_VISX_JITTER_CC_UTC20050626084016_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:42 2008 by Doxygen version 1.5.5.