61 #ifndef OPENMESH_GEOMETRY_QUADRIC_HH 62 #define OPENMESH_GEOMETRY_QUADRIC_HH 68 #include <OpenMesh/Core/Geometry/VectorT.hh> 69 #include <OpenMesh/Core/Utils/GenProg.hh> 86 template <
class Scalar>
90 typedef Scalar value_type;
99 QuadricT(Scalar _a, Scalar _b, Scalar _c, Scalar _d,
100 Scalar _e, Scalar _f, Scalar _g,
101 Scalar _h, Scalar _i,
103 : a_(_a), b_(_b), c_(_c), d_(_d),
104 e_(_e), f_(_f), g_(_g),
112 QuadricT( Scalar _a=0.0, Scalar _b=0.0, Scalar _c=0.0, Scalar _d=0.0 )
113 : a_(_a*_a), b_(_a*_b), c_(_a*_c), d_(_a*_d),
114 e_(_b*_b), f_(_b*_c), g_(_b*_d),
115 h_(_c*_c), i_(_c*_d),
119 template <
class _Po
int>
122 set_distance_to_point(_pt);
125 template <
class _Normal,
class _Po
int>
126 QuadricT(
const _Normal& _n,
const _Point& _p)
128 set_distance_to_plane(_n,_p);
132 void set(Scalar _a, Scalar _b, Scalar _c, Scalar _d,
133 Scalar _e, Scalar _f, Scalar _g,
134 Scalar _h, Scalar _i,
137 a_ = _a; b_ = _b; c_ = _c; d_ = _d;
138 e_ = _e; f_ = _f; g_ = _g;
144 template <
class _Po
int>
145 void set_distance_to_point(
const _Point& _pt)
147 set(1, 0, 0, -_pt[0],
154 void set_distance_to_plane(Scalar _a, Scalar _b, Scalar _c, Scalar _d)
156 a_ = _a*_a; b_ = _a*_b; c_ = _a*_c; d_ = _a*_d;
157 e_ = _b*_b; f_ = _b*_c; g_ = _b*_d;
158 h_ = _c*_c; i_ = _c*_d;
164 template <
class _Normal,
class _Po
int>
165 void set_distance_to_plane(
const _Normal& _n,
const _Point& _p)
167 set_distance_to_plane(_n[0], _n[1], _n[2], -
dot(_n,_p));
171 void clear() { a_ = b_ = c_ = d_ = e_ = f_ = g_ = h_ = i_ = j_ = 0.0; }
176 a_ += _q.a_; b_ += _q.b_; c_ += _q.c_; d_ += _q.d_;
177 e_ += _q.e_; f_ += _q.f_; g_ += _q.g_;
178 h_ += _q.h_; i_ += _q.i_;
186 return result += _other;
193 a_ *= _s; b_ *= _s; c_ *= _s; d_ *= _s;
194 e_ *= _s; f_ *= _s; g_ *= _s;
207 template <
class _Vec4>
210 Scalar x(_v[0]), y(_v[1]), z(_v[2]), w(_v[3]);
211 return _Vec4(x*a_ + y*b_ + z*c_ + w*d_,
212 x*b_ + y*e_ + z*f_ + w*g_,
213 x*c_ + y*f_ + z*h_ + w*i_,
214 x*d_ + y*g_ + z*i_ + w*j_);
218 template <
class _Vec>
224 Scalar a()
const {
return a_; }
225 Scalar b()
const {
return b_; }
226 Scalar c()
const {
return c_; }
227 Scalar d()
const {
return d_; }
228 Scalar e()
const {
return e_; }
229 Scalar f()
const {
return f_; }
230 Scalar g()
const {
return g_; }
231 Scalar h()
const {
return h_; }
232 Scalar i()
const {
return i_; }
233 Scalar j()
const {
return j_; }
235 Scalar xx()
const {
return a_; }
236 Scalar xy()
const {
return b_; }
237 Scalar xz()
const {
return c_; }
238 Scalar xw()
const {
return d_; }
239 Scalar yy()
const {
return e_; }
240 Scalar yz()
const {
return f_; }
241 Scalar yw()
const {
return g_; }
242 Scalar zz()
const {
return h_; }
243 Scalar zw()
const {
return i_; }
244 Scalar ww()
const {
return j_; }
249 template <
class _Vec3>
250 Scalar
evaluate(
const _Vec3& _v, GenProg::Int2Type<3>)
const 252 Scalar x(_v[0]), y(_v[1]), z(_v[2]);
253 return a_*x*x + 2.0*b_*x*y + 2.0*c_*x*z + 2.0*d_*x
254 + e_*y*y + 2.0*f_*y*z + 2.0*g_*y
260 template <
class _Vec4>
261 Scalar
evaluate(
const _Vec4& _v, GenProg::Int2Type<4>)
const 263 Scalar x(_v[0]), y(_v[1]), z(_v[2]), w(_v[3]);
264 return a_*x*x + 2.0*b_*x*y + 2.0*c_*x*z + 2.0*d_*x*w
265 + e_*y*y + 2.0*f_*y*z + 2.0*g_*y*w
266 + h_*z*z + 2.0*i_*z*w
272 Scalar a_, b_, c_, d_,
290 #endif // OPENMESH_GEOMETRY_HH defined Scalar evaluate(const _Vec3 &_v, GenProg::Int2Type< 3 >) const
evaluate quadric Q at 3D vector v: v*Q*v
Definition: QuadricT.hh:250
Scalar operator()(const _Vec &_v) const
evaluate quadric Q at (3D or 4D) vector v: v*Q*v
Definition: QuadricT.hh:219
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
QuadricT< Scalar > & operator+=(const QuadricT< Scalar > &_q)
add quadrics
Definition: QuadricT.hh:174
QuadricT< Scalar > & operator*=(Scalar _s)
multiply by scalar
Definition: QuadricT.hh:191
QuadricT(Scalar _a=0.0, Scalar _b=0.0, Scalar _c=0.0, Scalar _d=0.0)
constructor from given plane equation: ax+by+cz+d_=0
Definition: QuadricT.hh:112
osg::Vec3f::ValueType dot(const osg::Vec3f &_v1, const osg::Vec3f &_v2)
Adapter for osg vector member computing a scalar product.
Definition: VectorAdapter.hh:181
_Vec4 operator*(const _Vec4 &_v) const
multiply 4D vector from right: Q*v
Definition: QuadricT.hh:208
/class QuadricT Geometry/QuadricT.hh
Definition: QuadricT.hh:87
void clear()
set all entries to zero
Definition: QuadricT.hh:171
Helper class providing information about a vector type.
Definition: vector_traits.hh:93
QuadricT(Scalar _a, Scalar _b, Scalar _c, Scalar _d, Scalar _e, Scalar _f, Scalar _g, Scalar _h, Scalar _i, Scalar _j)
construct with upper triangle of symmetrix 4x4 matrix
Definition: QuadricT.hh:99
Scalar evaluate(const _Vec4 &_v, GenProg::Int2Type< 4 >) const
evaluate quadric Q at 4D vector v: v*Q*v
Definition: QuadricT.hh:261