本文整理汇总了C++中MatrixXf::lu方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXf::lu方法的具体用法?C++ MatrixXf::lu怎么用?C++ MatrixXf::lu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixXf
的用法示例。
在下文中一共展示了MatrixXf::lu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
restLengthRight = l0 * alpha;
restLengthRight = l0;
if(deltaXRight.dot(deltaXRight) < 0.001) {
deltaXDotRight = *(ptr->world_x_dot) - *(ptr->right->world_x_dot);
deltaXRight = *(ptr->world_x) - *(ptr->right->world_x);
restLengthLeft = l0;
}
absDeltaXRight = sqrt(deltaXRight.dot(deltaXRight));
absDeltaXLeft = sqrt(deltaXLeft.dot(deltaXLeft));
constant = -(ks * (absDeltaXLeft - restLengthLeft) + kd * deltaXDotLeft.dot(deltaXLeft)/absDeltaXLeft)*deltaXLeft/absDeltaXLeft - (ks * (absDeltaXRight - restLengthRight) + kd * deltaXDotRight.dot(deltaXRight)/absDeltaXRight)*deltaXRight/absDeltaXRight;
}
else if(ptr == right_of_e0) { //ball's right node is ptr
deltaXDotLeft = *(ptr->world_x_dot) - *(previous_state->e1->world_x_dot);
deltaXDotRight = *(ptr->world_x_dot) - *(ptr->right->world_x_dot);
deltaXLeft = *(ptr->world_x) - *(previous_state->e1->world_x);
deltaXRight = *(ptr->world_x) - *(ptr->right->world_x);
restLengthLeft = l0 * alpha;
restLengthRight = l0;
if(deltaXLeft.dot(deltaXLeft) < 0.001) {
deltaXDotLeft = *(ptr->world_x_dot) - *(ptr->left->world_x_dot);
deltaXLeft = *(ptr->world_x) - *(ptr->left->world_x);
restLengthLeft = l0;
}
absDeltaXLeft = sqrt(deltaXLeft.dot(deltaXLeft));
absDeltaXRight = sqrt(deltaXRight.dot(deltaXRight));
constant = -(ks * (absDeltaXLeft - restLengthLeft) + kd * deltaXDotLeft.dot(deltaXLeft)/absDeltaXLeft)*deltaXLeft/absDeltaXLeft - (ks * (absDeltaXRight - restLengthRight) + kd * deltaXDotRight.dot(deltaXRight)/absDeltaXRight)*deltaXRight/absDeltaXRight;
}
f[i] += constant.x();
f[i+1] += constant.y();
f[i+2] += constant.z();
f[i] = 0.0; f[i+2] = 0.0;
ptr = ptr->right;
}
Vector3f x0_and_x1= (1-alpha)* *(right_of_e0->left->world_x) + alpha* *(right_of_e0->world_x);
f[3*(NUM-1)] = previous_state->e1->rho * x0_and_x1.dot(Vector3f(0,-g,0));
VectorXf rhs = M * qOldDot + dt * f;
VectorXf qNewDot;
qNewDot = M.lu().solve(rhs);
VectorXf qNew = qNewDot * dt + qOld;
L3node * newRoot = new L3node(0.0, *(previous_state->root->world_x), *(previous_state->root->world_x_dot));
state->root = newRoot;
node * newPtr = state->root;
ptr = previous_state->root->right;
Vector3f newX, newXDot;
//update the new state
for(int i=0; i<3*(NUM-1); i+=3) {
newX = Vector3f(qNew[i], qNew[i+1], qNew[i+2]);
newXDot = Vector3f(qNewDot[i], qNewDot[i+1], qNewDot[i+2]);
L3node * newNode = new L3node(ptr->material_coordinate, newX, newXDot);
newPtr->right = newNode;
newPtr->right->left = newPtr;
ptr = ptr->right;
newPtr = newPtr->right;
}
L3node* rightNode = new L3node(1.0, *(ptr->world_x), *(ptr->world_x_dot));
newPtr->right = rightNode;
newPtr->right->left = newPtr;
cout << "qNew : " << qNew << "qDotNew: " << qNewDot << endl;
right_of_e0 = linear_search(qNew[3*(NUM-1)], newRoot);
alpha = (qNew[3*(NUM-1)] - right_of_e0->left->material_coordinate) / (right_of_e0->material_coordinate - right_of_e0->left->material_coordinate);
newX = (1.0-alpha) * *(right_of_e0->left->world_x) + alpha * *(right_of_e0->world_x);
newXDot = (1.0-alpha) * *(right_of_e0->left->world_x_dot) + alpha * *(right_of_e0->world_x_dot);
E0node * newE = new E0node(qNew[3*(NUM-1)], qNewDot[3*(NUM-1)], newX, newXDot, newRoot);
newE->rho = 2.0;
state->e1 = newE;
state->next = NULL;
return state;
/*
// state->e1 = dynamic_cast<E3node *> (previous_state->e1)->update();
//state->e1 = dynamic_cast<L3node *> (previous_state->e1)->update();
state->e1 = dynamic_cast<E0node *> (previous_state->e1)->update();
state->root = dynamic_cast<E0node *> (state->e1)->rootNode;
state->next = NULL;
return state;
*/
}