~esys-p-dev/esys-particle/trunk

« back to all changes in this revision

Viewing changes to Geometry/Triangle.cpp

  • Committer: Steffen Abe
  • Date: 2019-12-03 14:39:10 UTC
  • Revision ID: s.abe@igem-energie.de-20191203143910-0s4xguvluq2jva3z
- added rotateMeshBy() function to rotate whole meshes around a given axis

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
  m_p0+=d;
232
232
}
233
233
 
 
234
/*!
 
235
        rotate the whole triangle around an axis
 
236
 
 
237
    \param origin a point on the axis
 
238
    \param axis the orientation of the rotation axis
 
239
    \param angle the rotation angle
 
240
*/
 
241
void Triangle::rotate(const Vec3& origin, const Vec3& axis, double angle)
 
242
{
 
243
    // get positions of corners 1 & 2
 
244
    Vec3 c1=m_p0+m_p1;
 
245
    Vec3 c2=m_p0+m_p2;
 
246
    // rotate points
 
247
    m_p0.rotateBy(origin,axis,angle);
 
248
    c1.rotateBy(origin,axis,angle);
 
249
    c2.rotateBy(origin,axis,angle);
 
250
    // reconstruct edge vectors
 
251
    m_p1=c1-m_p0;
 
252
    m_p2=c2-m_p0;
 
253
    // recalculate normal and invtrans
 
254
    try{
 
255
        m_normal=cross(m_p2,m_p1).unit_s();
 
256
        m_trans=Matrix3(m_p1,m_p2,m_normal);
 
257
        m_invtrans=m_trans.inv();
 
258
    }
 
259
    catch(VecErr V){ // if unit_s thows exception -> v1||v2
 
260
        throw TriangleError();
 
261
    }
 
262
}
234
263
 
235
264
 
236
265
/*!