COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
calc_transform.cpp File Reference
#include "math/mathlib.h"
Include dependency graph for calc_transform.cpp:

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
35 {
36  rvector sourcea = {1., 0., 0.};
37  rvector sourceb = {0., 1., 0.};
38  rvector targeta;
39  rvector targetb;
40 
41  switch (argc)
42  {
43  case 13:
44  // sourcea, sourceb, targeta, targetb
45  {
46  for (uint16_t i=0; i<3; ++i)
47  {
48  sourcea.col[i] = atof(argv[i+1]);
49  sourceb.col[i] = atof(argv[i+4]);
50  targeta.col[i] = atof(argv[i+7]);
51  targetb.col[i] = atof(argv[i+10]);
52  }
53  }
54  break;
55  case 7:
56  // targetx, targety
57  {
58  for (uint16_t i=0; i<3; ++i)
59  {
60  targeta.col[i] = atof(argv[i+1]);
61  targetb.col[i] = atof(argv[i+4]);
62  }
63  }
64  break;
65  default:
66  {
67  printf("Usage: calc_transform sourcea_x sourcea_y sourcea_z sourceb_x sourceb_y sourceb_z targeta_x targeta_y targeta_z targetb_x targetb_y targetb_z\n");
68  printf("Usage: calc_transform targetx_x targetx_y targetx_z targety_x targety_y targety_z\n");
69  exit(1);
70  }
71  break;
72  }
73 
74  quaternion tq = q_irotate_for(sourcea, sourceb, targeta, targetb);
75 
76  printf("%f [ %f, %f, %f ]\n", tq.w, tq.d.x, tq.d.y, tq.d.z);
77 }
double y
Y value.
Definition: vector.h:114
3 element generic row vector
Definition: vector.h:53
int i
Definition: rw_test.cpp:37
cvector d
Orientation.
Definition: vector.h:405
Quaternion, scalar last, using x, y, z.
Definition: vector.h:402
double x
X value.
Definition: vector.h:112
quaternion q_irotate_for(rvector sourcea, rvector sourceb, rvector targeta, rvector targetb)
Create irotate quaternion from two orthogonal vectors.
Definition: mathlib.cpp:154
double w
Rotation.
Definition: vector.h:407
double z
Z value.
Definition: vector.h:116
double col[3]
Definition: vector.h:55