summaryrefslogtreecommitdiff
path: root/indra/llmath/v3math.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2014-02-13 15:35:21 -0800
committerRichard Linden <none@none>2014-02-13 15:35:21 -0800
commita347267cf1c55a3bd57d30117b8aa834623e1d61 (patch)
tree6df52463fa8516f6e2f42c15bf1eedf80caa7dd6 /indra/llmath/v3math.h
parent7e291bb4689c45d6f470d2a1958339728c52d8ce (diff)
cleaned up llmanipscale logic for readability...no change in functionality
Diffstat (limited to 'indra/llmath/v3math.h')
-rwxr-xr-xindra/llmath/v3math.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 0432aeba4c..c807a30f7b 100755
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -159,6 +159,9 @@ F32 dist_vec(const LLVector3 &a, const LLVector3 &b); // Returns distance betwe
F32 dist_vec_squared(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b
F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b ignoring Z component
LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b
+// Returns a vector in direction of a, such that when projected onto b, gives you the same value as b
+// in other words: projected_vec(inverse_projected_vec(a, b), b) == b;
+LLVector3 inverse_projected_vec(const LLVector3 &a, const LLVector3 &b);
LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b (same as projected_vec)
LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b); // Returns component of vector a not parallel to vector b (same as projected_vec)
LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vector that is a linear interpolation between a and b
@@ -495,6 +498,18 @@ inline LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b)
return project_axis * (a * project_axis);
}
+inline LLVector3 inverse_projected_vec(const LLVector3& a, const LLVector3& b)
+{
+ LLVector3 normalized_a = a;
+ normalized_a.normalize();
+ LLVector3 normalized_b = b;
+ F32 b_length = normalized_b.normalize();
+
+ F32 dot_product = normalized_a * normalized_b;
+ //NB: if a _|_ b, then returns an infinite vector
+ return normalized_a * (b_length / dot_product);
+}
+
inline LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b)
{
return projected_vec(a, b);