6 // Copyright (C) 2003 Jim Wilson - jimw@kelcomaine.com
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 int main( int argc, char **argv ) {
29 float x1,y1,z1,x2,y2,z2 = 0;
30 float center_x,center_y,center_z,axis_x,axis_y,axis_z;
34 printf("animassist - utility to calculate axis and center values for SimGear model animation\n\n");
35 printf("Usage: animassist x1 y1 z1 x2 y2 z2\n\n");
36 printf("Defining two vectors in SimGear coords (x1,y1,z1) and (x2,y2,z2)\n\n");
37 printf("Conversion from model to SimGear:\n");
38 printf("SimGear Coord AC3D Coordinate\n");
40 printf(" Y = Z * -1\n");
42 printf("Note: no normalization done, so please make the 2nd vector the furthest out\n");
56 vector_length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1));
58 /* arbitrary axis defined by cos(theta) where theta is angle from x,y or z axis */
59 axis_x = (x2-x1)/vector_length;
60 axis_y = (y2-y1)/vector_length;
61 axis_z = (z2-z1)/vector_length;
63 printf("Flightgear Model XML for:\n");
64 printf("Axis from (%f,%f,%f) to (%f,%f,%f)\n", x1,y1,z1,x2,y2,z2);
65 printf("Assuming units in meters!\n\n");
67 printf(" <x-m>%f</x-m>\n",center_x);
68 printf(" <y-m>%f</y-m>\n",center_y);
69 printf(" <z-m>%f</z-m>\n",center_z);
70 printf("</center>\n\n");
72 printf(" <x>%f</x>\n",axis_x);
73 printf(" <y>%f</y>\n",axis_y);
74 printf(" <z>%f</z>\n",axis_z);
75 printf("</axis>\n\n");