Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

LocalizationParticleData.cc

Go to the documentation of this file.
00001 //-*-c++-*-
00002 
00003 #include <math.h>
00004 
00005 #include "LocalizationParticleData.h"
00006 #include "ShapeLocalizationParticle.h"
00007 #include "Sketch.h"
00008 
00009 using namespace std;
00010 
00011 namespace DualCoding {
00012 
00013 LocalizationParticleData::LocalizationParticleData(ShapeSpace& _space, 
00014                const ParticleFilter<LocalizationParticle>::particle_collection &_particles,
00015                ParticleFilter<LocalizationParticle>::index_t _index) :
00016   BaseData(_space, getStaticType()), particles(&_particles), index(_index) {
00017   obstacle = false;
00018 }
00019 
00020 LocalizationParticleData::LocalizationParticleData(const LocalizationParticleData &other) :
00021   BaseData(other), particles(other.particles), index(other.index) {}
00022 
00023 DATASTUFF_CC(LocalizationParticleData);
00024 
00025 Point LocalizationParticleData::getCentroid() const {
00026   return Point((*particles)[index].x, (*particles)[index].y, 0, space->getRefFrameType());
00027 }
00028 
00029 bool LocalizationParticleData::updateParams(const ShapeRoot&, bool) { return true; }
00030 
00031 void LocalizationParticleData::printParams() const {
00032   cout << "Type = " << getTypeName() << "  ID=" << getId() << "  ParentID=" << getParentId() << endl;
00033   cout << "  location{" << getCentroid().coordX() << ", " << getCentroid().coordY() << "}"
00034        << ", orientation = " << getOrientation() << endl;
00035 }
00036 
00037 bool LocalizationParticleData::isMatchFor(const ShapeRoot& other) const {
00038   if (!(isSameTypeAs(other) && isSameColorAs(other)))
00039     return false;
00040   const Shape<LocalizationParticleData>& other_particle = ShapeRootTypeConst(other,LocalizationParticleData);
00041   float dist = getCentroid().distanceFrom(other_particle->getCentroid());
00042   return dist < 20; // *** DST hack
00043 }
00044 
00045 LocalizationParticleData& LocalizationParticleData::operator=(const LocalizationParticleData &other) {
00046   if ( this != &other ) {
00047     BaseData::operator=(other);
00048     particles = other.particles;
00049     index = other.index;
00050   }
00051   return *this;
00052 }
00053 
00054 //! Render into a sketch space and return a pointer. (Private.)
00055 Sketch<bool>* LocalizationParticleData::render() const {
00056   SketchSpace &SkS = space->getDualSpace();
00057   fmat::Column<3> ctr(getCentroid().getCoords());
00058   SkS.applyTmat(ctr);
00059   int const cx = int(ctr[0]);
00060   int const cy = int(ctr[1]);
00061   Sketch<bool>& draw_result = 
00062     *new Sketch<bool>(SkS, "render("+getName()+")");
00063   draw_result = false;
00064   draw_result(cx,cy) = true;  
00065   return &draw_result;
00066 }
00067 
00068 
00069 } // namespace
00070 

DualCoding 5.1CVS
Generated Mon May 9 04:56:26 2016 by Doxygen 1.6.3