From a970d30fedc77d78252cd93a2f0a027e58451c33 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 17 Jan 2009 19:40:35 +0000 Subject: [PATCH] added getPositionAt() to Ray module git-svn-id: svn://anubis/gvsu@368 45c1a28c-8058-47b2-ae61-ca45b979098e --- cs658/final/util/Ray.cc | 13 +++++++++++++ cs658/final/util/Ray.h | 1 + 2 files changed, 14 insertions(+) diff --git a/cs658/final/util/Ray.cc b/cs658/final/util/Ray.cc index ba1f2a0..5a6ba72 100644 --- a/cs658/final/util/Ray.cc +++ b/cs658/final/util/Ray.cc @@ -10,3 +10,16 @@ Ray::Ray(const Vector & origin, const Vector & direction) m_origin = origin; m_direction = direction; } + +/* + * return a vector for the point at distance dist + * from the ray's origin point, along its direction. + */ +Vector Ray::getPositionAt(double dist) const +{ + Vector v; + v[0] = m_origin[0] + dist * m_direction[0]; + v[1] = m_origin[1] + dist * m_direction[1]; + v[2] = m_origin[2] + dist * m_direction[2]; + return v; +} diff --git a/cs658/final/util/Ray.h b/cs658/final/util/Ray.h index 93b5ff0..85367fd 100644 --- a/cs658/final/util/Ray.h +++ b/cs658/final/util/Ray.h @@ -11,6 +11,7 @@ class Ray Ray(const Vector & origin, const Vector & direction); Vector getOrigin() const { return m_origin; } Vector getDirection() const { return m_direction; } + Vector getPositionAt(double dist) const; private: Vector m_origin;