ch-sa/labelCloud

not a bug, just some doubt about change side function

xunkaixin opened this issue · 2 comments

in bbox. py->translate_side function, through translate_point function can achieve the purpose of changing a side, and the result is right. but I can't understand that a side can be changed alone through the translation center. Theoretically, the translation center should be the overall offset of bbox. Can you help explain it

ch-sa commented

Hi @xunkaixin,

this code part could really benefit of better naming and documentation. ;)

So basically the function is used to increase the dimension of the bounding box along one axis, while ensuring that the centroid does not change (i.e. it does not move).

To do that it ...

  1. calculates the direction vector by subtracting two points that are perpendicular to the selected side (vertex ids p_id_s and p_id_o) → e.g. front left bottom and back left bottom for front side
  2. multiply the unit vector of the direction vector with half the changed distance (movement invard / outward)
  3. move the centroid with this translation vector

You need to take half the distance as you want to "grow" the bounding box in both directions.

Hope this explains it. Thanks for the hint though, will refactor this part on time.

Best,

Christoph

  • Refactor translate_side() function

thanks, before translate_side function, I ignored the change of length.