aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/geo
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/geo')
-rw-r--r--meowpp/geo/Vectors.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/meowpp/geo/Vectors.h b/meowpp/geo/Vectors.h
index 0f09ee6..78fcc42 100644
--- a/meowpp/geo/Vectors.h
+++ b/meowpp/geo/Vectors.h
@@ -91,6 +91,16 @@ public:
return *this;
}
+ //! @brief access the \c i -th scalar (0 => x, 1 => y)
+ Scalar const& scalar(size_t i) const {
+ return (i == 0 ? x() : (i == 1 ? y() : Scalar(0)));
+ }
+
+ //! @brief modivy the \c i -th scalar (0 => x, 1 => y)
+ Scalar const& scalar(size_t i, Scalar const& s) {
+ return (i == 0 ? x(s) : (i == 1 ? y(s) : s));
+ }
+
//! @brief return \a +(*this)
Vector2D positive() const {
return *this;
@@ -347,6 +357,16 @@ public:
return *this;
}
+ //! @brief access the \c i -th scalar (0 => x, 1 => y, 2 => z) {
+ Scalar const& scalar(size_t i) const {
+ return (i == 0 ? x() : (i == 1 ? y() : (i == 2 ? z() : Scalar(0))));
+ }
+
+ //! @brief modivy the \c i -th scalar (0 => x, 1 => y, 2 => z)
+ Scalar const& scalar(size_t i, Scalar const& s) {
+ return (i == 0 ? x(s) : (i == 1 ? y(s) : (i == 2 ? z(s) : s )));
+ }
+
//! @brief return \a +(*this)
Vector3D positive() const {
return *this;
@@ -471,7 +491,7 @@ public:
return ret;
}
- //! @brief return a 3x1 matrix form of itself
+ //! @brief return a 4x1 matrix form of itself
Matrix<Scalar> matrix(Scalar const& homo) const {
static Matrix<Scalar> ret(4, 1, Scalar(0));
ret(0, 0, x());
@@ -505,6 +525,6 @@ public:
Vector3D& operator/=(Scalar const& s) { return dived(s); }
};
-}
+} // meow
#endif // geo_Vectors_H__