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][30] = {"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 case invalid:
00095 break;
00096 }
00097 return "invalid";
00098 }
00099
00100 void initCof(){
00101 int i,j;
00102 for (i = 0; i < NUM_MATERIAL; i++)
00103 for (j = 0; j < NUM_MATERIAL; j++) {
00104 Cof[i][j] = 0.0;
00105 KineticCof[i][j] = 0.0;
00106 }
00107
00108
00109
00110
00111
00112 KineticCof[metal][metal] = 0.1;
00113
00114
00115 KineticCof[wood][wood] = 0.3;
00116
00117
00118 KineticCof[wood][metal] = KineticCof[metal][wood] = 0.2;
00119
00120
00121 KineticCof[plastic][plastic] = 0.2;
00122
00123
00124 KineticCof[plastic][metal] = KineticCof[metal][plastic] = 0.1;
00125
00126
00127 KineticCof[plastic][wood] = KineticCof[wood][plastic] = 0.3;
00128
00129
00130 KineticCof[rubber][rubber] = 1.9;
00131 KineticCof[rubber][metal] = KineticCof[metal][rubber] = 0.9;
00132 KineticCof[rubber][wood] = KineticCof[wood][rubber] = 0.9;
00133 KineticCof[rubber][plastic] = KineticCof[plastic][rubber] = 0.9;
00134
00135
00136 KineticCof[glass][glass] = 0.1;
00137 KineticCof[glass][metal] = KineticCof[metal][glass] = 0.1;
00138 KineticCof[glass][wood] = KineticCof[wood][glass] = 0.2;
00139 KineticCof[glass][plastic] = KineticCof[plastic][glass] = 0.1;
00140 KineticCof[glass][rubber] = KineticCof[rubber][glass] = 0.9;
00141
00142
00143 KineticCof[stone][stone] = 0.6;
00144 KineticCof[stone][glass] = KineticCof[glass][stone] = 0.3;
00145 KineticCof[stone][metal] = KineticCof[metal][stone] = 0.3;
00146 KineticCof[stone][wood] = KineticCof[wood][stone] = 0.5;
00147 KineticCof[stone][plastic] = KineticCof[plastic][glass] = 0.5;
00148 KineticCof[glass][rubber] = KineticCof[rubber][glass] = 1.4;
00149
00150
00151 Cof[metal][metal] = 0.2;
00152
00153
00154 Cof[wood][wood] = 0.4;
00155
00156
00157 Cof[wood][metal] = Cof[metal][wood] = 0.3;
00158
00159
00160 Cof[plastic][plastic] = 0.3;
00161
00162
00163 Cof[plastic][metal] = Cof[metal][plastic] = 0.2;
00164
00165
00166 Cof[plastic][wood] = Cof[wood][plastic] = 0.4;
00167
00168
00169 Cof[rubber][rubber] = 2.0;
00170 Cof[rubber][metal] = Cof[metal][rubber] = 1.0;
00171 Cof[rubber][wood] = Cof[wood][rubber] = 1.0;
00172 Cof[rubber][plastic] = Cof[plastic][rubber] = 1.0;
00173
00174
00175 Cof[glass][glass] = 0.2;
00176 Cof[glass][metal] = Cof[metal][glass] = 0.2;
00177 Cof[glass][wood] = Cof[wood][glass] = 0.3;
00178 Cof[glass][plastic] = Cof[plastic][glass] = 0.2;
00179 Cof[glass][rubber] = Cof[rubber][glass] = 1.0;
00180
00181
00182 Cof[stone][stone] = 0.7;
00183 Cof[stone][glass] = Cof[glass][stone] = 0.4;
00184 Cof[stone][metal] = Cof[metal][stone] = 0.4;
00185 Cof[stone][wood] = Cof[wood][stone] = 0.6;
00186 Cof[stone][plastic] = Cof[plastic][stone] = 0.6;
00187 Cof[stone][rubber] = Cof[rubber][stone] = 1.5;
00188
00189 }
00190
00191