LateralLongRangeOrientationConnectionPredicate.cpp

Go to the documentation of this file.
00001 
00012 #include "LateralLongRangeOrientationConnectionPredicate.h"
00013 
00014 #include <iostream>
00015 using std::cout;
00016 using std::cerr;
00017 using std::endl;
00018 
00019 LateralLongRangeOrientationConnectionPredicate::LateralLongRangeOrientationConnectionPredicate(
00020     double C,
00021     double sigma21,
00022     double kappa2,
00023     double mu2,
00024     bool toroid,
00025     double toroid_off,
00026     int src_shape_x, int src_shape_y,
00027     int dst_shape_x, int dst_shape_y,
00028     double src_scale,
00029     double dst_scale,
00030     double src_center_x, double src_center_y,
00031     double dst_center_x, double dst_center_y
00032     )
00033     : m_C(C)
00034     , m_sigma21(sigma21)
00035     , m_kappa2(kappa2)
00036     , m_mu2(mu2)
00037     , m_distance(toroid, toroid_off,
00038                     src_shape_x, src_shape_y,
00039                     dst_shape_x, dst_shape_y,
00040                     src_scale, dst_scale,
00041                     Point2D<double>(src_center_x, src_center_y),
00042                     Point2D<double>(dst_center_x, dst_center_y))
00043     , m_unirnd(0.0, 1.0)
00044 {
00045 }
00046 
00047 void LateralLongRangeOrientationConnectionPredicate::init(SimObjectPopulation const& src, SimObjectPopulation const& dst, RandomEngine *rnd)
00048 {
00049     AugmentedConnectionDecisionPredicate::init(src, dst, rnd);
00050 }
00051 
00052 bool LateralLongRangeOrientationConnectionPredicate::decide(size_t src, size_t dst, RandomEngine *rnd)
00053 {
00054     if (m_sourcePopulation->getID(src) == m_destinationPopulation->getID(dst))
00055         return false;
00056 
00057     Point2D<double> s(m_sourcePopulation->getLocation(src));
00058     Point2D<double> d(m_destinationPopulation->getLocation(dst));
00059 
00060     const SimObjectAttributes & src_attr = m_sourcePopulation->getAttributes(src);
00061     const SimObjectAttributes & dst_attr = m_destinationPopulation->getAttributes(dst);
00062     double sori=src_attr.get<double>(string("orientation"));
00063     double dori=dst_attr.get<double>(string("orientation"));
00064 
00065     double vdist2 = m_distance.sqr_distance(s, d);
00066 
00067     //mises distribution
00068     double phi = sori - dori - m_mu2;
00069     double V2 = exp(m_kappa2 * cos(2*phi))/exp(m_kappa2);
00070 
00071     //Gaussian part of ori-component
00072     double G21 = exp(-vdist2/(2.0 * m_sigma21*m_sigma21));
00073 
00074     return (m_unirnd(*rnd) < (V2 * G21 * m_C));
00075 }

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5