Make Vector3 methods const
This commit is contained in:
parent
68a4855edf
commit
f062efc349
2 changed files with 14 additions and 7 deletions
|
@ -44,6 +44,7 @@ Vector3::Vector3(float _x, float _y, float _z)
|
|||
*/
|
||||
inline Vector3
|
||||
Vector3::operator+(Vector3 v)
|
||||
const
|
||||
{
|
||||
return Vector3(x + v.x, y + v.y, z + v.z);
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ Vector3::operator+(Vector3 v)
|
|||
*/
|
||||
inline Vector3
|
||||
Vector3::operator*(float a)
|
||||
const
|
||||
{
|
||||
return Vector3(a*x, a*y, a*z);
|
||||
}
|
||||
|
@ -68,6 +70,7 @@ Vector3::operator*(float a)
|
|||
*/
|
||||
inline Vector3
|
||||
Vector3::operator-(Vector3 v)
|
||||
const
|
||||
{
|
||||
return Vector3(x - v.x, y - v.y, z - v.z);
|
||||
}
|
||||
|
@ -80,6 +83,7 @@ Vector3::operator-(Vector3 v)
|
|||
*/
|
||||
inline Vector3
|
||||
Vector3::operator-()
|
||||
const
|
||||
{
|
||||
return Vector3(-x, -y, -z);
|
||||
}
|
||||
|
@ -92,6 +96,7 @@ Vector3::operator-()
|
|||
*/
|
||||
inline float
|
||||
Vector3::length2()
|
||||
const
|
||||
{
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
|
@ -104,6 +109,7 @@ Vector3::length2()
|
|||
*/
|
||||
inline float
|
||||
Vector3::length()
|
||||
const
|
||||
{
|
||||
return sqrtf(length2());
|
||||
}
|
||||
|
@ -116,6 +122,7 @@ Vector3::length()
|
|||
*/
|
||||
inline float
|
||||
Vector3::dot(Vector3 v)
|
||||
const
|
||||
{
|
||||
return x*v.x + y*v.x + z*v.z;
|
||||
}
|
||||
|
|
14
src/basics.h
14
src/basics.h
|
@ -17,14 +17,14 @@ struct Vector3
|
|||
Vector3();
|
||||
Vector3(float x, float y, float z);
|
||||
|
||||
Vector3 operator+(Vector3 v);
|
||||
Vector3 operator*(float a);
|
||||
Vector3 operator-(Vector3 v);
|
||||
Vector3 operator-();
|
||||
Vector3 operator+(Vector3 v) const;
|
||||
Vector3 operator*(float a) const;
|
||||
Vector3 operator-(Vector3 v) const;
|
||||
Vector3 operator-() const;
|
||||
|
||||
float length2();
|
||||
float length();
|
||||
float dot(Vector3 v);
|
||||
float length2() const;
|
||||
float length() const;
|
||||
float dot(Vector3 v) const;
|
||||
|
||||
void normalize();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue