Hi,
I have the folowing code (Assuming corect constructors and accesors):
class Vector{
private:
double x;
double y;
public:
Vector operator-(Vector b);
}
Vector Vector::operato r-(Vector b){
Vector result= Vector(x-b.x(),y-b.y());
return result;
}
in another method I do the following:
set Vector iBallPos to some value
set Vector iPlayerPos to some value
Vector iBallDistVec=iP layerPos - iBallPos;
when output IBallPos, iPlayerPos and iBallDist I get the following:
Token "iBallPos.x ()" is: 45.4729
Token "iBallPos.y ()" is: -19.3021
Token "iPlayerPos.x() " is: 0
Token "iPlayerPos.y() " is: 0
Token "iBallDistVec.x ()" is: -0.920505
Token "iBallDistVec.y ()" is: 0.390731
or similar wrong values.
If anybody has any idea, what is wrong wrong with this code, please let me
know.
Till
--
Please add "Salt and Peper" to the subject line to bypass my spam filter
I have the folowing code (Assuming corect constructors and accesors):
class Vector{
private:
double x;
double y;
public:
Vector operator-(Vector b);
}
Vector Vector::operato r-(Vector b){
Vector result= Vector(x-b.x(),y-b.y());
return result;
}
in another method I do the following:
set Vector iBallPos to some value
set Vector iPlayerPos to some value
Vector iBallDistVec=iP layerPos - iBallPos;
when output IBallPos, iPlayerPos and iBallDist I get the following:
Token "iBallPos.x ()" is: 45.4729
Token "iBallPos.y ()" is: -19.3021
Token "iPlayerPos.x() " is: 0
Token "iPlayerPos.y() " is: 0
Token "iBallDistVec.x ()" is: -0.920505
Token "iBallDistVec.y ()" is: 0.390731
or similar wrong values.
If anybody has any idea, what is wrong wrong with this code, please let me
know.
Till
--
Please add "Salt and Peper" to the subject line to bypass my spam filter
Comment