00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include "mensagem.h"
00043 #include "memvirtu.h"
00044 #include "lowparam.h"
00045 #include "lowmacro.h"
00046 #include "lowsolid.h"
00047 #include "genfunc_.h"
00048 #include "eulerops.h"
00049 #include "shpshape.h"
00050 #include "vectorop.h"
00051 #include "mancommd.h"
00052
00053 #ifdef __Extended_Version
00054 void MSD_execNameRotateSolidAxis(void)
00055 {
00056 char name[30];
00057 float th, x1, y1, z1, x2, y2, z2;
00058
00059 if (8 != sscanf(restbuf, "%s %f %f %f %f %f %f %f", name,
00060 &x1, &y1, &z1, &x2, &y2, &z2, &th))
00061 {
00062 printf("Solido Pto_axis Vector Angulo\n");
00063 if (!lineins("? "))
00064 {
00065 return;
00066 }
00067 }
00068 MSD_highNameRotateSolidAxis(name, x1, y1, z1, x2, y2, z2, th);
00069 }
00070
00071 #endif
00072
00073 int MSD_highNameRotateSolidAxis(char *name, real x1, real y1, real z1, \
00074 real x2, real y2, real z2, \
00075 real th)
00076 {
00077 int sn;
00078
00079 if ((sn = MSD_getSolidIdFromName(name)) == -1)
00080 {
00081 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_RotateSolidAxis, name);
00082 return(ERROR);
00083 }
00084 return(MSD_highRotateSolidAxis(sn, x1, y1, z1, x2, y2, z2, th));
00085 }
00086
00087 #ifdef __Extended_Version
00088 void MSD_execRotateSolidAxis(void)
00089 {
00090 float th, x1, y1, z1, x2, y2, z2;
00091 int sn;
00092
00093 if (8 != sscanf(restbuf, "%d %f %f %f %f %f %f %f", &sn,
00094 &x1, &y1, &z1, &x2, &y2, &z2, &th))
00095 {
00096 printf("Solido Pto_axis Vector Angulo\n");
00097 if (!lineins("? "))
00098 {
00099 return;
00100 }
00101 }
00102 MSD_highRotateSolidAxis(sn, x1, y1, z1, x2, y2, z2, th);
00103 }
00104
00105 #endif
00106
00107 int MSD_highRotateSolidAxis(Id sn, real x1, real y1, real z1, \
00108 real x2, real y2, real z2, real th)
00109 {
00110 SPTYPE sptr;
00111 vector center, vec;
00112
00113 if ((sptr = MSD_getSolid(sn)) == SNIL)
00114 {
00115 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_RotateSolidAxis, sn);
00116 return(ERROR);
00117 }
00118 makevec(center, x1, y1, z1, 1.0);
00119 makevec(vec, x2, y2, z2, 1.0);
00120 normalize(vec);
00121 CommandCount++;
00122 return(MSD_lowRotateSolidAxis(sptr, center, vec, th));
00123 }
00124
00125 int MSD_lowRotateSolidAxis(SPTYPE sptr, vector center, vector axis, real th)
00126 {
00127 matrix rot;
00128
00129 MSD_lowTranslate(sptr, -center[0], -center[1], -center[2]);
00130 matident(rot);
00131 rotmat(axis, th * 3.141592 / 180.0, rot);
00132 MSD_lowTransformation(sptr, rot);
00133 MSD_lowTranslate(sptr, center[0], center[1], center[2]);
00134 return(SUCCESS);
00135 }