How to map a point onto a warped grid

前端 未结 4 1523
青春惊慌失措
青春惊慌失措 2020-12-16 17:51

Say you have a collection of points with coordinates on a Cartesian coordinate system.

\"an

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 18:13

    I understood that you have one-to-one correspondence between the wrapped and unwrapped grid points. And I assume that the deformation is not so extreme that you might have intersecting grid lines (like the image you show).

    The strategy is exactly what Jacob suggests: Triangulate the two grids such that there is a one-to-one correspondence between triangles, locate the point to be mapped in the triangulation and then use barycentric coordinates in the corresponding triangle to compute the new point location.

    Preprocess

    1. Generate the Delaunay triangulation of the points of the wrapped grid, let's call it WT.
    2. For every triangle in WT add a triangle between the corresponding vertices in the unwrapped grid. This gives a triangulation UWT of the unwrapped points.

    Map a point p into the wrapped grid

    1. Find the triangle T(p1,p2,p3) in the UWT which contains p.
    2. Compute the barycentric coordinates (b1,b2,b3) of p in T(p1,p2,p3)
    3. Let Tw(q1,q2,q3) be the triangle in WT corresponding to T(p1,p2,p3). The new position is
      b1 * q1 + b2 * q2 + b3 * q3.

    Remarks This gives a deformation function as a linear spline. For smoother behavior one could use the same triangulation but do higher order approximation which would lead to a bit more complicated computation instead of the barycentric coordinates.

提交回复
热议问题