Ejemplo n.º 1
0
 public InterpolationParameterController(InterpolationParameters parameters)
 {
     _doc                   = parameters;
     _numberOfPoints        = parameters.NumberOfPoints;
     _xOrg                  = parameters.XOrg;
     _xEnd                  = parameters.XEnd;
     _interpolationInstance = parameters.InterpolationInstance;
 }
    public InterpolationParameterController(InterpolationParameters parameters)
    {
      _doc = parameters;
      _numberOfPoints = parameters.NumberOfPoints;
      _xOrg = parameters.XOrg;
      _xEnd = parameters.XEnd;
      _interpolationInstance = parameters.InterpolationInstance;
      

    }
Ejemplo n.º 3
0
    public static void Interpolation(WorksheetController ctrl)
    {
      if(ctrl.SelectedDataColumns.Count==0)
        return;

      object paramobject = new InterpolationParameters();

      if(!Current.Gui.ShowDialog(ref paramobject,"Interpolation"))
        return;

      InterpolationParameters parameters = (InterpolationParameters)paramobject;


      Altaxo.Data.DataColumn yCol = ctrl.Doc.DataColumns[ctrl.SelectedDataColumns[0]];
      Altaxo.Data.DataColumn xCol = ctrl.Doc.DataColumns.FindXColumnOf(yCol);

      if(!(yCol is INumericColumn))
      {
        Current.Gui.ErrorMessageBox("The selected column is not numeric!");
        return;
      }
      if(!(xCol is INumericColumn))
      {
        Current.Gui.ErrorMessageBox("The x-column of the selected column is not numeric!");
        return;
      }

      int rows = Math.Min(xCol.Count,yCol.Count);
      IROVector yVec = DataColumnWrapper.ToROVector((INumericColumn)yCol,rows);
      IROVector xVec = DataColumnWrapper.ToROVector((INumericColumn)xCol,rows);

      parameters.InterpolationInstance.Interpolate(xVec,yVec);

      DoubleColumn xRes = new DoubleColumn();
      DoubleColumn yRes = new DoubleColumn();

      for(int i=0; i<parameters.NumberOfPoints;i++)
      {
        double r = i/(double)(parameters.NumberOfPoints-1);
        double x = parameters.XOrg*(1-r) + parameters.XEnd*(r);
        double y = ((IInterpolationFunction)parameters.InterpolationInstance).GetYOfX(x);
        xRes[i]=x;
        yRes[i]=y;
      }

      int newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber();
      ctrl.DataTable.DataColumns.Add(xRes,xCol.Name+".I",ColumnKind.X,newgroup);
      ctrl.DataTable.DataColumns.Add(yRes,yCol.Name+".I",ColumnKind.V,newgroup);

    }