diff options
Diffstat (limited to 'src/math/vector3f.h')
-rw-r--r-- | src/math/vector3f.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/math/vector3f.h b/src/math/vector3f.h index 82b818e..99a665f 100644 --- a/src/math/vector3f.h +++ b/src/math/vector3f.h @@ -114,6 +114,27 @@ public: return coord[index]; } + /// x coordinate + inline float x() const { return coord[0]; } + + /// y coordinate + inline float y() const { return coord[1]; } + + /// z coordinate + inline float z() const { return coord[2]; } + + /// mutable reference to the x coordinate + inline float & get_x() { return coord[0]; } + + /// mutable reference to the y coordinate + inline float & get_y() { return coord[1]; } + + /// mutable reference to the z coordinate + inline float & get_z() { return coord[2]; } + + /// a pointer to the internal data + inline float *ptr() const { return (float *) coord; } + /// cartesian length float length() const; @@ -125,11 +146,6 @@ public: /// vector must not be (0, 0, 0) void normalize(); - /// a pointer to the internal data - inline float *ptr() const { - return (float *) coord; - } - /* static functions */ /// Returns the unity vector on the X-axis @@ -158,11 +174,7 @@ public: static inline Vector3f normalized(const Vector3f & vector) { return (vector / vector.length()); } - - float &x; - float &y; - float &z; - + private: float coord[3]; }; |