diff --git a/include/Geometry/matrix.h b/include/Geometry/matrix.h index 7c72e4418a4b2d2119f0fc94ac30c078147df0af..42e814d136fb6a8498ea457a9581d8db3732d9e6 100644 --- a/include/Geometry/matrix.h +++ b/include/Geometry/matrix.h @@ -161,11 +161,15 @@ class Matrix // Vector / Matrix multiplication template -Vector operator*(const Vector& v, const Matrix& m); +Vector operator*(const Vector& v, const Matrix& m) ; // Scalar / Matrix multiplication template -Matrix operator*(T s, const Matrix& m); +Matrix operator*(T s, const Matrix& m) ; + +// Vector / Transposed vector multiplication +template +Matrix transposed_vectors_mult(const Vector& v1, const Vector& v2) ; /**********************************************/ diff --git a/include/Geometry/matrix.hpp b/include/Geometry/matrix.hpp index 3ade5395ceb19524d85357f8774fedc2a3b121df..85495aa1c60303b25990ceea5e923e1d37283c59 100644 --- a/include/Geometry/matrix.hpp +++ b/include/Geometry/matrix.hpp @@ -405,9 +405,11 @@ bool Matrix::operator==(const Matrix& m) const { template std::ostream& operator<<(std::ostream& out, const Matrix& m) { - for(unsigned int i = 0; i < M; ++i) + for(unsigned int i = 0; i < M; ++i) { for(unsigned int j = 0; j < N; ++j) out << m(i,j) << " " ; + std::cout << std::endl ; + } return out ; } @@ -446,6 +448,15 @@ Matrix operator*(T s, const Matrix& m) return res ; } +template +Matrix transposed_vectors_mult(const Vector& v1, const Vector& v2) { + Matrix res ; + for(unsigned int i = 0; i < M; ++i) + for(unsigned int j = 0; j < N; ++j) + res(i,j) = v1[i] * v2[j] ; + return res ; +} + } // namespace Geom } // namespace CGoGN diff --git a/include/Utils/colourConverter.h b/include/Utils/colourConverter.h index b4e05084918a5352ed76c960f98103db621ddef0..c9f59244299b14b39f11f3379106b27d440b6639 100644 --- a/include/Utils/colourConverter.h +++ b/include/Utils/colourConverter.h @@ -71,6 +71,16 @@ public: // methods */ ~ColourConverter() {} ; + /** + * getR + * @return original value (in its original space) + */ + VEC3 getOriginal() ; + /** + * getR + * @return enc value of provided colour + */ + VEC3 getColour(enum ColourEncoding enc) ; /** * getR * @return RGB value of provided colour diff --git a/include/Utils/colourConverter.hpp b/include/Utils/colourConverter.hpp index 66954ed3c346fa38b0d133947c7697f4b3429558..20684db2704b6406d304e9b69c651bb860250cca 100644 --- a/include/Utils/colourConverter.hpp +++ b/include/Utils/colourConverter.hpp @@ -65,6 +65,36 @@ ColourConverter::ColourConverter(VEC3 col, enum ColourEncoding enc) : } } +template +Geom::Vector<3,REAL> ColourConverter::getColour(enum ColourEncoding enc) { + switch (enc) { + case (C_RGB) : + return getRGB() ; + break ; + + case (C_XYZ) : + return getXYZ() ; + break ; + + case (C_Luv) : + return getLuv() ; + break ; + + case (C_Lab) : + return getLab() ; + break ; + + default : + assert(!"Should never arrive here : ColourConverter::getColour default case") ; + return getOriginal() ; + } +} + +template +Geom::Vector<3,REAL> ColourConverter::getOriginal() { + return getColour(this->originalEnc) ; +} + template Geom::Vector<3,REAL> ColourConverter::getRGB() { if (RGB == NULL) @@ -150,7 +180,7 @@ void ColourConverter::convertXYZtoLuv() { REAL Ydiv = Y/Yn ; if (Ydiv > 0.008856) - L = 116.0 * pow(Ydiv,1.0f/3.0) - 16.0 ; + L = 116.0 * pow(Ydiv,1.0/3.0) - 16.0 ; else // near black L = 903.3 * Ydiv ;