本人根据参考文献中提供的代码想要复现牙齿摩擦的模型,但代码的最后一行提示错误,希望有大佬能够给我些指点,万分感谢。可有偿协助我完成模型复现。Processing程序提示最后一句有错误,error on parameter or method declaration near ‘lowerTooth.move)’? 下面是完整代码。
class Tooth {
PVector pos;
PVector move;
int[][] toothStructure;
final int YVALUE = 0;
final int DAMAGE = 1;
final int STRUCTURE_PRESET = 2;
final int max_DAMAGE = 70; // Use this consistently instead of MAX_DAMAGE
final boolean toothBodyVisualization = true;
final boolean SIMULATE_DENTINE = false; // Changed for consistency
final float[] structure = { 6.2, 8.8, 10.4, 13.2, 14.6, 15, 15.2, 14, 11.6,
11.8, 12.4, 13.6, 12.8, 11.6, 11, 9.2, 9, 9.2,
9.2, 9.2, 9, 8.6, 9.4, 9.2, 9, 8.8, 9, 8.4, 9, 8,
7.4, 6.4, 5.6, 5, 5.6, 5.8, 5.2, 4.2};
int toothWidth;
int heightMolar;
boolean maxilla;
int colorChannel;
Tooth(PVector pos, int toothWidth, int heightMolar, boolean maxilla) {
this.pos = pos;
this.toothWidth = toothWidth;
this.maxilla = maxilla;
this.heightMolar = heightMolar;
toothStructure = new int[toothWidth][3];
move = new PVector(0, 0);
for (int i = 0; i < toothWidth; i++) {
toothStructure[i][YVALUE] = 0;
toothStructure[i][DAMAGE] = 0 ;
if (SIMULATE_ENAMEL_DENTINE) {
toothStructure[i][STRUCTURE_PRESET] = int(structure[i*40/toothWidth]*MAX_DAMAGE/15.2);
} else {
toothStructure[i][STRUCTURE_PRESET] = MAX_DAMAGE;
}
}
}
void render() {
pushMatrix();
translate(width / 3 - 50, height * 2 / 3 - 275);
for (int i = 0; i < toothWidth; i++) {
colorChannel = 255 - 250 * toothStructure[i][DAMAGE] / max_DAMAGE;
int colorValue = toothStructure[i][STRUCTURE_PRESET] * 180 / MAX_DAMAGE;
stroke(colorValue, colorValue, 0);
if (maxilla) {
if (toothBodyVisualization) {
line(pos.x + i, pos.y, pos.x + i, pos.y + heightMolar - toothStructure[i][YVALUE]);
}
stroke(255 - colorChannel, colorChannel, 0);
line(pos.x + i, pos.y + heightMolar - toothStructure[i][YVALUE],
pos.x + i, pos.y + heightMolar - 2 - toothStructure[i][YVALUE]);
} else {
if (toothBodyVisualization) {
line(pos.x + i, pos.y + heightMolar, pos.x + i, pos.y + 2 + toothStructure[i][YVALUE]);
}
stroke(255 - colorChannel, colorChannel, 0);
line(pos.x + i, pos.y + 2 + toothStructure[i][YVALUE],
pos.x + i, pos.y + toothStructure[i][YVALUE]);
}
}
popMatrix();
}
}
final int POWERSTROKE = 1;
final int OPENINGSTROKE = 2;
final int CLOSINGSTROKE = 3;
final int INCISORTOUCH = 4;
int stroke = POWERSTROKE;
int startContactLine, endContactLine;
int neutral_position_x;
int i_Lower;
int delta_pos_x;
final int WIDTH_UPPER_MOLAR = 150;
final int WIDTH_LOWER_MOLAR = 100;
final int HEIGHT_MOLAR = 200;
int powerStrokeStartPoint = 0;
// int powerStrokeStartPoint = - int(WIDTH_LOWER_MOLAR/5.0);
final boolean SIMULATE_INCISOR_LANDING = true;
final float incisor_touch_StartPoint = 0.50;
final int stopAtRemaining = 30;
Tooth upperTooth, lowerTooth;
boolean in_touch;
int cycle;
void setup() {
size(300, 750);
initSimulation();
colorMode(RGB, 255);
}
void initSimulation() {
upperTooth = new Tooth(new PVector(0, 0), WIDTH_UPPER_MOLAR, HEIGHT_MOLAR, true);
lowerTooth = new Tooth(new PVector(0, HEIGHT_MOLAR), WIDTH_LOWER_MOLAR, HEIGHT_MOLAR, false);
neutral_position_x = upperTooth.toothWidth
- int(float(lowerTooth.toothWidth) * incisor_touch_StartPoint);
lowerTooth.move.x = 1;
lowerTooth.move.y = 0;
cycle = 1;
}
void textOutput() {
pushMatrix();
translate(20, 20);
textSize(16);
fill(60);
switch (stroke) {
case POWERSTROKE:
text("Power Stroke", 10, 30);
break;
case CLOSINGSTROKE:
text("Closing Stroke", 10, 30);
break;
case OPENINGSTROKE:
text("Opening Stroke", 10, 30);
break;
case INCISORTOUCH:
text("Incisors landed", 10, 30);
break;
}
text("cycle No.:", 10, 50);
text(cycle, 200, 50);
text("incisor landing:", 10, 70);
if(SIMULATE_INCISOR_LANDING){
text("yes",200, 70);
}
else{
text("no",200,70);
}
text("starting point:", 10, 90);
text(powerStrokeStartPoint, 200, 90);
text("max. damage", 10, 110);
text(lowerTooth.max_DAMAGE, 200, 110);
text("molar angle:", 10, 130);
text(degrees(atan(float(upperTooth.toothStructure[WIDTH_UPPER_MOLAR - 1][YVALUE]
- upperTooth.toothStructure[0][YVALUE]) / float(WIDTH_UPPER_MOLAR))), 200, 130);
text("enamel-dentine sim.", 10, 150);
if (upperTooth.SIMULATE_DENTINE){
text("yes", 200, 150);
}
else{
text("no", 200,150);
}
int toothRemaining = 100 - 100 * lowerTooth.toothStructure[0][0] / HEIGHT_MOLAR;
text("rem. tooth struct. (%):", 10, 170);
text(toothRemaining, 200, 170);
if (toothRemaining <= stopAtRemaining) {noLoop();}
if (SIMULATE_INCISOR_LANDING == true){
text("Incisor land. pos. (%):", 10, 190);
text(int(incisor_touch_StartPoint*100) , 200, 190);
}
popMatrix();
}
void draw(){
background(240);
noFill();
textOutput();
lowerTooth.render();
upperTooth.render();
if ((lowerTooth.pos.x > neutral_position_x) &&
((stroke == INCISORTOUCH) (SIMULATE_INCISOR_LANDING == false))) {
stroke = OPENINGSTROKE;
cycle++;
lowerTooth.move.x = -1;
lowerTooth.move.y = 1;
}
if ((lowerTooth.pos.x <= powerStrokeStartPoint) &&
(lowerTooth.pos.y > HEIGHT_MOLAR + 15 - upperTooth.toothStructure[1][YVALUE] - lowerTooth.toothStructure[1][YVALUE])) {
stroke = CLOSINGSTROKE;
lowerTooth.move.y = -1;
lowerTooth.move.x = 0;
}
if ((lowerTooth.pos.x <= powerStrokeStartPoint) &&
(lowerTooth.pos.y <= HEIGHT_MOLAR)) {
stroke = POWERSTROKE;
if ((cycle == 2) (cycle == 25) (cycle == 50)
(cycle == 75) (cycle == 100) (cycle == 200)) {
saveFrame(“sim” + cycle + “” + abs(powerStrokeStartPoint) +
“_” + SIMULATE_INCISOR_LANDING + “.png”);
}
}
if ((lowerTooth.pos.x > upperTooth.toothWidth * incisor_touch_StartPoint)
&&(stroke == POWERSTROKE) && SIMULATE_INCISOR_LANDING) {
stroke = INCISORTOUCH;
lowerTooth.move.x = 1;
lowerTooth.move.y = 0;
}
if (stroke == POWERSTROKE) {
lowerTooth.move.x = 1;
lowerTooth.move.y = 2;
in_touch = false;
startContactLine = max(int(upperTooth.pos.x), int(lowerTooth.pos.x));
endContactLine = min(int(lowerTooth.pos.x) + lowerTooth.toothWidth,
int(upperTooth.pos.x) + upperTooth.toothWidth);
delta_pos_x = int(upperTooth.pos.x) - int(lowerTooth.pos.x);
for (int i = startContactLine; i < endContactLine; i++) {
i_Lower = i + delta_pos_x;
if ((lowerTooth.pos.y - upperTooth.pos.y) <
(HEIGHT_MOLAR - upperTooth.toothStructure[i][YVALUE]
- lowerTooth.toothStructure[i_Lower][YVALUE])) {
in_touch = true;
if (upperTooth.toothStructure[i][DAMAGE]
< upperTooth.toothStructure[i][STRUCTURE_PRESET]) {
upperTooth.toothStructure[i][DAMAGE] += random(3);}
else {
upperTooth.toothStructure[i][YVALUE] += 1;
upperTooth.toothStructure[i][DAMAGE] = 0;
}
if (lowerTooth.toothStructure[i_Lower][DAMAGE]
< lowerTooth.toothStructure[i_Lower][STRUCTURE_PRESET]) {
lowerTooth.toothStructure[i_Lower][DAMAGE] += random(3);}
else {
lowerTooth.toothStructure[i_Lower][YVALUE] += 1;
lowerTooth.toothStructure[i_Lower][DAMAGE] = 0;
}
}
}
if (in_touch == false) {
lowerTooth.move.x = 0;
lowerTooth.move.y = -1;
}
}
}
lowerTooth.pos.add(lowerTooth.move);