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:
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index bf562684604..d96beadd63b 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -134,6 +134,13 @@ MINLINE void copy_v4_v4_char(char r[4], const char a[4])
}
/* short */
+MINLINE void zero_v3_int(int r[3])
+{
+ r[0] = 0;
+ r[1] = 0;
+ r[2] = 0;
+}
+
MINLINE void copy_v2_v2_short(short r[2], const short a[2])
{
r[0] = a[0];
@@ -574,6 +581,16 @@ MINLINE float len_squared_v3(const float v[3])
return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
}
+MINLINE float len_manhattan_v2(const float v[2])
+{
+ return fabsf(v[0]) + fabsf(v[1]);
+}
+
+MINLINE float len_manhattan_v3(const float v[3])
+{
+ return fabsf(v[0]) + fabsf(v[1]) + fabsf(v[2]);
+}
+
MINLINE float len_v2(const float v[2])
{
return sqrtf(v[0] * v[0] + v[1] * v[1]);
@@ -601,20 +618,36 @@ MINLINE float len_squared_v2v2(const float a[2], const float b[2])
return dot_v2v2(d, d);
}
-MINLINE float len_v3v3(const float a[3], const float b[3])
+MINLINE float len_squared_v3v3(const float a[3], const float b[3])
{
float d[3];
sub_v3_v3v3(d, b, a);
- return len_v3(d);
+ return dot_v3v3(d, d);
}
-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])
+{
+ float d[2];
+
+ sub_v2_v2v2(d, b, a);
+ return len_manhattan_v2(d);
+}
+
+MINLINE float len_manhattan_v3v3(const float a[3], const float b[3])
{
float d[3];
sub_v3_v3v3(d, b, a);
- return dot_v3v3(d, d);
+ return len_manhattan_v3(d);
+}
+
+MINLINE float len_v3v3(const float a[3], const float b[3])
+{
+ float d[3];
+
+ sub_v3_v3v3(d, b, a);
+ return len_v3(d);
}
MINLINE float normalize_v2_v2(float r[2], const float a[2])