align5.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. """Linearly transform a Mesh by defining how a specific
  2. set of points (landmarks) must move"""
  3. from vedo import dataurl, Mesh, Arrows, show
  4. # Define the original set of landmark points
  5. # note that landmark points do not need to belong to any mesh
  6. landmarks1 = [
  7. [-0.067332, 0.177376, -0.05199058],
  8. [-0.004541, 0.085447, 0.05713107],
  9. [-0.011799, 0.175825, -0.02279279],
  10. [-0.081910, 0.117902, 0.04889364],
  11. ]
  12. # Define the target set of landmark points
  13. landmarks2 = [
  14. [0.1287002, 0.2651531, -0.0469673],
  15. [0.3338593, 0.0941488, 0.1243552],
  16. [0.1860555, 0.2626522, -0.0202493],
  17. [0.1149052, 0.1731894, 0.0474256],
  18. ]
  19. s1 = Mesh(dataurl + "bunny.obj").c("gold")
  20. # Clone the mesh and color the clone orange
  21. s2 = s1.clone().c('orange4')
  22. # Transform the cloned mesh by moving the landmarks from landmarks1 to landmarks2
  23. s2.align_with_landmarks(landmarks1, landmarks2)
  24. # Create arrows to visualize the movement of the landmark points
  25. arrows = Arrows(landmarks1, landmarks2, s=0.5).c('black')
  26. # Show the original mesh, transformed mesh, arrows, and script description
  27. show(s1, s2, arrows, __doc__, axes=True).close()