mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 16:35:06 +03:00
ipa: libipa: vector: Add mutable x(), y() and z() accessors
The x(), y() and z() functions of the Vector class are convenience accessors for the first, second and third element of the vector respectively, meant to improve readability of class users when a vector represents coordinates in 1D, 2D or 3D space. Those accessors are limited to immutable access to the vector elements, as they return a copy. Extend the API with mutable accessors. The immutable accessors are modified to return a reference to the vector elements instead of a copy for consistency. As they are inline functions, this should make no difference in terms of performance as the compiler can perform the same optimizations in their case. While at it, reorder functions to declare operators before other member functions, to be consistent with the usual coding style. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
d0478c41f4
commit
6089b5bc94
2 changed files with 58 additions and 42 deletions
|
@ -52,24 +52,6 @@ namespace ipa {
|
|||
* \copydoc Vector::operator[](size_t i) const
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Vector::x()
|
||||
* \brief Convenience function to access the first element of the vector
|
||||
* \return The first element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Vector::y()
|
||||
* \brief Convenience function to access the second element of the vector
|
||||
* \return The second element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Vector::z()
|
||||
* \brief Convenience function to access the third element of the vector
|
||||
* \return The third element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Vector::operator-() const
|
||||
* \brief Negate a Vector by negating both all of its coordinates
|
||||
|
@ -111,6 +93,39 @@ namespace ipa {
|
|||
* \return The vector divided by \a factor
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr T &Vector::x()
|
||||
* \brief Convenience function to access the first element of the vector
|
||||
* \return The first element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr T &Vector::y()
|
||||
* \brief Convenience function to access the second element of the vector
|
||||
* \return The second element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr T &Vector::z()
|
||||
* \brief Convenience function to access the third element of the vector
|
||||
* \return The third element of the vector
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr const T &Vector::x() const
|
||||
* \copydoc Vector::x()
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr const T &Vector::y() const
|
||||
* \copydoc Vector::y()
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn constexpr const T &Vector::z() const
|
||||
* \copydoc Vector::z()
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Vector::length2()
|
||||
* \brief Get the squared length of the vector
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue