本文整理汇总了C++中eigen::MatrixBase::cross方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixBase::cross方法的具体用法?C++ MatrixBase::cross怎么用?C++ MatrixBase::cross使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::MatrixBase
的用法示例。
在下文中一共展示了MatrixBase::cross方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
std::pair<Eigen::Vector3d, double> resolveCenterOfPressure(const Eigen::MatrixBase<DerivedTorque> & torque, const Eigen::MatrixBase<DerivedForce> & force, const Eigen::MatrixBase<DerivedNormal> & normal, const Eigen::MatrixBase<DerivedPoint> & point_on_contact_plane)
{
// TODO: implement multi-column version
using namespace Eigen;
if (abs(normal.squaredNorm() - 1.0) > 1e-12) {
throw std::runtime_error("Drake:resolveCenterOfPressure:BadInputs: normal should be a unit vector");
}
Vector3d cop;
double normal_torque_at_cop;
double fz = normal.dot(force);
bool cop_exists = abs(fz) > 1e-12;
if (cop_exists) {
auto torque_at_point_on_contact_plane = torque - point_on_contact_plane.cross(force);
double normal_torque_at_point_on_contact_plane = normal.dot(torque_at_point_on_contact_plane);
auto tangential_torque = torque_at_point_on_contact_plane - normal * normal_torque_at_point_on_contact_plane;
cop = normal.cross(tangential_torque) / fz + point_on_contact_plane;
auto torque_at_cop = torque - cop.cross(force);
normal_torque_at_cop = normal.dot(torque_at_cop);
}
else {
cop.setConstant(std::numeric_limits<double>::quiet_NaN());
normal_torque_at_cop = std::numeric_limits<double>::quiet_NaN();
}
return std::pair<Vector3d, double>(cop, normal_torque_at_cop);
}
示例2: makeCoordinateSystem
inline void makeCoordinateSystem(Eigen::MatrixBase<Derived>& v1,
Eigen::MatrixBase<DerivedOther1>& v2,
Eigen::MatrixBase<DerivedOther2>& v3)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(DerivedOther1, 3);
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(DerivedOther2, 3);
/*ASSERTMSG( v1.rows() == 3 && v1.cols()==1 &&
v2.rows() == 3 && v2.cols() == 1 &&
v3.rows() == 3 && v3.cols() == 1
, "IN: "<< v1.rows()<<","<<v1.cols()<<" OUT: "<<
v2.rows()<<","<<v2.cols()<<"/"<<v3.rows()<<","<<v3.cols() );*/
typedef typename Derived::Scalar PREC;
using std::abs;
using std::sqrt;
v1.normalize();
if (abs(v1(0)) > abs(v1(2)))
{
PREC invLen = 1.0 / sqrt(v1(0) * v1(0) + v1(2) * v1(2));
v2 = typename MyMatrix<double>::Vector3(-v1(2) * invLen, 0, v1(0) * invLen);
}
else
{
PREC invLen = 1.0 / sqrt(v1(1) * v1(1) + v1(2) * v1(2));
v2 = typename MyMatrix<double>::Vector3(0, v1(2) * invLen, -v1(1) * invLen);
}
v3 = v1.cross(v2);
v2.normalize();
v3.normalize();
};