1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19      subroutine rotationvectorinv(c,v)
20!
21!     calculates rotation matrix from rotation vector
22!
23      implicit none
24!
25      real*8 c(3,3),v(3),theta,ds,dc
26!
27!
28!
29      theta=dsqrt(v(1)*v(1)+v(2)*v(2)+v(3)*v(3))
30!
31      if (theta.eq.0.d0) then
32            c(1,1)=1.d0
33            c(1,2)=0.d0
34            c(1,3)=0.d0
35            c(2,1)=0.d0
36            c(2,2)=1.d0
37            c(2,3)=0.d0
38            c(3,1)=0.d0
39            c(3,2)=0.d0
40            c(3,3)=1.d0
41      else
42!
43            dc=dcos(theta)
44            ds=dsin(theta)
45!
46!     C-matrix from Guido Dhondt, The Finite Element
47!     Method for Three-Dimensional Thermomechanical
48!     Applications p 158
49!
50            c(1,1)=dc+(1.d0-dc)*v(1)*v(1)/(theta*theta)
51            c(1,2)=   (1.d0-dc)*v(1)*v(2)/(theta*theta)-ds*v(3)/theta
52            c(1,3)=   (1.d0-dc)*v(1)*v(3)/(theta*theta)+ds*v(2)/theta
53            c(2,1)=   (1.d0-dc)*v(2)*v(1)/(theta*theta)+ds*v(3)/theta
54            c(2,2)=dc+(1.d0-dc)*v(2)*v(2)/(theta*theta)
55            c(2,3)=   (1.d0-dc)*v(2)*v(3)/(theta*theta)-ds*v(1)/theta
56            c(3,1)=   (1.d0-dc)*v(3)*v(1)/(theta*theta)-ds*v(2)/theta
57            c(3,2)=   (1.d0-dc)*v(3)*v(2)/(theta*theta)+ds*v(1)/theta
58            c(3,3)=dc+(1.d0-dc)*v(3)*v(3)/(theta*theta)
59      endif
60!
61      return
62!
63      end
64