示例#1
0
 template <typename T> inline Math::Vector3<T> operator* (SymMatrix3<T> m, Math::Vector3<T> v) {
   return Math::Vector3<T> (
                            m.aa()*v.x() + m.ab()*v.y() + m.ac()*v.z(),
                            m.ab()*v.x() + m.bb()*v.y() + m.bc()*v.z(),
                            m.ac()*v.x() + m.bc()*v.y() + m.cc()*v.z()
                            );
 }
示例#2
0
  DipoleGeometry::DipoleGeometry (ldouble gridUnit,
                                  Math::Vector3<ldouble> periodicity1,
                                  Math::Vector3<ldouble> periodicity2)
    : box_ (0, 0, 0), matCount_ (0), validNvCount_ (0), origin_ (0, 0, 0),
      orientation_ (EMSim::Rotation<ldouble>::none ()),
      orientationInverse_ (EMSim::Rotation<ldouble>::none ()),
      gridUnit_ (gridUnit),
      periodicity1_ (periodicity1),
      periodicity2_ (periodicity2)
  {
    ASSERT (gridUnit >= 0);

    bool periodicity1IsZero = periodicity1.x () == 0 && periodicity1.y () == 0 && periodicity1.z () == 0;
    bool periodicity2IsZero = periodicity2.x () == 0 && periodicity2.y () == 0 && periodicity2.z () == 0;
    if (periodicity1IsZero) {
      ASSERT (periodicity2IsZero);
      periodicityDimension_ = 0;
    } else {
      if (periodicity2IsZero) {
        periodicityDimension_ = 1;
      } else {
        periodicityDimension_ = 2;
      }
    }

    gridUnitVol_ = gridUnit * gridUnit * gridUnit;
  }
示例#3
0
 void parse (StringParser& p, Math::Vector3<T>& out) {
   size_t start = p.pos ();
   p.expect (typeid (Math::Vector3<T>), start, '(');
   parse (p, out.x ());
   p.expect (typeid (Math::Vector3<T>), start, ',');
   parse (p, out.y ());
   p.expect (typeid (Math::Vector3<T>), start, ',');
   parse (p, out.z ());
   p.expect (typeid (Math::Vector3<T>), start, ')');
 }
示例#4
0
void TLens::set_thickness(double thickness, unsigned int index)
{
    double diff = thickness - get_thickness(index);

    for (unsigned int i = index; i < _surfaces.size(); i++)
    {
        Math::Vector3 p = _surfaces[i].get_local_position();
        p.z() += diff;
        _surfaces[i].set_local_position(p);
    }

    _last_pos += diff;
}
示例#5
0
 void Box::createDipoleGeometry (DipoleGeometry& dipoleGeometry) const {
   Math::Vector3<ldouble> size = this->size () / dipoleGeometry.gridUnit ();
   size_t mat = dipoleGeometry.materials ().size ();
   dipoleGeometry.materials ().push_back (material ());
   for (uint32_t z = 0; z < size.z (); z++) {
     for (uint32_t y = 0; y < size.y (); y++) {
       for (uint32_t x = 0; x < size.x (); x++) {
         ASSERT (mat <= 255);
         dipoleGeometry.addDipole (x, y, z, static_cast<uint8_t> (mat));
       }
     }
   }
   dipoleGeometry.moveToCenter ();
 }
示例#6
0
  void DipoleGeometry::normalize () {
    if (nvCount () == 0)
      return;

    Math::Vector3<uint32_t> min = Math::Vector3<uint32_t> (std::numeric_limits<uint32_t>::max (), std::numeric_limits<uint32_t>::max (), std::numeric_limits<uint32_t>::max ());

    for (uint32_t i = 0; i < nvCount (); i++) {
      Math::Vector3<uint32_t> coords = getGridCoordinates (i);
      if (coords.x () < min.x ())
        min.x () = coords.x ();
      if (coords.y () < min.y ())
        min.y () = coords.y ();
      if (coords.z () < min.z ())
        min.z () = coords.z ();
    }

    if (min != Math::Vector3<uint32_t> (0, 0, 0)) {
      for (uint32_t i = 0; i < nvCount (); i++) {
        positions_[i] -= min;
      }
      box_ -= min;
      origin () += min * gridUnit ();
    }
  }
示例#7
0
 void set (std::vector<U>& vector, size_t index, const Math::Vector3<U>& value) const {
     vector[index] = value.x ();
     vector[index + vecStride ()] = value.y ();
     vector[index + 2 * vecStride ()] = value.z ();
 }