Ejemplo n.º 1
0
Math::Matrix<4, 4>	Math::Matrix<4, 4>::rotation(double x, double y, double z)
{
  Math::Matrix<4, 4>	m_x = Math::Matrix<4, 4>::identite();
  Math::Matrix<4, 4>	m_y = Math::Matrix<4, 4>::identite();
  Math::Matrix<4, 4>	m_z = Math::Matrix<4, 4>::identite();

  // Convert parameters to radian
  x = Math::Utils::DegToRad(x);
  y = Math::Utils::DegToRad(y);
  z = Math::Utils::DegToRad(z);

  // Generate rotation matrix
  m_x(1, 1) = +std::cos(x);
  m_x(1, 2) = -std::sin(x);
  m_x(2, 1) = +std::sin(x);
  m_x(2, 2) = +std::cos(x);
  m_y(0, 0) = +std::cos(y);
  m_y(0, 2) = +std::sin(y);
  m_y(2, 0) = -std::sin(y);
  m_y(2, 2) = +std::cos(y);
  m_z(0, 0) = +std::cos(z);
  m_z(0, 1) = -std::sin(z);
  m_z(1, 0) = +std::sin(z);
  m_z(1, 1) = +std::cos(z);

  return m_z * m_y * m_x;
}
	inline Scalar operator()(Scalar const& x) const
	{
		// Check x value is in bounds
		assert( x >= m_x(0) && x <= m_x(m_N-1));
		// There muse be at least two data points
		assert(m_N>1);
		// Check that the input data has been provided
		assert(m_ready == true);

		// Intial bounding solutions
		Index klo,khi,k;
		klo = 0;
		khi = m_N-1;

		// Binary search for lower and upper bounding x values
		while (khi-klo > 1)
		{
			k=(khi+klo) >> 1;
			if(m_x(k) > x) {khi=k;}
			else           {klo=k;}
		}

		// Assert that the solutions are within the range of input x values
		assert(khi>=0 && klo>=0);
		assert(khi<m_N && klo<m_N);

		// Step regression: use the low-bounding x value to predict y
		return m_y(klo);
	}
Ejemplo n.º 3
0
      //! Get filter state value.
      //! @param pos matrix index.
      //! @return state matrix value.
      inline double
      getState(short pos) const
      {
        if ((size_t)pos >= m_state_count)
          throw std::runtime_error(DTR("invalid index"));

        return m_x(pos);
      }
	void setup(VectorXd const & xvals, VectorXd const & yvals)
	{
		// x,y data must be of the same size
		assert(xvals.rows()==yvals.rows());
		// There must be at least two data points
		assert(xvals.rows()>1);

		// Store x,y dats points
		m_x = xvals;
		m_y = yvals;
		m_N = xvals.rows();

		// Check data points are sorted in x
		for(Index i=1;i<m_N;i++) {assert(m_x(i) > m_x(i-1));}

		m_ready = true;
	}
Ejemplo n.º 5
0
double TimeSeriesLinePlotData::x(size_t pos) const
{
  return m_x(pos) + m_fracDaysOffset + m_minX; // hourly
}
Ejemplo n.º 6
0
// keys_edit: Keys for the 2d editor
// ------------------------------ >>
void keys_edit()
{
    if (!map.opened)
        return;

    // Scroll up
    if (binds.pressed("view_up"))
    {
        yoff += ((MAJOR_UNIT / (int)zoom)) + 1;
        force_map_redraw(true, true);
    }

    // Scroll down
    if (binds.pressed("view_down"))
    {
        yoff -= ((MAJOR_UNIT / (int)zoom)) + 1;
        force_map_redraw(true, true);
    }

    // Scroll left
    if (binds.pressed("view_left"))
    {
        xoff += ((MAJOR_UNIT / (int)zoom)) + 1;
        force_map_redraw(true, true);
    }

    // Scroll right
    if (binds.pressed("view_right"))
    {
        xoff -= ((MAJOR_UNIT / (int)zoom)) + 1;
        force_map_redraw(true, true);
    }

    // Zoom in
    if (binds.pressed("view_zoomin"))
        view_zoom(true);

    // Zoom out
    if (binds.pressed("view_zoomout"))
        view_zoom(false);

    // Center view on mouse
    if (binds.pressed("view_mousecenter"))
    {
        xoff = -m_x(mouse.x) / MAJOR_UNIT;
        yoff = -m_y(mouse.y) / MAJOR_UNIT;
        force_map_redraw(true, true);
    }

    // Set offsets to 0, 0
    if (binds.pressed("view_origin"))
    {
        xoff = yoff = 0;
        force_map_redraw(true, true);
    }

    // Vertices mode
    if (binds.pressed("mode_vertices"))
        change_edit_mode(0);

    // Linedefs mode
    if (binds.pressed("mode_linedefs"))
        change_edit_mode(1);

    // Sectors mode
    if (binds.pressed("mode_sectors"))
        change_edit_mode(2);

    // Things mode
    if (binds.pressed("mode_things"))
        change_edit_mode(3);

    // Change mode
    if (binds.pressed("mode_change"))
        cycle_edit_mode();

    // Increase grid size
    if (binds.pressed("view_increasegrid"))
    {
        increase_grid();
        force_map_redraw(false, true);
    }

    // Decrease grid size
    if (binds.pressed("view_decreasegrid"))
    {
        decrease_grid();
        force_map_redraw(false, true);
    }

    // Clear selection
    if (binds.pressed("edit_clearselection"))
    {
        clear_selection();
        force_map_redraw(true);
    }

    // Delete item
    if (binds.pressed("edit_deleteitem"))
    {
        if (edit_mode == 0)
            delete_vertex();

        if (edit_mode == 1)
            delete_line();

        if (edit_mode == 2)
            delete_sector();

        if (edit_mode == 3)
            delete_thing();

        force_map_redraw(true);
    }

    // Create item
    if (binds.pressed("edit_createitem"))
    {
        if (edit_mode == 0)
        {
            if (!selection())
                create_vertex();
            else
                create_lines(false);

            force_map_redraw(true);
            return;
        }

        if (edit_mode == 1)
        {
            if (selection())
                create_sector();

            force_map_redraw(true);
            return;
        }

        if (edit_mode == 3)
        {
            create_thing();
            force_map_redraw(true);
            return;
        }

        binds.clear("edit_createitem");
    }

    // Sector height quick changes (8 units)
    if (binds.pressed("sector_upfloor8"))
    {
        if (edit_mode == 2)
            sector_changeheight(true, 8);
    }

    if (binds.pressed("sector_downfloor8"))
    {
        if (edit_mode == 2)
            sector_changeheight(true, -8);
    }

    if (binds.pressed("sector_upceil8"))
    {
        if (edit_mode == 2)
            sector_changeheight(false, 8);
    }

    if (binds.pressed("sector_downceil8"))
    {
        if (edit_mode == 2)
            sector_changeheight(false, -8);
    }

    if (binds.pressed("sector_upboth8"))
    {
        if (edit_mode == 2)
        {
            sector_changeheight(true, 8);
            sector_changeheight(false, 8);
        }
    }

    if (binds.pressed("sector_downboth8"))
    {
        if (edit_mode == 2)
        {
            sector_changeheight(true, -8);
            sector_changeheight(false, -8);
        }
    }

    // Sector height quick changes (1 unit)
    if (binds.pressed("sector_upfloor"))
    {
        if (edit_mode == 2)
            sector_changeheight(true, 1);
    }

    if (binds.pressed("sector_downfloor"))
    {
        if (edit_mode == 2)
            sector_changeheight(true, -1);
    }

    if (binds.pressed("sector_upceil"))
    {
        if (edit_mode == 2)
            sector_changeheight(false, 1);
    }

    if (binds.pressed("sector_downceil"))
    {
        if (edit_mode == 2)
            sector_changeheight(false, -1);
    }

    if (binds.pressed("sector_upboth"))
    {
        if (edit_mode == 2)
        {
            sector_changeheight(true, 1);
            sector_changeheight(false, 1);
        }
    }

    if (binds.pressed("sector_downboth"))
    {
        if (edit_mode == 2)
        {
            sector_changeheight(true, -1);
            sector_changeheight(false, -1);
        }
    }

    // Flip line
    if (binds.pressed("line_flip"))
    {
        if (edit_mode == 1)
            line_flip(true, false);

        force_map_redraw(true);
    }

    // Swap line sides
    if (binds.pressed("line_swapsides"))
    {
        if (edit_mode == 1)
            line_flip(false, true);

        force_map_redraw(true);
    }

    // Flip both line direction and sides
    if (binds.pressed("line_flipboth"))
    {
        if (edit_mode == 1)
            line_flip(true, true);

        force_map_redraw(true);
    }

    // Begin line draw
    if (binds.pressed("line_begindraw"))
    {
        if (!line_draw)
            line_draw = true;

        binds.clear("line_begindraw");
    }

    // Begin rectangle draw
    if (binds.pressed("line_begindraw_rect"))
    {
        if (!line_draw)
        {
            line_draw = true;
            sel_box.set(mouse.x, mouse.y, mouse.x, mouse.y);
        }

        binds.clear("line_begindraw_rect");
    }

    // Undo
    if (binds.pressed("edit_undo"))
    {
        undo();
        clear_selection();
        hilight_item = -1;
        force_map_redraw(true, true);
        //map_changelevel(3);
        map.change_level(MC_NODE_REBUILD);
        binds.clear("edit_undo");
    }

    // Edit item
    if (binds.pressed("edit_edititem"))
    {
        edit_item();
        binds.clear("edit_edititem");
    }

    // Merge sectors
    if (binds.pressed("sector_merge"))
    {
        sector_merge(false);
        binds.clear("sector_merge");
    }

    // Join sectors
    if (binds.pressed("sector_join"))
    {
        sector_merge(true);
        binds.clear("sector_join");
    }

    if (binds.pressed("view_3dmode"))
    {
        binds.clear("view_3dmode");
        binds.clear("3d_exit");
        start_3d_mode();
    }

    if (binds.pressed("open_console"))
    {
        binds.clear("open_console");
        popup_console();
    }

    if (binds.pressed("copy"))
    {
        binds.clear("copy");
        clipboard.Copy();
    }

    if (binds.pressed("paste"))
    {
        binds.clear("paste");
        paste_mode = true;
        clear_selection();
    }

    if (binds.pressed("cancel_paste"))
    {
        binds.clear("cancel_paste");
        paste_mode = false;
        force_map_redraw(true, false);
    }
}