File: align5.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (34 lines) | stat: -rw-r--r-- 1,144 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Linearly transform a Mesh by defining how a specific
set of points (landmarks) must move"""
from vedo import dataurl, Mesh, Arrows, show

# Define the original set of landmark points
# note that landmark points do not need to belong to any mesh
landmarks1 = [
    [-0.067332, 0.177376, -0.05199058],
    [-0.004541, 0.085447,  0.05713107],
    [-0.011799, 0.175825, -0.02279279],
    [-0.081910, 0.117902,  0.04889364],
]

# Define the target set of landmark points
landmarks2 = [
    [0.1287002, 0.2651531, -0.0469673],
    [0.3338593, 0.0941488,  0.1243552],
    [0.1860555, 0.2626522, -0.0202493],
    [0.1149052, 0.1731894,  0.0474256],
]

s1 = Mesh(dataurl + "bunny.obj").c("gold")

# Clone the mesh and color the clone orange
s2 = s1.clone().c('orange4')

# Transform the cloned mesh by moving the landmarks from landmarks1 to landmarks2
s2.align_with_landmarks(landmarks1, landmarks2)

# Create arrows to visualize the movement of the landmark points
arrows = Arrows(landmarks1, landmarks2, s=0.5).c('black')

# Show the original mesh, transformed mesh, arrows, and script description
show(s1, s2, arrows, __doc__, axes=True).close()