minor bug
This commit is contained in:
parent
65c81124dd
commit
ee86220f5c
|
@ -1,29 +1,32 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* VCGLib o o *
|
* VCGLib o o *
|
||||||
* Visual and Computer Graphics Library o o *
|
* Visual and Computer Graphics Library o o *
|
||||||
* _ O _ *
|
* _ O _ *
|
||||||
* Copyright(C) 2004 \/)\/ *
|
* Copyright(C) 2004 \/)\/ *
|
||||||
* Visual Computing Lab /\/| *
|
* Visual Computing Lab /\/| *
|
||||||
* ISTI - Italian National Research Council | *
|
* ISTI - Italian National Research Council | *
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, *
|
* This program is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
* for more details. *
|
* for more details. *
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2004/05/05 08:21:55 cignoni
|
||||||
|
syntax errors in inersection plane line.
|
||||||
|
|
||||||
Revision 1.4 2004/05/04 02:37:58 ganovelli
|
Revision 1.4 2004/05/04 02:37:58 ganovelli
|
||||||
Triangle3<T> replaced by TRIANGLE
|
Triangle3<T> replaced by TRIANGLE
|
||||||
Segment<T> replaced by EDGETYPE
|
Segment<T> replaced by EDGETYPE
|
||||||
|
@ -62,12 +65,12 @@ Initial Commit
|
||||||
/**
|
/**
|
||||||
Function computing the intersection between couple of geometric primitives in
|
Function computing the intersection between couple of geometric primitives in
|
||||||
3 dimension
|
3 dimension
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
/// interseciton between sphere and line
|
/// interseciton between sphere and line
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Intersection( const Sphere3<T> & sp, const Line3<T> & li, Point3<T> & p0,Point3<T> & p1 ){
|
inline bool Intersection( const Sphere3<T> & sp, const Line3<T> & li, Point3<T> & p0,Point3<T> & p1 ){
|
||||||
|
|
||||||
// Per prima cosa si sposta il sistema di riferimento
|
// Per prima cosa si sposta il sistema di riferimento
|
||||||
// fino a portare il centro della sfera nell'origine
|
// fino a portare il centro della sfera nell'origine
|
||||||
|
@ -91,12 +94,12 @@ inline bool Intersection( const Sphere3<T> & sp, const Line3<T> & li, Point3<T>
|
||||||
|
|
||||||
p0=li.P(val0);
|
p0=li.P(val0);
|
||||||
p1=li.P(val1);
|
p1=li.P(val1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// intersection between line and plane
|
/// intersection between line and plane
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Intersection( const Plane3<T> & pl, const Line3<T> & li, Point3<T> & po){
|
inline bool Intersection( const Plane3<T> & pl, const Line3<T> & li, Point3<T> & po){
|
||||||
const T epsilon = T(1e-8);
|
const T epsilon = T(1e-8);
|
||||||
|
|
||||||
T k = pl.Direction() * li.Direction(); // Compute 'k' factor
|
T k = pl.Direction() * li.Direction(); // Compute 'k' factor
|
||||||
|
@ -107,9 +110,9 @@ inline bool Intersection( const Plane3<T> & pl, const Line3<T> & li, Point3<T> &
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// intersection between segment and plane
|
/// intersection between segment and plane
|
||||||
template<typename SEGMENTTYPE>
|
template<typename SEGMENTTYPE>
|
||||||
inline bool Intersection( const Plane3<typename SEGMENTTYPE::ScalarType> & pl,
|
inline bool Intersection( const Plane3<typename SEGMENTTYPE::ScalarType> & pl,
|
||||||
const SEGMENTTYPE & sg,
|
const SEGMENTTYPE & sg,
|
||||||
Point3<typename SEGMENTTYPE::ScalarType> & po){
|
Point3<typename SEGMENTTYPE::ScalarType> & po){
|
||||||
typedef typename SEGMENTTYPE::ScalarType T;
|
typedef typename SEGMENTTYPE::ScalarType T;
|
||||||
|
@ -125,10 +128,10 @@ inline bool Intersection( const Plane3<typename SEGMENTTYPE::ScalarType> & pl,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// intersection between plane and triangle
|
/// intersection between plane and triangle
|
||||||
// not optimal: uses plane-segment intersection (and the fact the two or none edges can be intersected)
|
// not optimal: uses plane-segment intersection (and the fact the two or none edges can be intersected)
|
||||||
template<typename TRIANGLETYPE>
|
template<typename TRIANGLETYPE>
|
||||||
inline bool Intersection( const Plane3<typename TRIANGLETYPE::ScalarType> & pl,
|
inline bool Intersection( const Plane3<typename TRIANGLETYPE::ScalarType> & pl,
|
||||||
const TRIANGLETYPE & tr,
|
const TRIANGLETYPE & tr,
|
||||||
Segment3<typename TRIANGLETYPE::ScalarType> & sg){
|
Segment3<typename TRIANGLETYPE::ScalarType> & sg){
|
||||||
typedef typename TRIANGLETYPE::ScalarType T;
|
typedef typename TRIANGLETYPE::ScalarType T;
|
||||||
|
@ -151,30 +154,30 @@ inline bool Intersection( const Plane3<typename TRIANGLETYPE::ScalarType> & pl,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// intersection between two triangles
|
/// intersection between two triangles
|
||||||
template<typename TRIANGLETYPE>
|
template<typename TRIANGLETYPE>
|
||||||
inline bool Intersection( const TRIANGLETYPE & t0,const TRIANGLETYPE & t1){
|
inline bool Intersection(const TRIANGLETYPE & t0,const TRIANGLETYPE & t1){
|
||||||
return NoDivTriTriIsect(t0.P0(0),t0.P0(1),t0.P0(2),
|
return NoDivTriTriIsect(t0.P0(0),t0.P0(1),t0.P0(2),
|
||||||
t1.P0(0),t1.P0(1),t1.P0(2));
|
t1.P0(0),t1.P0(1),t1.P0(2));
|
||||||
}
|
}
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Intersection( Point3<T> V0,Point3<T> V1,Point3<T> V2,
|
inline bool Intersection(Point3<T> V0,Point3<T> V1,Point3<T> V2,
|
||||||
Point3<T> U0,Point3<T> U1,Point3<T> U2){
|
Point3<T> U0,Point3<T> U1,Point3<T> U2){
|
||||||
return NoDivTriTriIsect(V0,V1,V2,U0,U1,U2);
|
return NoDivTriTriIsect(V0,V1,V2,U0,U1,U2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool Intersection( Point3<T> V0,Point3<T> V1,Point3<T> V2,
|
inline bool Intersection(Point3<T> V0,Point3<T> V1,Point3<T> V2,
|
||||||
Point3<T> U0,Point3<T> U1,Point3<T> U2,int *coplanar,
|
Point3<T> U0,Point3<T> U1,Point3<T> U2,int *coplanar,
|
||||||
Point3<T> &isectpt1,Point3<T> &isectpt2){
|
Point3<T> &isectpt1,Point3<T> &isectpt2){
|
||||||
|
|
||||||
return tri_tri_intersect_with_isectline(V0,V1,V2,U0,U1,U2,
|
return tri_tri_intersect_with_isectline(V0,V1,V2,U0,U1,U2,
|
||||||
coplanar,isectpt1,isectpt2);
|
coplanar,isectpt1,isectpt2);
|
||||||
}
|
}
|
||||||
template<typename TRIANGLETYPE,typename SEGMENTTYPE >
|
template<typename TRIANGLETYPE,typename SEGMENTTYPE >
|
||||||
inline bool Intersection( const TRIANGLETYPE & t0,const TRIANGLETYPE & t1,bool &coplanar,
|
inline bool Intersection(const TRIANGLETYPE & t0,const TRIANGLETYPE & t1,bool &coplanar,
|
||||||
SEGMENTTYPE & sg){
|
SEGMENTTYPE & sg){
|
||||||
Point3<T> ip0,ip1;
|
Point3<SEGMENTTYPE::PointType> ip0,ip1;
|
||||||
return tri_tri_intersect_with_isectline(t0.P0(0),t0.P0(1),t0.P0(2),
|
return tri_tri_intersect_with_isectline(t0.P0(0),t0.P0(1),t0.P0(2),
|
||||||
t1.P0(0),t1.P0(1),t1.P0(2),
|
t1.P0(0),t1.P0(1),t1.P0(2),
|
||||||
coplanar,sg.P0(),sg.P1()
|
coplanar,sg.P0(),sg.P1()
|
||||||
|
|
Loading…
Reference in New Issue