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 #include <stdio.h>
00027 #include <string.h>
00028
00029 #include "material.h"
00030
00031 double Cof[NUM_MATERIAL][NUM_MATERIAL];
00032 double KineticCof[NUM_MATERIAL][NUM_MATERIAL];
00033 char *matNameList[NUM_MATERIAL] = {"frictionless","glass","metal","wood",
00034 "plastic","rubber","stone","invalid"};
00035
00036 materialT readMaterial(const char *matStr)
00037 {
00038 if (!strcmp(matStr,"frictionless")) return(frictionless);
00039 if (!strcmp(matStr,"glass")) return(glass);
00040 if (!strcmp(matStr,"metal")) return(metal);
00041 if (!strcmp(matStr,"wood")) return(wood);
00042 if (!strcmp(matStr,"plastic")) return(plastic);
00043 if (!strcmp(matStr,"rubber")) return(rubber);
00044 if (!strcmp(matStr,"stone")) return(stone);
00045 return(invalid);
00046 }
00047
00048 void getMaterialStr(materialT mat,char *str){
00049 switch (mat) {
00050 case frictionless:
00051 strcpy(str,"frictionless");
00052 break;
00053 case glass:
00054 strcpy(str,"glass");
00055 break;
00056 case metal:
00057 strcpy(str,"metal");
00058 break;
00059 case wood:
00060 strcpy(str,"wood");
00061 break;
00062 case plastic:
00063 strcpy(str,"plastic");
00064 break;
00065 case rubber:
00066 strcpy(str,"rubber");
00067 break;
00068 case stone:
00069 strcpy(str,"stone");
00070 break;
00071 case invalid:
00072 strcpy(str,"invalid");
00073 break;
00074 }
00075 }
00076
00077 const char *
00078 getMaterialStr(materialT mat){
00079 switch (mat) {
00080 case frictionless:
00081 return "frictionless";
00082 case glass:
00083 return "glass";
00084 case metal:
00085 return "metal";
00086 case wood:
00087 return "wood";
00088 case plastic:
00089 return "plastic";
00090 case rubber:
00091 return "rubber";
00092 case stone:
00093 return "stone";
00094 }
00095 return "invalid";
00096 }
00097
00098 void initCof(){
00099 int i,j;
00100 for (i = 0; i < NUM_MATERIAL; i++)
00101 for (j = 0; j < NUM_MATERIAL; j++) {
00102 Cof[i][j] = 0.0;
00103 KineticCof[i][j] = 0.0;
00104 }
00105
00106
00107
00108
00109
00110 KineticCof[metal][metal] = 0.1;
00111
00112
00113 KineticCof[wood][wood] = 0.3;
00114
00115
00116 KineticCof[wood][metal] = KineticCof[metal][wood] = 0.2;
00117
00118
00119 KineticCof[plastic][plastic] = 0.2;
00120
00121
00122 KineticCof[plastic][metal] = KineticCof[metal][plastic] = 0.1;
00123
00124
00125 KineticCof[plastic][wood] = KineticCof[wood][plastic] = 0.3;
00126
00127
00128 KineticCof[rubber][rubber] = 1.9;
00129 KineticCof[rubber][metal] = KineticCof[metal][rubber] = 0.9;
00130 KineticCof[rubber][wood] = KineticCof[wood][rubber] = 0.9;
00131 KineticCof[rubber][plastic] = KineticCof[plastic][rubber] = 0.9;
00132
00133
00134 KineticCof[glass][glass] = 0.1;
00135 KineticCof[glass][metal] = KineticCof[metal][glass] = 0.1;
00136 KineticCof[glass][wood] = KineticCof[wood][glass] = 0.2;
00137 KineticCof[glass][plastic] = KineticCof[plastic][glass] = 0.1;
00138 KineticCof[glass][rubber] = KineticCof[rubber][glass] = 0.9;
00139
00140
00141 KineticCof[stone][stone] = 0.6;
00142 KineticCof[stone][glass] = KineticCof[glass][stone] = 0.3;
00143 KineticCof[stone][metal] = KineticCof[metal][stone] = 0.3;
00144 KineticCof[stone][wood] = KineticCof[wood][stone] = 0.5;
00145 KineticCof[stone][plastic] = KineticCof[plastic][glass] = 0.5;
00146 KineticCof[glass][rubber] = KineticCof[rubber][glass] = 1.4;
00147
00148
00149 Cof[metal][metal] = 0.2;
00150
00151
00152 Cof[wood][wood] = 0.4;
00153
00154
00155 Cof[wood][metal] = Cof[metal][wood] = 0.3;
00156
00157
00158 Cof[plastic][plastic] = 0.3;
00159
00160
00161 Cof[plastic][metal] = Cof[metal][plastic] = 0.2;
00162
00163
00164 Cof[plastic][wood] = Cof[wood][plastic] = 0.4;
00165
00166
00167 Cof[rubber][rubber] = 2.0;
00168 Cof[rubber][metal] = Cof[metal][rubber] = 1.0;
00169 Cof[rubber][wood] = Cof[wood][rubber] = 1.0;
00170 Cof[rubber][plastic] = Cof[plastic][rubber] = 1.0;
00171
00172
00173 Cof[glass][glass] = 0.2;
00174 Cof[glass][metal] = Cof[metal][glass] = 0.2;
00175 Cof[glass][wood] = Cof[wood][glass] = 0.3;
00176 Cof[glass][plastic] = Cof[plastic][glass] = 0.2;
00177 Cof[glass][rubber] = Cof[rubber][glass] = 1.0;
00178
00179
00180 Cof[stone][stone] = 0.7;
00181 Cof[stone][glass] = Cof[glass][stone] = 0.4;
00182 Cof[stone][metal] = Cof[metal][stone] = 0.4;
00183 Cof[stone][wood] = Cof[wood][stone] = 0.6;
00184 Cof[stone][plastic] = Cof[plastic][stone] = 0.6;
00185 Cof[stone][rubber] = Cof[rubber][stone] = 1.5;
00186
00187 }
00188
00189