Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-27 04:32:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-27 04:32:58 +0300
commitfde4686d77dd72ccfa88febdea360136bfd17a36 (patch)
tree52a715e72488c70457f5c29a74e24c0e3977e470 /source/blender/blenlib/BLI_math_geom.h
parent9c82e1efc32bdff04c3136ef5a2959ed73711ca7 (diff)
barycentric transform utility geometry function.
From 2 triangles and 1 point, the relative position between the point and the first triangle is applied to the second triangle to find the target point. the barycentric weights are calculated in 2D space with a signed area so values outside the triangle bounds are supported. wrapped by python: pt_to = Geometry.BarycentricTransform(pt_from, t1a, t1b, t1c, t2a, t1b, t1c) NOTE: - moved some barycentric weight functions out of projection painting into the math lib. - ended up making some of the math functions use const args. TODO: - support exceptional cases. zero area tries and similar.
Diffstat (limited to 'source/blender/blenlib/BLI_math_geom.h')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 49d335f6c5c..e676001fba5 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -37,12 +37,13 @@ extern "C" {
void cent_tri_v3(float r[3], float a[3], float b[3], float c[3]);
void cent_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]);
-float normal_tri_v3(float r[3], float a[3], float b[3], float c[3]);
-float normal_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]);
+float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
+float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
-float area_tri_v2(float a[2], float b[2], float c[2]);
-float area_tri_v3(float a[3], float b[3], float c[3]);
-float area_quad_v3(float a[3], float b[3], float c[3], float d[3]);
+float area_tri_v2(const float a[2], const float b[2], const float c[2]);
+float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]);
+float area_tri_v3(const float a[3], const float b[3], const float c[3]);
+float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
float area_poly_v3(int nr, float verts[][3], float normal[3]);
/********************************* Distance **********************************/
@@ -120,6 +121,13 @@ void interp_weights_poly_v3(float w[], float v[][3], int n, float p[3]);
void interp_cubic_v3(float x[3], float v[3],
float x1[3], float v1[3], float x2[3], float v2[3], float t);
+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 barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2],
+ const float co[2], float w[3]);
+
/***************************** View & Projection *****************************/
void lookat_m4(float mat[4][4], float vx, float vy,