MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
vec2rot.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/utils/vec2rot.cc,v 1.20 2017/01/12 15:10:28 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  *
10  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
11  * via La Masa, 34 - 20156 Milano, Italy
12  * http://www.aero.polimi.it
13  *
14  * Changing this copyright notice is forbidden.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation (version 2 of the License).
19  *
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
32 
33 #include <cstdlib>
34 #include <cstring>
35 #include <iostream>
36 
37 #include "matvec3.h"
38 
39 int
40 main(int argn, const char* const argv[])
41 {
42  if (argn > 1) {
43  if (!strcasecmp(argv[1], "-?")
44  || !strcasecmp(argv[1], "-h")
45  || !strcasecmp(argv[1], "--help")) {
46  std::cerr << std::endl
47  << "usage: " << argv[0] << std::endl
48  << std::endl
49  << " reads the Euler angles (in degs)"
50  " from stdin;" << std::endl
51  << " writes the rotation matrix"
52  " on standard output" << std::endl
53  << " (m11, m12, m13,"
54  " m21, m22, m23,"
55  " m31, m32, m33)" << std::endl
56  << std::endl
57  << "part of MBDyn package (Copyright (C)"
58  " Pierangelo Masarati, 1996-2004)" << std::endl
59  << std::endl;
60  exit(EXIT_SUCCESS);
61  }
62  }
63 
64  unsigned short int i1, i2;
65  static doublereal v1[3], v2[3];
66  while (true) {
67  std::cin >> i1;
68  if (std::cin) {
69  std::cin >> v1[0] >> v1[1] >> v1[2]
70  >> i2
71  >> v2[0] >> v2[1] >> v2[2];
72  std::cout << MatR2vec(i1, Vec3(v1), i2, Vec3(v2)) << std::endl;
73  } else {
74  break;
75  }
76  }
77 
78  return EXIT_SUCCESS;
79 }
80 
Mat3x3 MatR2vec(unsigned short int ia, const Vec3 &va, unsigned short int ib, const Vec3 &vb)
Definition: matvec3.cc:779
Definition: matvec3.h:98
int main(int argn, const char *const argv[])
Definition: vec2rot.cc:40
double doublereal
Definition: colamd.c:52