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


C++ vec3::transpose方法代码示例

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


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

示例1: bilateral

void cloth::bilateral(phys::system& system) {
  using namespace math;
  core::each( boost::edges(mesh), [&](const mesh_type::edge_descriptor& e) {
      natural i = boost::source(e, mesh);
      natural j = boost::target(e, mesh);
	
      auto info = mesh[e];
	
      const vec3 diff = dofs[i].g() - dofs[j].g(); 
      
      if( diff.norm() < 1e-5 ) core::log("ALARRRM");
      
      const vec3 n = diff.normalized();
      
      auto& J = system.constraint.bilateral.matrix;

      real norm = 2 * std::sqrt( 2 * diff.squaredNorm() );
      
      real scale = 1/norm;
      
      J(info.key, &dofs[i]) = scale * 2 * diff.transpose(); //  n.transpose();
      J(info.key, &dofs[j]) = -2 * scale * diff.transpose(); // - n.transpose();
      
      auto& b = system.constraint.bilateral.values;
      b(info.key).setZero();
      
      auto& c = system.constraint.bilateral.corrections;
      c(info.key).setConstant( scale * (info.rest * info.rest - diff.squaredNorm())  );
      
    });
  
}
开发者ID:Jorjor70,项目名称:meuh,代码行数:32,代码来源:cloth.cpp

示例2: rodrigue_matrix

/**
 * @brief rodrigue_matrix Calculate Rotational matrix by rotational axis and angle
 * @param n: rotational axis
 * @param c: cos value of rotational angle
 * @return
 */
mat3 rodrigue_matrix(const vec3& n, float c)
{
    mat3 rom = mat3::Identity();
    mat3 N;
    N << 0.00f, +n(2), -n(1),
         -n(2), 0.00f, +n(0),
         +n(1), -n(0), 0.00f;
    rom *= c;
    rom += (1.0f - c) * n * n.transpose();
    rom += sqrt(1.0f - c * c) * N;
    return rom;
}
开发者ID:wilsonCernWq,项目名称:TerrainViewer,代码行数:18,代码来源:icg_helper.cpp

示例3: getMatrix

mat33 getMatrix(vec3 vec, double alpha)
{
    mat33 res;

    mat33 I;
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            I(i,j)=(i==j)?1.0:.0;
        }
    }

    vec.normalize();
    mat33 E=crossProductMat(vec);
    //print(E);
    //print(I);
    //std::cout<<vec.transpose()<<"\n";
    res=cos(alpha)*I+(1-cos(alpha))*vec*vec.transpose()-sin(alpha)*E;
    return res;
}
开发者ID:scienceasdf,项目名称:Some-math-templates,代码行数:19,代码来源:squaternion.cpp

示例4: reset

  void graph::reset(math::natural n) {

    width = n;
    height = n;
    
    obj.resize( width * height);
    constraint.mesh = mesh_type( width * height );

    auto pos = [&](natural i) -> vec3& {
      return obj[i].conf;
    };

    auto vel = [&](natural i) -> vec3& {
      return obj[i].velocity;
    };

  

    auto edge = [&](real rest) -> edge_type {
      edge_type res;
      res.rest = rest;
      res.constraint = new phys::constraint::bilateral(1);
      return res;
    };

    // place vertices
    for(natural i = 0 ; i < n * n; ++i ) {
      const natural x = i / width;
      const natural y = i % width;
      
      pos(i) = (sceneRadius()/2) * vec3(y, 0, x) / width;
      vel(i).setZero();
    }

    // create edges
    for(natural i = 0 ; i < n * n; ++i ) {
      const natural x = i / width;
      const natural y = i % width;
      
      bool ok_height = (x < height - 1);
      bool ok_width = (y < width - 1);
      
      if( ok_height ) {
	real rest = (pos(i) - pos(i + width)).norm();
	
	boost::add_edge(i, i + width, edge(rest), constraint.mesh);
      }

      if( ok_width ) { 
	real rest = (pos(i) - pos(i + 1)).norm();
	boost::add_edge(i, i + 1, edge(rest), constraint.mesh);
      }
      
      if( ok_height && ok_width ) {
	// real rest = (pos(i) - pos(i + width + 1)).norm();
	// boost::add_edge(i, i + width + 1, edge(rest), constraint.mesh);

	// rest = (pos(i + 1) - pos(i + width)).norm();
	// boost::add_edge(i + 1, i + width, edge(rest), constraint.mesh);
      }

    }

    frame[0]->transform( SE3::translation( pos(0) ) );
    frame[1]->transform( SE3::translation( pos(width - 1) ) );

    system.clear();
    
    // masses
    core::each( obj, [&](const obj_type& o) {
	system.mass[ &o ].setIdentity(3, 3);
	system.resp[ &o ].setIdentity(3, 3);
      });
    
    constraint.lambda.clear();
    

    constraint.update.clear();

    // setup constraints
    core::each( boost::edges(constraint.mesh), [&](const mesh_type::edge_descriptor& e) {
	auto c = constraint.mesh[e].constraint;

	natural i = boost::source(e, constraint.mesh);
	natural j = boost::target(e, constraint.mesh);
	
	const real rest = constraint.mesh[e].rest;
	
	constraint.update[c] = [&,i,j,c,e,rest] {
	  
	  const vec3 diff = obj[i].conf - obj[j].conf; 
	  const vec3 n = diff.normalized();
	  
	  auto& row = system.constraint.bilateral.matrix[ c ];
      
	  row[ &obj[i] ] = n.transpose();
	  row[ &obj[j] ] = -n.transpose();
      
	  const real gamma = 1;
  
//.........这里部分代码省略.........
开发者ID:Jorjor70,项目名称:meuh,代码行数:101,代码来源:graph.cpp


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