2004-03-16 04:07:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
2016-06-13 07:29:25 +02:00
|
|
|
* Copyright(C) 2004-2016 \/)\/ *
|
2004-03-16 04:07:38 +01:00
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
make point2 derived Eigen's Matrix, and a set of minimal fixes to make meshlab compile
with both old and new version. The fixes include:
- dot product: vec0 * vec1 => vec0.dot(vec1) (I added .dot() to the old Point classes too)
- Transpose: Transpose is an Eigen type, so we cannot keep it if Eigen is used. Therefore
I added a .tranpose() to old matrix classes, and modified most of the Transpose() to transpose()
both in vcg and meshlab. In fact, transpose() are free with Eigen, it simply returns a transpose
expression without copies. On the other be carefull: m = m.transpose() won't work as expected,
here me must evaluate to a temporary: m = m.transpose().eval(); However, this operation in very
rarely needed: you transpose at the same sime you set m, or you use m.transpose() directly.
- the last issue is Normalize which both modifies *this and return a ref to it. This behavior
don't make sense anymore when using expression template, e.g., in (a+b).Normalize(), the type
of a+b if not a Point (or whatever Vector types), it an expression of the addition of 2 points,
so we cannot modify the value of *this, since there is no value. Therefore I've already changed
all those .Normalize() of expressions to the Eigen's version .normalized().
- Finally I've changed the Zero to SetZero in the old Point classes too.
2008-10-28 01:59:46 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
2004-03-16 04:07:38 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2004-04-29 12:47:06 +02:00
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
#ifndef VCG_USE_EIGEN
|
|
|
|
#include "deprecated_point.h"
|
|
|
|
#else
|
2004-03-16 04:07:38 +01:00
|
|
|
|
|
|
|
#ifndef __VCGLIB_POINT
|
|
|
|
#define __VCGLIB_POINT
|
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
#include "../math/eigen.h"
|
2004-03-16 04:07:38 +01:00
|
|
|
#include <vcg/math/base.h>
|
|
|
|
#include <vcg/space/space.h>
|
|
|
|
|
2008-10-29 12:17:11 +01:00
|
|
|
namespace vcg {
|
2008-10-28 21:06:17 +01:00
|
|
|
template<typename Scalar> class Point2;
|
|
|
|
template<typename Scalar> class Point3;
|
|
|
|
template<typename Scalar> class Point4;
|
2004-04-05 14:35:33 +02:00
|
|
|
|
2008-10-28 21:06:17 +01:00
|
|
|
namespace ndim{
|
|
|
|
template <int Size, typename Scalar> class Point;
|
|
|
|
}
|
2008-10-28 12:47:37 +01:00
|
|
|
}
|
2004-04-05 14:35:33 +02:00
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
namespace vcg {
|
|
|
|
namespace ndim{
|
make point2 derived Eigen's Matrix, and a set of minimal fixes to make meshlab compile
with both old and new version. The fixes include:
- dot product: vec0 * vec1 => vec0.dot(vec1) (I added .dot() to the old Point classes too)
- Transpose: Transpose is an Eigen type, so we cannot keep it if Eigen is used. Therefore
I added a .tranpose() to old matrix classes, and modified most of the Transpose() to transpose()
both in vcg and meshlab. In fact, transpose() are free with Eigen, it simply returns a transpose
expression without copies. On the other be carefull: m = m.transpose() won't work as expected,
here me must evaluate to a temporary: m = m.transpose().eval(); However, this operation in very
rarely needed: you transpose at the same sime you set m, or you use m.transpose() directly.
- the last issue is Normalize which both modifies *this and return a ref to it. This behavior
don't make sense anymore when using expression template, e.g., in (a+b).Normalize(), the type
of a+b if not a Point (or whatever Vector types), it an expression of the addition of 2 points,
so we cannot modify the value of *this, since there is no value. Therefore I've already changed
all those .Normalize() of expressions to the Eigen's version .normalized().
- Finally I've changed the Zero to SetZero in the old Point classes too.
2008-10-28 01:59:46 +01:00
|
|
|
|
2004-03-16 04:07:38 +01:00
|
|
|
/** \addtogroup space */
|
|
|
|
/*@{*/
|
2008-10-28 12:47:37 +01:00
|
|
|
/**
|
|
|
|
The templated class for representing a point in R^N space.
|
|
|
|
The class is templated over the ScalarType class that is used to represent coordinates.
|
|
|
|
PointBase provides the interface and the common operators for points
|
|
|
|
of any dimensionality.
|
|
|
|
*/
|
|
|
|
template <int N, class S> class Point : public Eigen::Matrix<S,N,1>
|
2004-03-16 04:07:38 +01:00
|
|
|
{
|
2008-10-28 21:06:17 +01:00
|
|
|
//----------------------------------------
|
|
|
|
// template typedef part
|
|
|
|
// use it as follow: typename Point<N,S>::Type instead of simply Point<N,S>
|
|
|
|
//----------------------------------------
|
|
|
|
public:
|
|
|
|
typedef Eigen::Matrix<S,N,1> Type;
|
|
|
|
//----------------------------------------
|
|
|
|
// inheritence part
|
|
|
|
//----------------------------------------
|
|
|
|
private:
|
|
|
|
typedef Eigen::Matrix<S,N,1> _Base;
|
2008-10-29 12:29:57 +01:00
|
|
|
public:
|
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
using _Base::coeff;
|
|
|
|
using _Base::coeffRef;
|
|
|
|
using _Base::setZero;
|
|
|
|
using _Base::data;
|
|
|
|
using _Base::V;
|
|
|
|
|
|
|
|
_EIGEN_GENERIC_PUBLIC_INTERFACE(Point,_Base);
|
|
|
|
VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Point)
|
2004-03-16 04:07:38 +01:00
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
inline Point() : Base() {}
|
|
|
|
template<typename OtherDerived>
|
2008-10-28 21:06:17 +01:00
|
|
|
inline Point(const Eigen::MatrixBase<OtherDerived>& other) : Base(other) {}
|
2004-04-05 14:35:33 +02:00
|
|
|
|
2004-03-16 04:07:38 +01:00
|
|
|
/// slower version, more stable (double precision only)
|
2008-10-28 21:06:17 +01:00
|
|
|
inline S StableDot (const Point& p) const;
|
2008-10-28 12:47:37 +01:00
|
|
|
|
2004-04-05 14:35:33 +02:00
|
|
|
/// Signed area operator
|
2008-10-28 21:06:17 +01:00
|
|
|
/// a % b returns the signed area of the parallelogram inside a and b
|
|
|
|
// inline S operator % ( PointType const & p ) const;
|
2004-04-05 14:35:33 +02:00
|
|
|
|
|
|
|
}; // end class definition
|
|
|
|
|
|
|
|
|
2008-10-28 21:06:17 +01:00
|
|
|
typedef Eigen::Matrix<short ,2,1> Point2s;
|
|
|
|
typedef Eigen::Matrix<int ,2,1> Point2i;
|
|
|
|
typedef Eigen::Matrix<float ,2,1> Point2f;
|
|
|
|
typedef Eigen::Matrix<double,2,1> Point2d;
|
|
|
|
typedef Eigen::Matrix<short ,2,1> Vector2s;
|
|
|
|
typedef Eigen::Matrix<int ,2,1> Vector2i;
|
|
|
|
typedef Eigen::Matrix<float ,2,1> Vector2f;
|
|
|
|
typedef Eigen::Matrix<double,2,1> Vector2d;
|
|
|
|
|
|
|
|
typedef Eigen::Matrix<short ,3,1> Point3s;
|
|
|
|
typedef Eigen::Matrix<int ,3,1> Point3i;
|
|
|
|
typedef Eigen::Matrix<float ,3,1> Point3f;
|
|
|
|
typedef Eigen::Matrix<double,3,1> Point3d;
|
|
|
|
typedef Eigen::Matrix<short ,3,1> Vector3s;
|
|
|
|
typedef Eigen::Matrix<int ,3,1> Vector3i;
|
|
|
|
typedef Eigen::Matrix<float ,3,1> Vector3f;
|
|
|
|
typedef Eigen::Matrix<double,3,1> Vector3d;
|
|
|
|
|
|
|
|
|
|
|
|
typedef Eigen::Matrix<short ,4,1> Point4s;
|
|
|
|
typedef Eigen::Matrix<int ,4,1> Point4i;
|
|
|
|
typedef Eigen::Matrix<float ,4,1> Point4f;
|
|
|
|
typedef Eigen::Matrix<double,4,1> Point4d;
|
|
|
|
typedef Eigen::Matrix<short ,4,1> Vector4s;
|
|
|
|
typedef Eigen::Matrix<int ,4,1> Vector4i;
|
|
|
|
typedef Eigen::Matrix<float ,4,1> Vector4f;
|
|
|
|
typedef Eigen::Matrix<double,4,1> Vector4d;
|
2008-10-28 12:47:37 +01:00
|
|
|
|
2004-04-05 14:35:33 +02:00
|
|
|
|
2004-03-16 04:07:38 +01:00
|
|
|
/*@}*/
|
|
|
|
|
2005-12-12 12:22:32 +01:00
|
|
|
} // end namespace ndim
|
|
|
|
} // end namespace vcg
|
2004-03-16 04:07:38 +01:00
|
|
|
#endif
|
|
|
|
|
2008-10-28 12:47:37 +01:00
|
|
|
#endif
|