demitervip
demitervip
关注数: 19
粉丝数: 2
发帖数: 243
关注贴吧数: 5
哪位高手说下魔方这个程序怎么计算哒? 求求啦~
有哪位前辈子帮我解释下!(我在实习周啊,不会做实例急啊) import java.awt.*;import java.applet.Applet;public final class rubik extends Applet{ int i; int j; int k; int n; int o; int p; int q; int lastX; int lastY; int dx; int dy; int rectX[]; int rectY[]; Color colList[]; Color bgcolor; final double sideVec[] = { 0.0, 0.0, 1.0, 0.0, 0.0, -1, 0.0, -1, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1, 0.0, 0.0 }; final double corners[] = { -1, -1, -1, 1.0, -1, -1, 1.0, 1.0, -1, -1, 1.0, -1, -1, -1, 1.0, 1.0, -1, 1.0, 1.0, 1.0, 1.0, -1, 1.0, 1.0 }; double topCorners[]; double botCorners[]; final int sides[] = { 4, 5, 6, 7, 3, 2, 1, 0, 0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6, 0, 4, 7, 3 }; final int nextSide[] = { 2, 3, 4, 5, 4, 3, 2, 5, 1, 3, 0, 5, 1, 4, 0, 2, 1, 5, 0, 3, 2, 0, 4, 1 }; final int mainBlocks[] = { 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3 }; final int twistDir[] = { -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1 }; final int colDir[] = { -1, -1, 1, -1, 1, -1 }; final int circleOrder[] = { 0, 1, 2, 5, 8, 7, 6, 3 }; int topBlocks[]; int botBlocks[]; int sideCols[]; int sideW; int sideH; int dragReg; int twistSide; int nearSide[]; int buffer[];
有哪位前辈子帮我解释下!(我在实习周啊,不会做实例急啊) 都不会啊~代码在网上找的代码请帮忙解释下老师问的时候讲给老师听哒`import java.awt.*;import java.applet.Applet;public final class rubik extends Applet{ int i; int j; int k; int n; int o; int p; int q; int lastX; int lastY; int dx; int dy; int rectX[]; int rectY[]; Color colList[]; Color bgcolor; final double sideVec[] = { 0.0, 0.0, 1.0, 0.0, 0.0, -1, 0.0, -1, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1, 0.0, 0.0 }; final double corners[] = { -1, -1, -1, 1.0, -1, -1, 1.0, 1.0, -1, -1, 1.0, -1, -1, -1, 1.0, 1.0, -1, 1.0, 1.0, 1.0, 1.0, -1, 1.0, 1.0 }; double topCorners[]; double botCorners[]; final int sides[] = { 4, 5, 6, 7, 3, 2, 1, 0, 0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6, 0, 4, 7, 3 }; final int nextSide[] = { 2, 3, 4, 5, 4, 3, 2, 5, 1, 3, 0, 5, 1, 4, 0, 2, 1, 5, 0, 3, 2, 0, 4, 1 }; final int mainBlocks[] = { 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3 }; final int twistDir[] = { -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1 }; final int colDir[] = { -1, -1, 1, -1, 1, -1 }; final int circleOrder[] = { 0, 1, 2, 5, 8, 7, 6, 3 }; int topBlocks[]; int botBlocks[]; int sideCols[]; int sideW; int sideH; int dragReg; int twistSide; int nearSide[]; int buffer[]; double dragCorn[]; double dragDir[]; double eye[] = { 0.3651, 0.1826, -0.9129 }; double eX[] = { 0.9309, -0.0716, 0.3581 }; double eY[]; double Teye[]; double TeX[]; double TeY[]; double light[]; double temp[] = { 0.0, 0.0, 0.0 }; double temp2[] = { 0.0, 0.0, 0.0 }; double newCoord[]; double sx; double sy; double sdxh; double sdyh; double sdxv; double sdyv; double d; double t1; double t2; double t3; double t4; double t5; double t6; double phi; double phibase; double Cphi; double Sphi; double currDragDir[]; boolean naturalState; boolean twisting; boolean OKtoDrag;double local0; Math m; Graphics offGraphics; Image offImage; public void init() { offImage = createImage(120, 120); offGraphics = offImage.getGraphics(); rectX = new int[4]; rectY = new int[4]; newCoord = new double[16]; dragDir = new double[24]; dragCorn = new double[96]; topCorners = new double[24]; botCorners = new double[24]; topBlocks = new int[24]; botBlocks = new int[24]; buffer = new int[12]; nearSide = new int[12]; light = new double[3]; Teye = new double[3]; TeX = new double[3]; TeY = new double[3]; currDragDir = new double[2]; eY = new double[3]; vecProd(eye, 0, eX, 0, eY, 0); normalize(eY, 0); colList = new Color[120]; for (i = 0; i < 20; i++) { colList[i] = new Color(103 + i * 8, 103 + i * 8, 103 + i * 8);
1
下一页