void HexLatticeGenerator::set(const Vector2& anchor, AnchorAlignEnum align, LatticeRowEnum dir,
                              float width, float density, size_t tgtPopulation, float angle) {
  _rowDir = dir;
  setRotationDeg(angle);
  float r = effectiveRadius(density);
  _rowDist = rankDistance(r);
  _nbrDist = 2.f * r;
  // Compute the layout of the agents for quick compute
  float actualWidth;
  switch (dir) {
    case ROW_X:
      _rowPop = (size_t)(width / _nbrDist);
      if (_rowPop == 0) ++_rowPop;
      _rowCount = (tgtPopulation / (2 * _rowPop - 1) + 1) * 2;
      _totalPop = (2 * _rowPop - 1) * (_rowCount / 2);
      if (_totalPop - (_rowPop - 1) > tgtPopulation) {
        _totalPop -= (_rowPop - 1);
        --_rowCount;
      }
      actualWidth = (_rowPop - 1) * _nbrDist;
      break;
    case ROW_Y:
      _rowCount = (int)(width / _rowDist);
      if (_rowCount == 0) ++_rowCount;
      _rowPop = tgtPopulation / _rowCount + 1;
      _totalPop = _rowCount * _rowPop;
      actualWidth = (_rowCount - 1) * _rowDist;
      break;
  }
  // Recompute _anchor based on _anchorAlign - essentially, change the anchor point
  //  such that the first agent is always placed at the origin.
  // This is the rotated displacement of the center/right corner to the origin
  if (align == CENTER) {
    _anchor = anchor - Vector2(_cosRot * actualWidth, _sinRot * actualWidth) * 0.5f;
  } else if (align == RIGHT_CORNER) {
    _anchor = anchor - Vector2(_cosRot * actualWidth, _sinRot * actualWidth);
  } else {
    // Don't need any modification for _align == LEFT
    _anchor = anchor;
  }
}
// event functions
//------------------------------------------------------------------------------
// onUpdateRotDeg() - update rotation (degrees)
//------------------------------------------------------------------------------
bool CompassRose::onUpdateRotDeg(const Basic::Number* const x)
{
    bool ok = false; 
    if (x != nullptr) ok = setRotationDeg(x->getReal());
    return ok;
}