Added DihedralAngleRad that computes the signed dihedral angle between the normals of two adjacent faces
This commit is contained in:
parent
49d759af2a
commit
9ad68bc573
|
|
@ -63,6 +63,56 @@ inline bool IsBorder(FaceType const & f, const int j )
|
|||
return true;
|
||||
}
|
||||
|
||||
/*! \brief Compute the signed dihedral angle between the normals of two adjacent faces
|
||||
*
|
||||
* The angle between the normal is signed according to the concavity/convexity of the
|
||||
* dihedral angle: negative if the edge shared between the two faces is concave, positive otherwise.
|
||||
* The surface it is assumend to be oriented.
|
||||
* It simply use the projection of the opposite vertex onto the plane of the other one.
|
||||
* It does not assume anything on face normals.
|
||||
*
|
||||
* v0 ___________ vf1
|
||||
* |\ |
|
||||
* | \i1 f1 |
|
||||
* | \ |
|
||||
* |f0 i0\ |
|
||||
* | \ |
|
||||
* |__________\|
|
||||
* vf0 v1
|
||||
*/
|
||||
|
||||
template <class FaceType>
|
||||
inline typename FaceType::ScalarType DihedralAngleRad(FaceType & f, const int i )
|
||||
{
|
||||
typedef typename FaceType::ScalarType ScalarType;
|
||||
typedef typename FaceType::CoordType CoordType;
|
||||
typedef typename FaceType::VertexType VertexType;
|
||||
|
||||
FaceType *f0 = &f;
|
||||
FaceType *f1 = f.FFp(i);
|
||||
int i0=i;
|
||||
int i1=f.FFi(i);
|
||||
VertexType *vf0 = f0->V2(i0);
|
||||
VertexType *vf1 = f1->V2(i1);
|
||||
|
||||
CoordType n0 = NormalizedNormal(*f0);
|
||||
CoordType n1 = NormalizedNormal(*f1);
|
||||
ScalarType off0 = n0*vf0->P();
|
||||
ScalarType off1 = n1*vf1->P();
|
||||
|
||||
ScalarType dist01 = off0 - n0*vf1->P();
|
||||
ScalarType dist10 = off1 - n1*vf0->P();
|
||||
|
||||
// just to be sure use the sign of the largest in absolute value;
|
||||
ScalarType sign;
|
||||
if(fabs(dist01) > fabs(dist10)) sign = dist01;
|
||||
else sign=dist10;
|
||||
|
||||
ScalarType angleRad=Angle(f0->N(),f1->N());
|
||||
|
||||
if(sign > 0 ) return angleRad;
|
||||
else return -angleRad;
|
||||
}
|
||||
|
||||
/// Count border edges of the face
|
||||
template <class FaceType>
|
||||
|
|
|
|||
Loading…
Reference in New Issue