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


C++ Jacobian::deriv方法代码示例

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


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

示例1: SetEulerZYX

/**
 * \brief funcion to set the euler zyx angles. 
 * \param gamma input parameter that contains the amount of rotation around X.  
 * \param beta input parameter that contains the amount of rotation around Y.
 * \param alpha output parameter that contains the amount of rotation around Z.
 * \param JR output parameter that will contain the Rotation and Jacobian with the rotational velocities.
 */
 void SetEulerZYX(const Jacobian<double>& gamma, 
				  const Jacobian<double>& beta, 
				  const Jacobian<double>& alpha,
 				  Jacobian<Rotation>& JR) {
	// position-domain :
	JR.value() = Rotation::EulerZYX(alpha.value(),beta.value(),gamma.value());
	double ca = ::cos(alpha.value()); 
	double sa = ::sin(alpha.value()); 
	double cb = ::cos(beta.value()); 
	double sb = ::sin(beta.value()); 
	// velocity-domain :
	assert(gamma.nrOfDeriv()==JR.nrOfDeriv());
	assert(beta.nrOfDeriv()==JR.nrOfDeriv());
	assert(alpha.nrOfDeriv()==JR.nrOfDeriv());
    for (int i=0;i<gamma.nrOfDeriv();++i) {
		if (gamma.hasDeriv(i) || beta.hasDeriv(i) || alpha.hasDeriv(i) ) {
			Vector w;
			double dalpha  = alpha.deriv(i);
			double dbeta   = beta.deriv(i);
			double dgamma  = gamma.deriv(i);
			w[0] = -sa*dbeta + ca*cb*dgamma;
			w[1] =  ca*dbeta + sa*cb*dgamma;
			w[2] =  dalpha - sb*dgamma; 
			JR.deriv(i) = w;
		} else {
			JR.setDeriv(i,false);
		}
	}
}
开发者ID:berkaydeniz,项目名称:orocos_kinematics_dynamics,代码行数:36,代码来源:jacobianframevel.cpp

示例2: GetEulerZYX

/**
 * \brief function to get the euler zyx angles. 
 * \param JR input parameter that indicates the Rotation and Jacobian with the rotational velocities.
 * \param gamma output parameter will contain the amount of rotation around X.  
 * \param beta output parameter will contain the amount of rotation around Y.
 * \param alpha output parameter will contain the amount of rotation around Z.
 * \retval 0 if successfull, otherwise its a singular situation.
 */
 int GetEulerZYX(const Jacobian<Rotation>& JR, 
				  Jacobian<double>& gamma, 
				  Jacobian<double>& beta, 
				  Jacobian<double>& alpha,
				  double eps) {
	// position-domain :
	JR.value().GetEulerZYX(alpha.value(),beta.value(),gamma.value());
	double ca = ::cos(alpha.value()); 
	double sa = ::sin(alpha.value()); 
	double cb = ::cos(beta.value()); 
	double sb = ::sin(beta.value()); 
	// velocity-domain :
	assert(gamma.nrOfDeriv()==JR.nrOfDeriv());
	assert(beta.nrOfDeriv()==JR.nrOfDeriv());
	assert(alpha.nrOfDeriv()==JR.nrOfDeriv());
    for (int i=0;i<JR.nrOfDeriv();++i) {
		if (JR.hasDeriv(i) ) {
			Vector w = JR.deriv(i);			
			double dgamma = (ca*w[0]+sa*w[1]);
			if (fabs(cb) < eps) { 
				if (fabs(dgamma)< eps) {
					dgamma = 0.0;  // arbitrary choice
				} else {
					return 1;
				}
			} else {
				dgamma /= cb;
			}
			double dalpha = w[2] + sb*dgamma;
			double dbeta  = -sa*w[0]+ca*w[1];
			gamma.deriv(i)=dgamma;
			alpha.deriv(i)=dalpha;
			beta.deriv(i) =dbeta;
		} else {
			gamma.setDeriv(i,false);
			beta.setDeriv(i,false);
			alpha.setDeriv(i,false);
		}
	}
	return 0;
 }
开发者ID:berkaydeniz,项目名称:orocos_kinematics_dynamics,代码行数:49,代码来源:jacobianframevel.cpp


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