add 2d length functions for testing pixel coords. len_manhattan_v2_int, len_manhattan_v2v2_int

This commit is contained in:
Campbell Barton 2013-04-11 02:23:45 +00:00
parent e2a37db1d1
commit b77acc2879
2 changed files with 15 additions and 0 deletions

@ -149,12 +149,14 @@ MINLINE void star_m3_v3(float rmat[3][3], float a[3]);
MINLINE float len_squared_v2(const float v[2]);
MINLINE float len_squared_v3(const float v[3]);
MINLINE float len_manhattan_v2(const float v[2]);
MINLINE float len_manhattan_v2_int(const int v[2]);
MINLINE float len_manhattan_v3(const float v[3]);
MINLINE float len_v2(const float a[2]);
MINLINE float len_v2v2(const float a[2], const float b[2]);
MINLINE float len_squared_v2v2(const float a[2], const float b[2]);
MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]);
MINLINE float len_manhattan_v2v2_int(const int a[2], const int b[2]);
MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]);
MINLINE float len_v3(const float a[3]);
MINLINE float len_v3v3(const float a[3], const float b[3]);

@ -594,6 +594,11 @@ MINLINE float len_manhattan_v2(const float v[2])
return fabsf(v[0]) + fabsf(v[1]);
}
MINLINE float len_manhattan_v2_int(const int v[2])
{
return ABS(v[0]) + ABS(v[1]);
}
MINLINE float len_manhattan_v3(const float v[3])
{
return fabsf(v[0]) + fabsf(v[1]) + fabsf(v[2]);
@ -642,6 +647,14 @@ MINLINE float len_manhattan_v2v2(const float a[2], const float b[2])
return len_manhattan_v2(d);
}
MINLINE float len_manhattan_v2v2_int(const int a[2], const int b[2])
{
int d[2];
sub_v2_v2v2_int(d, b, a);
return len_manhattan_v2_int(d);
}
MINLINE float len_manhattan_v3v3(const float a[3], const float b[3])
{
float d[3];