MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
eu2phi.cc File Reference
#include "mbconfig.h"
#include <cstring>
#include <stdlib.h>
#include <string>
#include <iostream>
#include "matvec3.h"
#include "matvecexp.h"
#include "Rot.hh"
Include dependency graph for eu2phi.cc:

Go to the source code of this file.

Functions

int main (int argn, const char *const argv[])
 

Function Documentation

int main ( int  argn,
const char *const  argv[] 
)

Definition at line 46 of file eu2phi.cc.

References EulerAngles2MatR(), M_PI, Vec3::Norm(), R, and RotManip::VecRot().

47 {
48  bool v = false;
49  if (argn > 1) {
50  if (!strcasecmp(argv[1], "-?")
51  || !strcasecmp(argv[1], "-h")
52  || !strcasecmp(argv[1], "--help")) {
53  std::cerr << std::endl
54  << "usage: " << argv[0] << "[-v]" << std::endl
55  << std::endl
56  << " reads the Euler angles (in degs)"
57  " from stdin;" << std::endl
58  << " writes the rotation vector {magniture (in degs), direction} on standard output"
59  << std::endl
60  << " -v: write the rotation vector (in rads) instead of magnitude, direction"
61  << std::endl
62  << std::endl
63  << "part of MBDyn package (Copyright (C)"
64  " Pierangelo Masarati, 1996-2006)" << std::endl
65  << " Authors: Alessandro Fumagalli" << std::endl
66  << " Marco Morandini" << std::endl
67  << std::endl;
68  exit(EXIT_SUCCESS);
69  } else {
70  if (!strcasecmp(argv[1], "-v")) {
71  v = true;
72  }
73  }
74  }
75 
76  std::cout.precision(16);
77 
78  static doublereal d[3];
79  while (true) {
80  std::cin >> d[0];
81  if (std::cin) {
82  std::cin >> d[1] >> d[2];
83 
84  Mat3x3 R(EulerAngles2MatR(Vec3(d)/(180./M_PI)));
85  Vec3 phi(RotManip::VecRot(R));
86 
87  if (v) {
88  std::cout << phi << std::endl;
89  } else {
90  doublereal D = phi.Norm();
91  if (D != 0.) {
92  std::cout << D*180./M_PI << " " << phi/D << std::endl;
93  } else {
94  std::cout << 0. << " " << 0. << " " << 0. << " " << 0. << std::endl;
95  }
96  }
97  } else {
98  break;
99  }
100  }
101 
102  return EXIT_SUCCESS;
103 }
#define M_PI
Definition: gradienttest.cc:67
Definition: matvec3.h:98
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
Mat3x3 EulerAngles2MatR(const Vec3 &v)
Definition: matvec3.cc:1008
double doublereal
Definition: colamd.c:52
Mat3x3 R

Here is the call graph for this function: