summaryrefslogtreecommitdiffstats
path: root/src/Vector3.h
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-03-11 17:10:15 +0100
committerandrew <xdotftw@gmail.com>2014-03-11 17:10:15 +0100
commitd64db443c2d0f094c4ee098fa1ffacb2c92e5d88 (patch)
tree273f9f5f8cd97d73e9d0db391de15d1696b205c7 /src/Vector3.h
parentUnified Vector classes (diff)
downloadcuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar.gz
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar.bz2
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar.lz
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar.xz
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.tar.zst
cuberite-d64db443c2d0f094c4ee098fa1ffacb2c92e5d88.zip
Diffstat (limited to '')
-rw-r--r--src/Vector3.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Vector3.h b/src/Vector3.h
index 0be52248d..8ee7a87b0 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -10,10 +10,6 @@
-
-
-
-
template <typename T>
// tolua_begin
class Vector3
@@ -196,6 +192,11 @@ public:
);
}
+ /** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Z coord.
+ The result satisfies the following equation:
+ (*this + Result * (a_OtherEnd - *this)).z = a_Z
+ If the line is too close to being parallel, this function returns NO_INTERSECTION
+ */
inline double LineCoeffToXYPlane(const Vector3<T> & a_OtherEnd, T a_Z) const
{
if (abs(z - a_OtherEnd.z) < EPS)
@@ -206,6 +207,11 @@ public:
return (a_Z - z) / (a_OtherEnd.z - z);
}
+ /** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Y coord.
+ The result satisfies the following equation:
+ (*this + Result * (a_OtherEnd - *this)).y = a_Y
+ If the line is too close to being parallel, this function returns NO_INTERSECTION
+ */
inline double LineCoeffToXZPlane(const Vector3<T> & a_OtherEnd, T a_Y) const
{
if (abs(y - a_OtherEnd.y) < EPS)
@@ -216,6 +222,11 @@ public:
return (a_Y - y) / (a_OtherEnd.y - y);
}
+ /** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified X coord.
+ The result satisfies the following equation:
+ (*this + Result * (a_OtherEnd - *this)).x = a_X
+ If the line is too close to being parallel, this function returns NO_INTERSECTION
+ */
inline double LineCoeffToYZPlane(const Vector3<T> & a_OtherEnd, T a_X) const
{
if (abs(x - a_OtherEnd.x) < EPS)
@@ -231,9 +242,14 @@ public:
/** Return value of LineCoeffToPlane() if the line is parallel to the plane. */
static const double NO_INTERSECTION;
+
};
// tolua_end
+
+
+
+
template <typename T>
const double Vector3<T>::EPS = 0.000001;