9.6 VecPosition
VecPosition
Is used to define 3-Dimensional Vectors which can be used to store posiitonal information. When the supplied Coordinate System type equals CARTESIAN, the arguments x and y denote the x- and y-coordinates of the new position. When it equals POLAR however, the arguments x and y denote the polar coordinates of the new position; in this case x is thus equal to the distance r from the origin and y is equal to the angle phi that the polar vector makes with the x-axis. By deafult CARTESIAN coordinates are used.
VecPosition::VecPosition(double x, double y, double z, CoordSystemT cs) {
setVecPosition(x, y, z, cs );
}
There are multiple additional methods for handling the manipulation of a VecPosition
object which can be seen in vecposition.h
and the implementation for these can be found in vecposition.cc
. These methods include stuff like checking if two VecPosition
objects are equal as well as operators for handling the addition and subtraction of VecPosition
objects.
For example if we define 2 VecPosition
objects as:
VecPosition a = VecPositon(1,2,3);
VecPosition b = VecPositon(1,1,1);
we can find the sum of these objects simply by saying VecPosition c = a + b
and this is thanks to the fact that
inline VecPosition operator + ( const VecPosition &p ) const {
return ( VecPosition( m_x + p.m_x, m_y + p.m_y, m_z + p.m_z ) );
}
has already been defined for us to use along with many others.
A variable called ball
in the strategy.cc
file is of type VecPosition
and it stores the position of the ball.