dilevin / CSC417-a2-mass-spring-3d

Assignment 2 for CSC2549
11 stars 13 forks source link

Mouse interaction get reverse direction #21

Closed haoda-li closed 3 years ago

haoda-li commented 4 years ago

I expect the mouse drag will pull the closest vertex to the dragged position and bounce back, while in the program the vertex is pulled to the opposite direction. The issue is that on main.cpp line 65, instead of f.segment<3>(3*Visualize::picked_vertices()[pickedi]) -= dV_mouse.segment<3>(3); the code should be f.segment<3>(3*Visualize::picked_vertices()[pickedi]) += dV_mouse.segment<3>(3);

This small fix should make the interaction looks more "correct". It won't impact the actual assignment implementations.

dilevin commented 4 years ago

There is something odd about this. Here we should be accumulating forces, which are the negative of dV. Your fix adds a potential energy gradient to a force which feels incorrect. Perhaps you should double check your potential energy gradient ...

abhimadan commented 4 years ago

Are you assembling the negative gradients in assemble_forces? That would make the signs consistent.