/* Decompiled by Mocha from rubik.class */
/* Originally compiled from rubik.java */
import java.awt.*;
import java.applet.Applet;
public final synchronized 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.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0 };
final double corners[] = { -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 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[];
double eX[];
double eY[];
double Teye[];
double TeX[];
double TeY[];
double light[];
double temp[];
double temp2[];
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;
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);
colList[i + 20] = new Color(i * 6, i * 6, 84 + i * 9);
colList[i + 40] = new Color(84 + i * 9, i * 5, i * 5);
colList[i + 60] = new Color(i * 6, 84 + i * 9, i * 6);
colList[i + 80] = new Color(84 + i * 9, 84 + i * 9, i * 6);
colList[i + 100] = new Color(84 + i * 9, 55 + i * 8, i * 3);
}
sideCols = new int[54];
for (i = 0; i < 54; i++)
sideCols[i] = i / 9;
bgcolor = findBGColor();
resize(125, 125);
repaint();
}
public Color findBGColor()
{
Color color;
String string2 = "0123456789abcdef";
int an[] = new int[6];
String string1 = getParameter("bgcolor");
if (string1 != null && string1.length() == 6)
{
for (i = 0; i < 6; i++)
for (j = 0; j < 16; j++)
if (Character.toLowerCase(string1.charAt(i)) == string2.charAt(j))
an[i] = j;
color = new Color(an[0] * 16 + an[1], an[2] * 16 + an[3], an[4] * 16 + an[5]);
}
else
color = Color.lightGray;
return color;
}
public double scalProd(double ad1[], int i, double ad2[], int j)
{
return ad1[i] * ad2[j] + ad1[i + 1] * ad2[j + 1] + ad1[i + 2] * ad2[j + 2];
}
public double vNorm(double ad[], int i)
{
return Math.sqrt(ad[i] * ad[i] + ad[i + 1] * ad[i + 1] + ad[i + 2] * ad[i + 2]);
}
public double cosAng(double ad1[], int i, double ad2[], int j)
{
return scalProd(ad1, i, ad2, j) / (vNorm(ad1, i) * vNorm(ad2, j));
}
public void normalize(double ad[], int i)
{
local0 = vNorm(ad, i);
ad[i] = ad[i] / local0;
ad[i + 1] = ad[i + 1] / local0;
ad[i + 2] = ad[i + 2] / local0;
}
public void scalMult(double ad[], int i, double d)
{
ad[i] = ad[i] * d;
ad[i + 1] = ad[i + 1] * d;
ad[i + 2] = ad[i + 2] * d;
}
public void addVec(double ad1[], int i, double ad2[], int j)
{
ad2[j] += ad1[i];
ad2[j + 1] += ad1[i + 1];
ad2[j + 2] += ad1[i + 2];
}
public void subVec(double ad1[], int i, double ad2[], int j)
{
ad2[j] -= ad1[i];
ad2[j + 1] -= ad1[i + 1];
ad2[j + 2] -= ad1[i + 2];
}
public void copyVec(double ad1[], int i, double ad2[], int j)
{
ad2[j] = ad1[i];
ad2[j + 1] = ad1[i + 1];
ad2[j + 2] = ad1[i + 2];
}
public void vecProd(double ad1[], int i, double ad2[], int j, double ad3[], int k)
{
ad3[k] = ad1[i + 1] * ad2[j + 2] - ad1[i + 2] * ad2[j + 1];
ad3[k + 1] = ad1[i + 2] * ad2[j] - ad1[i] * ad2[j + 2];
ad3[k + 2] = ad1[i] * ad2[j + 1] - ad1[i + 1] * ad2[j];
}
public void cutUpCube()
{
for (i = 0; i < 24; i++)
{
topCorners[i] = corners[i];
botCorners[i] = corners[i];
}
copyVec(sideVec, 3 * twistSide, temp, 0);
copyVec(temp, 0, temp2, 0);
scalMult(temp, 0, 1.3333);
scalMult(temp2, 0, 0.6667);
for (i = 0; i < 8; i++)
{
boolean flag = false;
for (j = 0; j < 4; j++)
if (i == sides[twistSide * 4 + j])
flag = true;
if (flag)
subVec(temp2, 0, botCorners, i * 3);
else
addVec(temp, 0, topCorners, i * 3);
}
for (i = 0; i < 24; i++)
{
topBlocks[i] = mainBlocks[i];
botBlocks[i] = mainBlocks[i];
}
for (i = 0; i < 6; i++)
{
if (i == twistSide)
{
botBlocks[i * 4 + 1] = 0;
botBlocks[i * 4 + 3] = 0;
}
else
{
k = -1;
for (j = 0; j < 4; j++)
if (nextSide[i * 4 + j] == twistSide)
k = j;
switch (k)
{
case 0:
topBlocks[i * 4 + 3] = 1;
botBlocks[i * 4 + 2] = 1;
break;
case 1:
topBlocks[i * 4] = 2;
botBlocks[i * 4 + 1] = 2;
break;
case 2:
topBlocks[i * 4 + 2] = 2;
botBlocks[i * 4 + 3] = 2;
break;
case 3:
topBlocks[i * 4 + 1] = 1;
botBlocks[i * 4] = 1;
break;
case -1:
topBlocks[i * 4 + 1] = 0;
topBlocks[i * 4 + 3] = 0;
break;
}
storhnipeiineachieve.rar_电信计费
版权申诉
68 浏览量
2022-09-24
07:59:05
上传
评论
收藏 11KB RAR 举报
weixin_42653672
- 粉丝: 94
- 资源: 1万+
最新资源
- 使用ASP.NET Core和Entity Framework Core来构建一个基本的进销存系统.rar
- 深度学习经典数据集+FER2013面部表情识别+附带使用方法的python代码
- Python中,要实现连接多个相机并识别多个二维码.rar
- 使用FFT算法对一个信号进行分析.rar
- 171cms游戏应用下载系统源码.zip
- 基于jsp+servlet+mysql蛋糕甜品店购物网站源码+数据库(期末大作业).zip
- Java项目:在线蛋糕商城系统(java+jsp+mysql)源码+数据库+期末大作业.zip
- ZapyaClient10_7-1.apk
- 织梦cms站长导航网站源码.zip
- 基于SSM+MySQL的网络投票调查问卷系统源码+数据库(java期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈