fixed view plane distance calculation to use tan() and convert degrees to radians

git-svn-id: svn://anubis/fart/trunk@41 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-01-23 16:44:39 +00:00
1 parent a1c81e5adc
commit 20eafaf9f4
3 files changed
+19 -5

No files matched your search

+15 -3
View File
@@ -19,15 +19,27 @@ Vector::Vector(double x, double y, double z)
Vector & Vector::normalize()
{
double length = sqrt(m_array[0] * m_array[0]
+ m_array[1] * m_array[1]
+ m_array[2] * m_array[2]);
double length = mag();
m_array[0] /= length;
m_array[1] /= length;
m_array[2] /= length;
return *this;
}
double Vector::mag()
{
return sqrt(m_array[0] * m_array[0]
+ m_array[1] * m_array[1]
+ m_array[2] * m_array[2]);
}
double Vector::mag2()
{
return m_array[0] * m_array[0]
+ m_array[1] * m_array[1]
+ m_array[2] * m_array[2];
}
std::ostream & operator<<(std::ostream & out, const Vector & v)
{
out << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]";
+2
View File
@@ -12,6 +12,8 @@ class Vector
double & operator[](int idx) { return m_array[idx]; }
double operator[](int idx) const { return m_array[idx]; }
Vector & normalize();
double mag();
double mag2();
private:
double m_array[3];