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 "eulerops.h"
00048 #include "shpshape.h"
00049 #include "vectorop.h"
00050 #include "mancommd.h"
00051
00052 void MSD_execNameAffine(void)
00053 {
00054 int i, ip, ap, bp;
00055 char name1[15];
00056 float a11, a12, a13, a21, a22, a23, a31, a32, a33, xc, yc, zc;
00057
00058 for (ip = 0; ip == 0;)
00059 {
00060 bp = sscanf(restbuf, "%s %f %f %f", name1, &xc, &yc, &zc);
00061 if (bp == 4)
00062 {
00063 for (i = 0; i < 3; ++i)
00064 {
00065 if (!lineins("? "))
00066 {
00067 return;
00068 }
00069 if (i == 0)
00070 {
00071 ap = sscanf(restbuf, "%f %f %f", &a11, &a12, &a13);
00072 }
00073 if (i == 1)
00074 {
00075 ap = sscanf(restbuf, "%f %f %f", &a21, &a22, &a23);
00076 }
00077 if (i == 2)
00078 {
00079 ap = sscanf(restbuf, "%f %f %f", &a31, &a32, &a33);
00080 }
00081 if (ap != 3)
00082 {
00083 break;
00084 }
00085 }
00086 }
00087 if ((bp == 4) && (ap == 3))
00088 {
00089 ip = 1;
00090 }
00091 if ((bp != 4) || (ap != 3))
00092 {
00093 printf("Objeto Centro de Transf.\nMatriz de Transf.\n");
00094 if (!lineins("? "))
00095 {
00096 return;
00097 }
00098 }
00099 }
00100 MSD_highNameAffine(name1, a11, a12, a13, a21, a22, a23, a31, a32, a33, xc, yc, zc);
00101 }
00102
00103 int MSD_highNameAffine(char *name, real a11, real a12, real a13, \
00104 real a21, real a22, real a23, \
00105 real a31, real a32, real a33, \
00106 real xc, real yc, real zc)
00107 {
00108 int sn;
00109
00110 if ((sn = MSD_getSolidIdFromName(name)) == -1)
00111 {
00112 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_AffineSolid, name);
00113 return(ERROR);
00114 }
00115 return(MSD_highAffine(sn, a11, a12, a13, a21, a22, a23, a31, a32,
00116 a33, xc, yc, zc));
00117 }
00118
00119 #ifdef __Extended_Version
00120 void MSD_execAffine(void)
00121 {
00122 int sn, i, ip, ap, bp;
00123 float a11, a12, a13, a21, a22, a23, a31, a32, a33, xc, yc, zc;
00124
00125 for (ip = 0; ip == 0;)
00126 {
00127 bp = sscanf(restbuf, "%d %f %f %f", &sn, &xc, &yc, &zc);
00128 if (bp == 4)
00129 {
00130 for (i = 0; i < 3; ++i)
00131 {
00132 if (!lineins("? "))
00133 {
00134 return;
00135 }
00136 if (i == 0)
00137 {
00138 ap = sscanf(restbuf, "%f %f %f", &a11, &a12, &a13);
00139 }
00140 if (i == 1)
00141 {
00142 ap = sscanf(restbuf, "%f %f %f", &a21, &a22, &a23);
00143 }
00144 if (i == 2)
00145 {
00146 ap = sscanf(restbuf, "%f %f %f", &a31, &a32, &a33);
00147 }
00148 if (ap != 3)
00149 {
00150 break;
00151 }
00152 }
00153 }
00154 if ((bp == 4) && (ap == 3))
00155 {
00156 ip = 1;
00157 }
00158 if ((bp != 4) || (ap != 3))
00159 {
00160 printf("Objeto Centro de Transf.\nMatriz de Transf.\n");
00161 if (!lineins("? "))
00162 {
00163 return;
00164 }
00165 }
00166 }
00167 MSD_highAffine(sn, a11, a12, a13, a21, a22, a23, a31, a32, a33, xc, yc, zc);
00168 }
00169
00170 #endif
00171
00172 int MSD_highAffine(Id sn, real a11, real a12, real a13, \
00173 real a21, real a22, real a23, \
00174 real a31, real a32, real a33, \
00175 real xc, real yc, real zc)
00176 {
00177 SPTYPE s;
00178 matrix mat;
00179 vector vec;
00180
00181 if ((s = MSD_getSolid(sn)) == SNIL)
00182 {
00183 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_AffineSolid, sn);
00184 return(ERROR);
00185 }
00186 matident(mat);
00187 mat[0][0] = a11;
00188 mat[0][1] = a12;
00189 mat[0][2] = a13;
00190 mat[1][0] = a21;
00191 mat[1][1] = a22;
00192 mat[1][2] = a23;
00193 mat[2][0] = a31;
00194 mat[2][1] = a32;
00195 mat[2][2] = a33;
00196 makevec(vec, xc, yc, zc, 1.0);
00197 CommandCount++;
00198 return(MSD_lowAffine(s, vec, mat));
00199 }
00200
00201 int MSD_lowAffine(SPTYPE sptr, vector center, matrix mat)
00202 {
00203 matrix m;
00204
00205 matident(m);
00206 mattrans(m, -center[0], -center[1], -center[2]);
00207 matmult(m, m, mat);
00208 mattrans(m, center[0], center[1], center[2]);
00209 MSD_lowTransformation(sptr, m);
00210 return(SUCCESS);
00211 }