Menu

[r124]: / trunk / include / small / dcovec3-function.hpp  Maximize  Restore  History

Download this file

49 lines (41 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//=============================================================================
/*! calculate vector product only for 3D vector */
inline dcovec3 operator/(const dcovec3& A, const dcovec3& B)
{
dcovec3 C;
C(0) =A(1)*B(2) -A(2)*B(1);
C(1) =A(2)*B(0) -A(0)*B(2);
C(2) =A(0)*B(1) -A(1)*B(0);
return C;
}
//=============================================================================
/*! calculate vector product only for 3D vector */
inline dcovec3 operator/=(dcovec3& A, const dcovec3& B)
{
A =A/B;
return A;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! */
inline dquater vr2q(const dcovec3& v, const double& r)
{
return dquater(v(0),v(1),v(2),r);
}
//=============================================================================
/*! */
inline dquater vt2q(const dcovec3& v, const double& theta)
{
return vr2q( v/(nrm2(v)+DBL_MIN)*std::sin(0.5*theta), std::cos(0.5*theta) );
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! */
inline dcovec3 rotate(const dcovec3& v, const dquater& q)
{
return imag( q*vr2q(v,0.)*conj(q) );
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.