summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/hamilton-tools.cpp18
-rw-r--r--compat/hamilton-tools.h10
2 files changed, 14 insertions, 14 deletions
diff --git a/compat/hamilton-tools.cpp b/compat/hamilton-tools.cpp
index e18082a8..dfbb4630 100644
--- a/compat/hamilton-tools.cpp
+++ b/compat/hamilton-tools.cpp
@@ -1,19 +1,19 @@
#include "hamilton-tools.h"
#include <cmath>
-double VectorLength(const tVector v)
+double VectorLength(const tVector& v)
{
return(sqrt(v.v[0]*v.v[0] + v.v[1]*v.v[1] + v.v[2]*v.v[2]));
}
double sqr(const double v) { return(v*v); }
-double VectorDistance(const double v1[], const tVector v2)
+double VectorDistance(const double v1[], const tVector& v2)
{
return(sqrt(sqr(v2.v[0]-v1[0])+sqr(v2.v[1]-v1[1])+sqr(v2.v[2]-v1[2])));
}
-tVector Lerp(const tVector s, const double d[], const double alpha)
+tVector Lerp(const tVector& s, const double d[], const double alpha)
{
tVector V;
V.v[0] = s.v[0] + (d[0] - s.v[0]) * alpha;
@@ -22,7 +22,7 @@ tVector Lerp(const tVector s, const double d[], const double alpha)
return(V);
}
-tQuat QuatFromAngleAxe(const double angle, const tVector axe)
+tQuat QuatFromAngleAxe(const double angle, const tVector& axe)
{
double a = TO_RAD * 0.5 * angle;
double d = sin(a) / VectorLength(axe);
@@ -35,7 +35,7 @@ tQuat QuatFromAngleAxe(const double angle, const tVector axe)
);
}
-tQuat QuatMultiply(const tQuat qL, const tQuat qR)
+tQuat QuatMultiply(const tQuat& qL, const tQuat& qR)
{
tQuat Q;
Q.x = qL.w*qR.x + qL.x*qR.w + qL.y*qR.z - qL.z*qR.y;
@@ -45,7 +45,7 @@ tQuat QuatMultiply(const tQuat qL, const tQuat qR)
return(Q);
}
-double AngleBetween(const tQuat S, const tQuat D)
+double AngleBetween(const tQuat& S, const tQuat& D)
{
return( TO_DEG * 2*acos(fabs(S.x*D.x + S.y*D.y + S.z*D.z + S.w*D.w)) );
}
@@ -61,7 +61,7 @@ tQuat QuatFromYPR(const double YPR[])
return(QuatMultiply(Qy, Q));
}
-void Normalize(tQuat Q)
+void Normalize(tQuat& Q)
{
double m = sqrt(Q.x*Q.x + Q.y*Q.y + Q.z*Q.z + Q.w*Q.w);
if (m > EPSILON)
@@ -75,7 +75,7 @@ void Normalize(tQuat Q)
else Q = tQuat(0, 0, 0, 1);
}
-tQuat Slerp(const tQuat S, const tQuat D, const double alpha)
+tQuat Slerp(const tQuat& S, const tQuat& D, const double alpha)
{
// calc cosine of half angle
double cosin = S.x*D.x + S.y*D.y + S.z*D.z + S.w*D.w;
@@ -117,7 +117,7 @@ tQuat Slerp(const tQuat S, const tQuat D, const double alpha)
return( Q );
}
-void QuatToYPR(const tQuat Q, double YPR[])
+void QuatToYPR(const tQuat& Q, double YPR[])
{
const double xx = Q.x * Q.x;
const double xy = Q.x * Q.y;
diff --git a/compat/hamilton-tools.h b/compat/hamilton-tools.h
index 6bcd7b5d..73bc882c 100644
--- a/compat/hamilton-tools.h
+++ b/compat/hamilton-tools.h
@@ -21,9 +21,9 @@ struct tQuat
{x = X; y = Y; z = Z; w = W;}
};
-double OTR_COMPAT_EXPORT VectorDistance(const double v1[], const tVector v2);
-tVector OTR_COMPAT_EXPORT Lerp (const tVector s, const double d[], const double alpha);
+double OTR_COMPAT_EXPORT VectorDistance(const double v1[], const tVector& v2);
+tVector OTR_COMPAT_EXPORT Lerp (const tVector& s, const double d[], const double alpha);
tQuat OTR_COMPAT_EXPORT QuatFromYPR (const double YPR[]);
-double OTR_COMPAT_EXPORT AngleBetween (const tQuat S, const tQuat D);
-tQuat OTR_COMPAT_EXPORT Slerp (const tQuat S, const tQuat D, const double alpha);
-void OTR_COMPAT_EXPORT QuatToYPR (const tQuat Q, double YPR[]);
+double OTR_COMPAT_EXPORT AngleBetween (const tQuat& S, const tQuat& D);
+tQuat OTR_COMPAT_EXPORT Slerp (const tQuat& S, const tQuat& D, const double alpha);
+void OTR_COMPAT_EXPORT QuatToYPR (const tQuat& Q, double YPR[]);