L
Lateralus
headers/vector3.h: In member function ‘Vector3
Vector3:perator*(Scalar)’:
headers/vector3.h:13: error: no matching function for call to
‘Vector3::Vector3(Vector3)’
‘Vector3::Vector3(Vector3)’
headers/vector3.h:10: note: candidates are: Vector3::Vector3(Vector3&)
I'm a little confused as to what my problem is. I get this error for
any method which calls the constructor.
#ifndef __VECTOR3_H__
#define __VECTOR3_H__
#include "common_math.h"
class Vector3 {
public:
Scalar x, y, z;
Vector3(void) { x = y = z = 0; }
Vector3(Scalar fx, Scalar fy, Scalar fz) { x = fx; y = fy; z = fz; }
Vector3(Vector3& v) { x = v.x; y = v.y; z = v.z; }
Vector3 operator=(Vector3& v) { x = v.x; y = v.y; z = v.z; return v;}
Vector3 operator*(Scalar s) { return Vector3(x*s, y*s, z*s); }
friend Vector3 operator*(Scalar s, Vector3& v) { return
Vector3(v.x*s, v.y*s, v.z*s); }
Vector3 operator/(Scalar s) { return Vector3(x/s, y/s, z/s); }
Vector3 operator+(Vector3& v) { return Vector3(x+v.x, y+v.y, z+v.z);
}
Vector3 operator-(Vector3& v) { return Vector3(x-v.x, y-v.y, z-v.z);
}
void operator+=(Vector3& v) { x += v.x; y += v.y; z += v.z; }
void operator-=(Vector3& v) { x -= v.x; y -= v.y; z -= v.z; }
void operator*=(Scalar s) { x *= s; y *= s; z *= s; }
void operator/=(Scalar s) { x /= s; y /= s; z /= s; }
Scalar Magnitude(void) { return (Scalar)sqrt(x*x + y*y + z*z); }
Vector3 Normalize(void) { return *this/Magnitude(); }
Scalar DotProduct(Vector3& v) { return (x*v.x + y*v.y + z*v.z); }
Vector3 CrossProduct(Vector3& v) { return Vector3((y*v.z)-(z*v.y),
(z*v.x)-(x*v.z), (x*v.y)-(y*v.x)); }
Vector3 Rotate(Scalar xr, Scalar yr, Scalar zr) {
Scalar sxr, syr, szr, cxr, cyr, czr;
sxr = (Scalar)sin(DegToRad(xr));
syr = (Scalar)sin(DegToRad(yr));
szr = (Scalar)sin(DegToRad(zr));
cxr = (Scalar)cos(DegToRad(xr));
cyr = (Scalar)cos(DegToRad(yr));
czr = (Scalar)cos(DegToRad(zr));
return Vector3(((x*(cyr*czr))+
(y*(cyr*szr))+
(z*(-syr))),
((x*((sxr*syr*czr)+(cxr*(-szr))))+
(y*((sxr*syr*szr)+(cxr*czr)))+
(z*(sxr*cyr))),
((x*((cxr*syr*czr)+(sxr*(-szr))))+
(y*((cxr*syr*szr)+((-sxr)*czr)))+
(z*(cxr*cyr))));
}
};
#endif //__VECTOR3_H__
Vector3:perator*(Scalar)’:
headers/vector3.h:13: error: no matching function for call to
‘Vector3::Vector3(Vector3)’
‘Vector3::Vector3(Vector3)’
headers/vector3.h:10: note: candidates are: Vector3::Vector3(Vector3&)
I'm a little confused as to what my problem is. I get this error for
any method which calls the constructor.
#ifndef __VECTOR3_H__
#define __VECTOR3_H__
#include "common_math.h"
class Vector3 {
public:
Scalar x, y, z;
Vector3(void) { x = y = z = 0; }
Vector3(Scalar fx, Scalar fy, Scalar fz) { x = fx; y = fy; z = fz; }
Vector3(Vector3& v) { x = v.x; y = v.y; z = v.z; }
Vector3 operator=(Vector3& v) { x = v.x; y = v.y; z = v.z; return v;}
Vector3 operator*(Scalar s) { return Vector3(x*s, y*s, z*s); }
friend Vector3 operator*(Scalar s, Vector3& v) { return
Vector3(v.x*s, v.y*s, v.z*s); }
Vector3 operator/(Scalar s) { return Vector3(x/s, y/s, z/s); }
Vector3 operator+(Vector3& v) { return Vector3(x+v.x, y+v.y, z+v.z);
}
Vector3 operator-(Vector3& v) { return Vector3(x-v.x, y-v.y, z-v.z);
}
void operator+=(Vector3& v) { x += v.x; y += v.y; z += v.z; }
void operator-=(Vector3& v) { x -= v.x; y -= v.y; z -= v.z; }
void operator*=(Scalar s) { x *= s; y *= s; z *= s; }
void operator/=(Scalar s) { x /= s; y /= s; z /= s; }
Scalar Magnitude(void) { return (Scalar)sqrt(x*x + y*y + z*z); }
Vector3 Normalize(void) { return *this/Magnitude(); }
Scalar DotProduct(Vector3& v) { return (x*v.x + y*v.y + z*v.z); }
Vector3 CrossProduct(Vector3& v) { return Vector3((y*v.z)-(z*v.y),
(z*v.x)-(x*v.z), (x*v.y)-(y*v.x)); }
Vector3 Rotate(Scalar xr, Scalar yr, Scalar zr) {
Scalar sxr, syr, szr, cxr, cyr, czr;
sxr = (Scalar)sin(DegToRad(xr));
syr = (Scalar)sin(DegToRad(yr));
szr = (Scalar)sin(DegToRad(zr));
cxr = (Scalar)cos(DegToRad(xr));
cyr = (Scalar)cos(DegToRad(yr));
czr = (Scalar)cos(DegToRad(zr));
return Vector3(((x*(cyr*czr))+
(y*(cyr*szr))+
(z*(-syr))),
((x*((sxr*syr*czr)+(cxr*(-szr))))+
(y*((sxr*syr*szr)+(cxr*czr)))+
(z*(sxr*cyr))),
((x*((cxr*syr*czr)+(sxr*(-szr))))+
(y*((cxr*syr*szr)+((-sxr)*czr)))+
(z*(cxr*cyr))));
}
};
#endif //__VECTOR3_H__