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.
This commit is contained in:
2009-12-27 01:32:58 +00:00
parent 9c82e1efc3
commit fde4686d77
9 changed files with 176 additions and 82 deletions

View File

@@ -51,8 +51,8 @@ extern "C" {
MINLINE void zero_v2(float r[2]);
MINLINE void zero_v3(float r[3]);
MINLINE void copy_v2_v2(float r[2], float a[2]);
MINLINE void copy_v3_v3(float r[3], float a[3]);
MINLINE void copy_v2_v2(float r[2], const float a[2]);
MINLINE void copy_v3_v3(float r[3], const float a[3]);
MINLINE void swap_v2_v2(float a[2], float b[2]);
MINLINE void swap_v3_v3(float a[3], float b[3]);
@@ -67,7 +67,7 @@ MINLINE void add_v3_v3v3(float r[3], float a[3], float b[3]);
MINLINE void sub_v2_v2(float r[2], float a[2]);
MINLINE void sub_v2_v2v2(float r[2], float a[2], float b[2]);
MINLINE void sub_v3_v3(float r[3], float a[3]);
MINLINE void sub_v3_v3v3(float r[3], float a[3], float b[3]);
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void mul_v2_fl(float r[2], float f);
MINLINE void mul_v3_fl(float r[3], float f);
@@ -87,7 +87,7 @@ MINLINE float dot_v2v2(float a[2], float b[2]);
MINLINE float dot_v3v3(float a[3], float b[3]);
MINLINE float cross_v2v2(float a[2], float b[2]);
MINLINE void cross_v3_v3v3(float r[3], float a[3], float b[3]);
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void star_m3_v3(float R[3][3],float a[3]);
@@ -103,11 +103,11 @@ MINLINE float normalize_v3(float r[3]);
/******************************* Interpolation *******************************/
void interp_v2_v2v2(float r[2], float a[2], float b[2], float t);
void interp_v2_v2v2v2(float r[2], float a[2], float b[2], float c[3], float t[3]);
void interp_v3_v3v3(float r[3], float a[3], float b[3], float t);
void interp_v3_v3v3v3(float p[3], float v1[3], float v2[3], float v3[3], float w[3]);
void interp_v3_v3v3v3v3(float p[3], float v1[3], float v2[3], float v3[3], float v4[3], float w[4]);
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t);
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]);
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t);
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4]);
void mid_v3_v3v3(float r[3], float a[3], float b[3]);
@@ -130,7 +130,7 @@ float angle_v2v2v2(float a[2], float b[2], float c[2]);
float angle_normalized_v2v2(float a[2], float b[2]);
float angle_v3v3(float a[2], float b[2]);
float angle_v3v3v3(float a[2], float b[2], float c[2]);
float angle_normalized_v3v3(float a[3], float b[3]);
float angle_normalized_v3v3(const float v1[3], const float v2[3]);
void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]);
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);