2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Implements the CqVector3D class.
23
\author Paul C. Gregory (pgregory@aqsis.com)
33
START_NAMESPACE( Aqsis )
35
//---------------------------------------------------------------------
36
/** Copy constructor from 4D Vector.
39
CqVector3D::CqVector3D( const CqVector4D &From )
45
//---------------------------------------------------------------------
46
/** Copy constructor from color.
49
CqVector3D::CqVector3D( const CqColor &From )
55
//---------------------------------------------------------------------
56
/** Cross product of two vectors.
59
CqVector3D operator%( const CqVector3D &a, const CqVector3D &b )
61
return ( CqVector3D( ( a.m_y * b.m_z ) - ( a.m_z * b.m_y ),
62
( a.m_z * b.m_x ) - ( a.m_x * b.m_z ),
63
( a.m_x * b.m_y ) - ( a.m_y * b.m_x ) ) );
66
//---------------------------------------------------------------------
67
/** Sets this vector to be the cross product of itself and another vector.
70
CqVector3D &CqVector3D::operator%=( const CqVector3D &From )
72
CqVector3D vecTemp( *this );
74
m_x = ( vecTemp.m_y * From.m_z ) - ( vecTemp.m_z * From.m_y );
75
m_y = ( vecTemp.m_z * From.m_x ) - ( vecTemp.m_x * From.m_z );
76
m_z = ( vecTemp.m_x * From.m_y ) - ( vecTemp.m_y * From.m_x );
81
//---------------------------------------------------------------------
82
/** Copy from specified 4D vector.
85
CqVector3D &CqVector3D::operator=( const CqVector4D &From )
87
if ( From.h() != 1.0 )
89
m_x = From.x() / From.h();
90
m_y = From.y() / From.h();
91
m_z = From.z() / From.h();
104
//---------------------------------------------------------------------
105
/** Copy from specified color.
108
CqVector3D &CqVector3D::operator=( const CqColor &From )
118
//----------------------------------------------------------------------
119
/** Outputs a vector to an output stream.
120
* \param Stream Stream to output the matrix to.
121
* \param Vector The vector to output.
122
* \return The new state of Stream.
125
std::ostream &operator<<( std::ostream &Stream, const CqVector3D &Vector )
127
Stream << Vector.m_x << "," << Vector.m_y << "," << Vector.m_z;
132
//---------------------------------------------------------------------
134
END_NAMESPACE( Aqsis )