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
|
inline Vector3
|
||||||
Vector3::operator+(Vector3 v)
|
Vector3::operator+(Vector3 v)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return Vector3(x + v.x, y + v.y, z + v.z);
|
return Vector3(x + v.x, y + v.y, z + v.z);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +57,7 @@ Vector3::operator+(Vector3 v)
|
||||||
*/
|
*/
|
||||||
inline Vector3
|
inline Vector3
|
||||||
Vector3::operator*(float a)
|
Vector3::operator*(float a)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return Vector3(a*x, a*y, a*z);
|
return Vector3(a*x, a*y, a*z);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +70,7 @@ Vector3::operator*(float a)
|
||||||
*/
|
*/
|
||||||
inline Vector3
|
inline Vector3
|
||||||
Vector3::operator-(Vector3 v)
|
Vector3::operator-(Vector3 v)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return Vector3(x - v.x, y - v.y, z - v.z);
|
return Vector3(x - v.x, y - v.y, z - v.z);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +83,7 @@ Vector3::operator-(Vector3 v)
|
||||||
*/
|
*/
|
||||||
inline Vector3
|
inline Vector3
|
||||||
Vector3::operator-()
|
Vector3::operator-()
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return Vector3(-x, -y, -z);
|
return Vector3(-x, -y, -z);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +96,7 @@ Vector3::operator-()
|
||||||
*/
|
*/
|
||||||
inline float
|
inline float
|
||||||
Vector3::length2()
|
Vector3::length2()
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return x*x + y*y + z*z;
|
return x*x + y*y + z*z;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +109,7 @@ Vector3::length2()
|
||||||
*/
|
*/
|
||||||
inline float
|
inline float
|
||||||
Vector3::length()
|
Vector3::length()
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return sqrtf(length2());
|
return sqrtf(length2());
|
||||||
}
|
}
|
||||||
|
@ -116,6 +122,7 @@ Vector3::length()
|
||||||
*/
|
*/
|
||||||
inline float
|
inline float
|
||||||
Vector3::dot(Vector3 v)
|
Vector3::dot(Vector3 v)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return x*v.x + y*v.x + z*v.z;
|
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();
|
||||||
Vector3(float x, float y, float z);
|
Vector3(float x, float y, float z);
|
||||||
|
|
||||||
Vector3 operator+(Vector3 v);
|
Vector3 operator+(Vector3 v) const;
|
||||||
Vector3 operator*(float a);
|
Vector3 operator*(float a) const;
|
||||||
Vector3 operator-(Vector3 v);
|
Vector3 operator-(Vector3 v) const;
|
||||||
Vector3 operator-();
|
Vector3 operator-() const;
|
||||||
|
|
||||||
float length2();
|
float length2() const;
|
||||||
float length();
|
float length() const;
|
||||||
float dot(Vector3 v);
|
float dot(Vector3 v) const;
|
||||||
|
|
||||||
void normalize();
|
void normalize();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue