diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-13 08:55:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-13 08:55:45 +0400 |
commit | ff42afb6c5284f1c224d0c6f73e8e86facc27ff4 (patch) | |
tree | 2a51b632e59deaf2693f1a9535ed888d1900e765 /source/blender/blenlib | |
parent | 3529913629c83c27627d93a186bd5e7638dd839a (diff) |
Math Lib: rename barycentric_transform -> transform_point_by_tri_v3
also add transform_point_by_seg_v3
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 11 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 20 |
2 files changed, 25 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 9962529e095..d3158ef7926 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -215,9 +215,14 @@ void interp_cubic_v3(float x[3], float v[3], int interp_sparse_array(float *array, const int list_size, const float invalid); -void barycentric_transform(float pt_tar[3], float const pt_src[3], - const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], - const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]); +void transform_point_by_tri_v3( + float pt_tar[3], float const pt_src[3], + const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], + const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]); +void transform_point_by_seg_v3( + float p_dst[3], const float p_src[3], + const float l_dst_p1[3], const float l_dst_p2[3], + const float l_src_p1[3], const float l_src_p2[3]); void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 3d4cea70551..6ca98e52909 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2446,9 +2446,10 @@ void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const flo /* given 2 triangles in 3D space, and a point in relation to the first triangle. * calculate the location of a point in relation to the second triangle. * Useful for finding relative positions with geometry */ -void barycentric_transform(float pt_tar[3], float const pt_src[3], - const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], - const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]) +void transform_point_by_tri_v3( + float pt_tar[3], float const pt_src[3], + const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], + const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3]) { /* this works by moving the source triangle so its normal is pointing on the Z * axis where its barycentric weights can be calculated in 2D and its Z offset can @@ -2485,6 +2486,19 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3], madd_v3_v3v3fl(pt_tar, pt_tar, no_tar, (z_ofs_src / area_src) * area_tar); } +/** + * Simply re-interpolates, + * assumes p_src is between \a l_src_p1-l_src_p2 + */ +void transform_point_by_seg_v3( + float p_dst[3], const float p_src[3], + const float l_dst_p1[3], const float l_dst_p2[3], + const float l_src_p1[3], const float l_src_p2[3]) +{ + float t = line_point_factor_v3(p_src, l_src_p1, l_src_p2); + interp_v3_v3v3(p_dst, l_dst_p1, l_dst_p2, t); +} + /* given an array with some invalid values this function interpolates valid values * replacing the invalid ones */ int interp_sparse_array(float *array, const int list_size, const float skipval) |