当前位置: 首页>>代码示例>>C++>>正文


C++ dMatrix::GetNumberRows方法代码示例

本文整理汇总了C++中dMatrix::GetNumberRows方法的典型用法代码示例。如果您正苦于以下问题:C++ dMatrix::GetNumberRows方法的具体用法?C++ dMatrix::GetNumberRows怎么用?C++ dMatrix::GetNumberRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dMatrix的用法示例。


在下文中一共展示了dMatrix::GetNumberRows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetCoordinates

dMatrix clSpline::GetCoordinates(const dMatrix &uSpec)
{
  dMatrix coord;

  if(uSpec.GetNumberColumns() != 1 || uSpec.GetNumberRows() == 0)
  {
    throw clException("clSpline", "GetCoordinates", "Invalid dimensions of matrix uSpec.");
  }
  else
  {
    coord.SetNumberRows(uSpec.GetNumberRows());
    coord.SetNumberColumns(3);

    if(!initialised)
    {
      Initialise();
    }

    // Do for all specified u's
    for(int i=1; i<=uSpec.GetNumberRows(); i++)
    {
      if(uSpec(i, 1) < 0 || uSpec(i, 1) > 1)
      {
        throw clException("clSpline", "GetCoordinates", "Invalid value for uSpec.");
      }
      else
      {
        // Now find the position of uSpec
        double uu = uSpec(i, 1)*GetSplineLength();

        int j = 1;
        while((uu - u(j+1, 1) > 0) && (j<u.GetNumberRows()-1))
        {
          j++;
        }

        // Now calculate the coefficients
        double A = (u(j+1, 1)-uu)/(u(j+1, 1)-u(j,1));
        double B = 1-A;
        double C = (A*A*A-A)/6 * (u(j+1, 1)-u(j, 1))*(u(j+1, 1)-u(j, 1));
        double D = (B*B*B-B)/6 * (u(j+1, 1)-u(j, 1))*(u(j+1, 1)-u(j, 1));

        // Finally calculate the coordinates
        coord.SetElement(i, 1, A*X(j, 1) + B*X(j+1, 1) + C*X2(j, 1) + D*X2(j+1, 1));
        coord.SetElement(i, 2, A*Y(j, 1) + B*Y(j+1, 1) + C*Y2(j, 1) + D*Y2(j+1, 1));
        coord.SetElement(i, 3, A*Z(j, 1) + B*Z(j+1, 1) + C*Z2(j, 1) + D*Z2(j+1, 1));
      }
    }
  }

  return (coord);
}
开发者ID:hklaufus,项目名称:GridLab,代码行数:52,代码来源:spline.cpp

示例2: SetControlPoints

void clSpline::SetControlPoints(const dMatrix &cPointsX, const dMatrix &cPointsY, const dMatrix &cPointsZ)
{
  // Check if dimensions are correct
  if((cPointsX.GetNumberColumns() != 1 || cPointsY.GetNumberColumns() != 1 || cPointsZ.GetNumberColumns() != 1) ||
     (cPointsX.GetNumberRows() != cPointsY.GetNumberRows()) ||
     (cPointsX.GetNumberRows() != cPointsZ.GetNumberRows()))
  {
    throw clException("clSpline", "SetControlPoints", "Dimensions of matrices do not match.");
  }
  else
  {
    X = cPointsX;
    Y = cPointsY;
    Z = cPointsZ;
  }
}
开发者ID:hklaufus,项目名称:GridLab,代码行数:16,代码来源:spline.cpp


注:本文中的dMatrix::GetNumberRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。