-
Notifications
You must be signed in to change notification settings - Fork 19
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
Solving mesh collision #263
Conversation
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.
Thanks a lot @sophietheis
Nope .. That would also be a good addition! |
tyssue/collisions/solvers.py
Outdated
angle_e = pd.concat([angle_e.iloc[pos_s:], angle_e.iloc[:pos_s]]) | ||
|
||
angle_e = pd.concat([angle_e, angle_e.iloc[[0]]]) | ||
angle_e.iloc[-1]['angle'] += 360 |
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.
+= 2*np.pi
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.
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.
Well, indeed it will cause problem if face is not convex. I hadn't thought about it...
But I try to implement the algorithm from the paper you send, but must have something that I don't get because it didn't work.
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.
well I think this only limits us to "star convex" cells, which is not so bad (the cell we see here is not very physiological).
Maybe we can live with that for the moment (with a warning in the doc)?
But in this case I think your alog boils down to:
angle = np.arctan2(
sheet.edge_df["dy"],
sheet.edge_df["dx"]
)
to_flip = sheet.edge_df[angle < 0, ["srce", "trgt"]]
(
sheet.vert_df[to_flip["srce"].to_numpy(), ["x", "y"]],
sheet.vert_df[to_flip["trgt"].to_numpy(), ["x", "y"]]
) = (
sheet.vert_df[to_flip["trgt"].to_numpy(), ["x", "y"]],
sheet.vert_df[to_flip["srce"].to_numpy(), ["x", "y"]]
)
As we just flip the negative angles (i.e. the red arrow on the drawing above)
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.
Well, in fact I have a very strange behavior if I use reset_index(ordered=True)
: vertex stop moving.
They are supposed to move because when I plot forces, I see big arrow forces for a few vertex. And if I apply find_energy_min
without collisions, vertex moves again...
I really don't know what append to "block" vertex movement...
So for now I will keep the code that work, and focus on why sometime tissue is out of control.... 😒
Great, congrats, I'll try to test/revise it soon, I have a PR to submit on my side also :) |
Surface mesh create wasn't create all faces. Now it is fixed. Also : -add two methods to Mesh to list faces and vertices. -generalised coordinates -add `write_polygon_mesh` to export mesh into .ply to visualised with blinder
Add class to solve collision in 2D or in 3D. 3D collision solver need to be fixed
Add `How to cite` section Add `Geometry` section Add `Publications` section Update bibliography link
Unable to make this algo works... https://europepmc.org/article/PMC/3660981 Use ordered vertices and their angle position. -> uncrossed face : angles are monotonically increasing -> crossed face : angles are not monotonically increasing
Need to recalculate angle_e for twisted face One fix which is only suitable for 2D lateral sheet...
les test de topologie passent je pense avec mes derniers patchs |
Okay, je vais verifier que je n'ai pas écrasé certaines de tes modif en faisant le git rebase. |
Les tests sont fixés. |
ok, je regarde comment tu as écrit tout ça et je te fais un retour |
In order to keep track of cell lineage
5d51b61
to
181edcd
Compare
Hi @sophietheis , I am finally working on releasing tyssue 1.0 I am merging everything this as is, feel free to push your latest updates! Best |
* dependency * Update history.py > Added the self.time_stamps() method code for HistoryHdf5 class into the __init__() method so that time_stamps are only calculated once as self._time_stamps > Edited self.time_stamps() method to return self._time_stamps > Greatly improves efficiency of retrieve() method as time_stamps is not computed each time a new time-point is loaded. * Solving mesh collision (#263) * Fix for Issues #261 - cell division failed at the border * Fix Mesh creation Surface mesh create wasn't create all faces. Now it is fixed. Also : -add two methods to Mesh to list faces and vertices. -generalised coordinates -add `write_polygon_mesh` to export mesh into .ply to visualised with blinder * Add 2D collision solver Add class to solve collision in 2D or in 3D. 3D collision solver need to be fixed * Update README.md Add `How to cite` section Add `Geometry` section Add `Publications` section Update bibliography link * Generalised wich vertex penetrate face * Attempt to set out particular cases * Detect and fix self-crossing face Unable to make this algo works... https://europepmc.org/article/PMC/3660981 Use ordered vertices and their angle position. -> uncrossed face : angles are monotonically increasing -> crossed face : angles are not monotonically increasing * Use `.apply()` Need to recalculate angle_e for twisted face One fix which is only suitable for 2D lateral sheet... * ENH: write `mean_XX` method in `Epithelium` class (Issue #224) * Fix according to comments * Fix Issue #258 ax argument not considered in `plt_draw.sheet_view` * ENH: pass column name to `data_at_opposite` issue (#245) * Add publication and remove bibtex reference * Add check face convexity * Use reset_index and code simplification * yAdd to_mesh function (issue #221) and some test * Remove the use of reset_index in face_self_intersect * use ipv_draw with 2D data * Fix solution after detection point inside polygon * Remove solving collision for 2 same face... * Abord vertex displacement if it creates twisted face * New way to calculate the position of "penetrate" vertices For now, it is the best way to fix collision (compare to what I tried before). So when a vertex is inside an other face. It is pullback by 10% of the length of the ([v-f1]+[v-f2]/2). with v, f1, f2 position of vertices and center of face 1 and face 2, which are the faces to which the vertex belongs. It is not perfect and very arbitrary for now, but it avoids vertex displacement at strange place. * WIP - use force field to fix collision * Small fix * Remove function duplication due to circular import * Calculate "repulsion" gradient in the effector method. Remove loop * Fix tests Remove collisions tests Fix method call in meshes test Comment "update_repulstion" method in planar geometry * Add lateralsheet shapes + test * Update publication + add collapse texte * Add test for Repulsion effector * Add test update repulsion * Remove unused import * Add `drop_face` to allow hole (issues #220 and #141) (associate #221) * Update readme.md * Update publications in README.md * Add `lineage` attribute to `Epithelium` In order to keep track of cell lineage * Remove memory oscillation * dependency (#277) * bug fixes --------- Co-authored-by: Guillaume Gay <[email protected]> * tests pass * fixes unknown namz --------- Co-authored-by: sniffo <[email protected]> Co-authored-by: Sophie THEIS <[email protected]>
Solve mesh collision in 2D.
Fix issue #261 & #262.
Update readme.md