diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 16:55:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 16:55:36 +0400 |
commit | 89c8de1f48607a5d887b44966be220ed9bf93285 (patch) | |
tree | 270d805e57d96f64c395df8505b2100d22dddf2e /source/blender/blenlib | |
parent | 7d4eee2b1879e7e1224787761d3ef3bfe4a891d6 (diff) |
add matrix multiply for projection that outputs 2d values.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index ada2d43b81f..e408b223923 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -88,11 +88,13 @@ void mul_serie_m4(float R[4][4], void mul_m4_v3(float M[4][4], float r[3]); void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]); +void mul_v2_m4v3(float r[2], float M[4][4], const float v[3]); void mul_v2_m2v2(float r[2], float M[2][2], const float v[2]); void mul_mat3_m4_v3(float M[4][4], float r[3]); void mul_m4_v4(float M[4][4], float r[4]); void mul_v4_m4v4(float r[4], float M[4][4], const float v[4]); void mul_project_m4_v3(float M[4][4], float vec[3]); +void mul_v2_project_m4_v3(float r[2], float M[4][4], const float vec[3]); void mul_m3_v3(float M[3][3], float r[3]); void mul_v3_m3v3(float r[3], float M[3][3], const float a[3]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index d9063b80f13..fa85e015ee8 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -344,6 +344,15 @@ void mul_v3_m4v3(float r[3], float mat[4][4], const float vec[3]) r[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2] + mat[3][2]; } +void mul_v2_m4v3(float r[2], float mat[4][4], const float vec[3]) +{ + float x; + + x = vec[0]; + r[0] = x * mat[0][0] + vec[1] * mat[1][0] + mat[2][0] * vec[2] + mat[3][0]; + r[1] = x * mat[0][1] + vec[1] * mat[1][1] + mat[2][1] * vec[2] + mat[3][1]; +} + void mul_v2_m2v2(float r[2], float mat[2][2], const float vec[2]) { float x; @@ -375,6 +384,15 @@ void mul_project_m4_v3(float mat[4][4], float vec[3]) vec[2] /= w; } +void mul_v2_project_m4_v3(float r[2], float mat[4][4], const float vec[3]) +{ + const float w = mul_project_m4_v3_zfac(mat, vec); + mul_v2_m4v3(r, mat, vec); + + r[0] /= w; + r[1] /= w; +} + void mul_v4_m4v4(float r[4], float mat[4][4], const float v[4]) { float x, y, z; |