New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rigid body system #10
Conversation
panchagil
commented
Jun 7, 2019
- Moved rigid bodies to physics/ folder
- added RigidBodySystem that keeps list of RB.
- Moved solvers to solvers/ folder
- Removed (a lot of)unused code
- moved RigidBody class to namespace ccd::opt - made RigidBody attributes private to ensure consistency of CM
- moved solvers to solver/ - moved rigid_body to physics/ - added RigidBodySystem that has a list of rigid bodies - handles the mapping of local to global coordinates
- Added get/set of RB velocities - Added method to clear RBSystem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like these changes. I just have a couple of questions and comments.
total_edge_length += edge_length; | ||
} | ||
Eigen::VectorXd cm; | ||
cm = (vertex_masses.asDiagonal() * vertices).colwise().sum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a function to build the mass matrix. This function would then call the mass matrix function. The function would be
double build_mass_matrix(const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges, Eigen::SparseMatrix<double>& mass_matrix)
where the function return the total edge length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I can make the build_mass_matrix. Is the total length the same as mass_matrix.sum()? If that is the case, I'll rather make the return void.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, is the same as mass_matrix.sum()
, so returning nothing makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
= hvertices * Tm.transpose(); | ||
|
||
Eigen::MatrixXd displacements; | ||
displacements = tvertices.rowwise().hnormalized(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will convert this to not use homogeneous coordinates after we accept this pull request. It makes taking the gradient and hessian.
src/physics/rigid_body_system.hpp
Outdated
|
||
Eigen::MatrixX2d world_vertices() const | ||
{ | ||
return vertices.rowwise() + position.transpose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this definition not in the cpp
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen short functions defined on the .hpp file, idk why. I can move it to the cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, need I was just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
void assemble_displacements(); | ||
void assemble_displacements( | ||
const Eigen::VectorXd& v, Eigen::MatrixXd& u); | ||
void add_rigid_body(RigidBody rb) { rigid_bodies.push_back(rb); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this function call assemble or do something to update the fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be expensive if we need to add many rigid bodies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, so when is assemble called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after you add them all. Look at state.cpp update_fields_from_rigid_bodies
.
@@ -1,6 +1,6 @@ | |||
// Functions for optimizing functions. | |||
// Includes Newton's method with and without constraints. | |||
#include <opt/newtons_method.hpp> | |||
#include "newtons_method.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use quotes here when we mostly use <solvers/newton_method.hpp>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using quotes when is its own .hpp, mostly because that is the template of my IDE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay