v[2] /= d;
}
+ private float ballPosition[] = new float[5 * 2 * 3];
+ private PolychoronVertex[] drawEdge = new PolychoronVertex[2];
+ float[] tempVec = new float[3];
+ float[] axisA = new float[3];
+ float[] axisB = new float[3];
+
@Override
// ここで描画
public void onDrawFrame(GL10 gl) {
obj.sort();
// 辺
for (int i = 0; i < obj.getEdgeNum() / 2; i++) {
- PolychoronVertex[] e = obj.getEdge(i);
- float[] b1 = e[0].v3;
- float[] b2 = e[1].v3;
- float v[] = { b1[0] - b2[0], b1[1] - b2[1], b1[2] - b2[2] };
- normalize(v);
+ obj.getEdge(drawEdge, i);
+ float[] b1 = drawEdge[0].v3;
+ float[] b2 = drawEdge[1].v3;
+ tempVec[0] = b1[0] - b2[0];
+ tempVec[1] = b1[1] - b2[1];
+ tempVec[2] = b1[2] - b2[2];
+ normalize(tempVec);
//
- float[] a = { -v[1], v[0], 0 };
- if (-v[1] == 0 && v[0] == 0) {
- a[1] = -v[2];
- a[2] = v[1];
+ axisA[0] = -tempVec[1];
+ axisA[1] = tempVec[0];
+ axisA[2] = 0;
+ if (-tempVec[1] == 0 && tempVec[0] == 0) {
+ axisA[1] = -tempVec[2];
+ axisA[2] = tempVec[1];
}
- normalize(a);
- float[] b = { a[1] * v[2] - a[2] * v[1], a[2] * v[0] - a[0] * v[2],
- a[0] * v[1] - a[1] * v[0] };
+ normalize(axisA);
+ axisB[0] = axisA[1] * tempVec[2] - axisA[2] * tempVec[1];
+ axisB[1] = axisA[2] * tempVec[0] - axisA[0] * tempVec[2];
+ axisB[2] = axisA[0] * tempVec[1] - axisA[1] * tempVec[0];
for (int k = 0; k < 3; k++) {
- a[k] *= 0.05;
- b[k] *= 0.05;
+ axisA[k] *= 0.05;
+ axisB[k] *= 0.05;
}
- float ballPosition[] = new float[5 * 2 * 3];
for (int j = 0; j < ballPosition.length / 2 / 3; j++) {
ballPosition[j * 6 + 0] = (float) (b1[0]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[0] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[0] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[0] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[0] * edgeR);
ballPosition[j * 6 + 1] = (float) (b1[1]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[1] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[1] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[1] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[1] * edgeR);
ballPosition[j * 6 + 2] = (float) (b1[2]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[2] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[2] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[2] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[2] * edgeR);
ballPosition[j * 6 + 3] = (float) (b2[0]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[0] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[0] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[0] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[0] * edgeR);
ballPosition[j * 6 + 4] = (float) (b2[1]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[1] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[1] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[1] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[1] * edgeR);
ballPosition[j * 6 + 5] = (float) (b2[2]
- + Math.cos(j * 3.14 * 2 / 4.0) * a[2] * edgeR + Math
- .sin(j * 3.14 * 2 / 4.0) * b[2] * edgeR);
+ + Math.cos(j * 3.14 * 2 / 4.0) * axisA[2] * edgeR + Math
+ .sin(j * 3.14 * 2 / 4.0) * axisB[2] * edgeR);
}
// 位置指定
- lineBuffer = makeFloatBuffer(ballPosition);
- lineBuffer.position(0);
+ setFloatBuffer(lineBuffer, ballPosition);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, lineTexture);
// 頂点
for (int i = 0; i < obj.getVertexNum(); i++) {
// 位置指定
- elPositionBuffer = makeFloatBuffer(elPosition);
+ setFloatBuffer(elPositionBuffer, elPosition);
// 画像の指定
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, vTexture);
GLES20.glVertexAttribPointer(aPositionIndex, 3, GLES20.GL_FLOAT,
false, 0, elPositionBuffer);
//
- modelMatrix = obj.cloneMatrix3d(i);
+ obj.copyMatrix3d(modelMatrix, i);
GLES20.glUniformMatrix4fv(viewMatrixIndex, 1, false, viewMatrix, 0);
GLES20.glUniformMatrix4fv(projMatrixIndex, 1, false, projMatrix, 0);
GLES20.glUniformMatrix4fv(modelMatrixIndex, 1, false, modelMatrix,
modelMatrixIndex = GLES20.glGetUniformLocation(program, "u_MatModel");
//
GLES20.glUseProgram(program); // 作ったプログラムを使う
+ //
+ lineBuffer = makeFloatBuffer(ballPosition);
+ elPositionBuffer = makeFloatBuffer(elPosition);
}
// フロートの配列からフロートバッファを返す
return fb;
}
+ private void setFloatBuffer(FloatBuffer fb, float[] fArray) {
+ fb.position(0);
+ fb.put(fArray).position(0);
+ return;
+ }
+
// リソースIDから bitmap を GL に登録して テクスチャID を返す
private int makeTexture(int resId) {
Resources r = resouce;// view.getResources();
}
+ float[] temp = new float[16];
+ float[] rot = new float[16];
// スクロール動作で3次元物体を回転させる
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float d = (float) Math.sqrt(distanceX * distanceX + distanceY
* distanceY);
- float[] f = new float[16];
- Matrix.setRotateM(f, 0, d / 10, -distanceY, -distanceX, 0);
- Matrix.multiplyMM(rm, 0, f, 0, rm, 0);
+ Matrix.setRotateM(temp, 0, d / 10, -distanceY, -distanceX, 0);
+ Matrix.multiplyMM(rm, 0, temp, 0, rm, 0);
obj.transpose3(rm);
return true;
}
public boolean onDoubleTap(MotionEvent e) {
switch (mode) {
case STOP:
- obj.transpose4u(PolychoronVertex.rotateUX(0.05f));
+ PolychoronVertex.rotateUX(rot,0.05f);
+ obj.transpose4u(rot);
mode = ModeD4.XU;
case XU:
- obj.transpose4u(PolychoronVertex.rotateUY(0.05f));
+ PolychoronVertex.rotateUY(rot,0.05f);
+ obj.transpose4u(rot);
mode = ModeD4.YU;
break;
case YU:
- obj.transpose4u(PolychoronVertex.rotateUZ(0.05f));
+ PolychoronVertex.rotateUZ(rot,0.05f);
+ obj.transpose4u(rot);
mode = ModeD4.ZU;
break;
case ZU:
mode = ModeD4.STOP;
break;
}
+ obj.transpose4u(rot);
return false;
}
void init() {
vertexList = new PolychoronVertex[vertex.length / 4];
+ float[] initMat=new float[16];
for (int i = 0; i < vertex.length / 4; i++) {
vertexList[i] = new PolychoronVertex();
float[] v = { vertex[i * 4], vertex[i * 4 + 1], vertex[i * 4 + 2],
vertex[i * 4 + 3] };
vertexList[i].v4 = v.clone();
- vertexList[i].setConvert1(PolychoronVertex.rotateUZ(0.5f));
+ PolychoronVertex.rotateUZ(initMat,0.5f);
+ vertexList[i].setConvert1(initMat);
vertexList[i].convert1();
}
}
PolychoronVertex[] e = { edges[i * 2], edges[i * 2 + 1] };
return e;
}
-
+ protected PolychoronVertex[] getEdge(PolychoronVertex[] e,int i) {
+ e[0]=edges[i * 2];
+ e[1]=edges[i * 2 + 1];
+ return e;
+ }
protected float[] getVetex() {
return vertex;
}
-
- void sort() {
- Arrays.sort(vertexList, new Comparator<PolychoronVertex>() {
+ private Comparator<PolychoronVertex> comp= new Comparator<PolychoronVertex>() {
public int compare(PolychoronVertex o1, PolychoronVertex o2) {
float[] n1 = o1.v3;
float[] n2 = o2.v3;
return n1[2] < n2[2] ? -1 : 1;
}
- });
+ };
+ void sort() {
+ Arrays.sort(vertexList,comp);
}
PolychoronVertex getVetex(int i) {
vertexList[i].v3[2]);
return m;
}
+ public float[] copyMatrix3d(float[] m,int i) {
+ Matrix.setIdentityM(m, 0);
+ Matrix.translateM(m, 0, vertexList[i].v3[0], vertexList[i].v3[1],
+ vertexList[i].v3[2]);
+ return m;
+ }
}
Matrix.multiplyMV(v3, 0, m2, 0, v3, 0);
}
- public static float[] rotateUX(float u) {
- float[] m = { (float) Math.cos(u), 0, 0, (float) -Math.sin(u), 0, 1, 0,
- 0, 0, 0, 1, 0, (float) Math.sin(u), 0, 0, (float) Math.cos(u) };
+
+ public static float[] rotateUX(float[] m,float u) {
+ Matrix.setIdentityM(m, 0);
+ m[0]=(float) Math.cos(u);
+ m[3]=(float) -Math.sin(u);
+ m[12]=(float) Math.sin(u);
+ m[15]=(float) Math.cos(u);
return m;
}
- public static float[] rotateUY(float u) {
- float[] m = { 1, 0, 0, 0, 0, (float) Math.cos(u), 0,
- (float) -Math.sin(u), 0, 0, 1, 0, 0, (float) Math.sin(u), 0,
- (float) Math.cos(u) };
+ public static float[] rotateUY(float[] m,float u) {
+ Matrix.setIdentityM(m, 0);
+ m[5]=(float) Math.cos(u);
+ m[7]=(float) -Math.sin(u);
+ m[13]=(float) Math.sin(u);
+ m[15]=(float) Math.cos(u);
return m;
}
- public static float[] rotateUZ(float u) {
- float[] m = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, (float) Math.cos(u),
- (float) -Math.sin(u), 0, 0, (float) Math.sin(u),
- (float) Math.cos(u) };
+ public static float[] rotateUZ(float[] m,float u) {
+ Matrix.setIdentityM(m, 0);
+ m[10]=(float) Math.cos(u);
+ m[11]=(float) -Math.sin(u);
+ m[14]=(float) Math.sin(u);
+ m[15]=(float) Math.cos(u);
return m;
}
}
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
<resources>
- <integer-array name="answers">
- <item>0</item>
- <item>0</item>
- <item>0</item>
- <item>1</item>
- <item>1</item>
- </integer-array>
- <string-array name="questions">
- <item>1\n
- adad\n\n\nああああ</item>
- <item>2\n
- adsad\n\n\nああああ</item>
- <item>3\n
- adsad\n\n\nああああ</item>
- <item>4\n
- あー\n
- だるいにゃん</item>
- <item>5\n\n\n\nああああ
- </item>
- <item>6\n
- </item>
- </string-array>
- <array name="choices">
- <item >@array/q1</item>
- <item >@array/q2</item>
- <item >@array/q3</item>
- <item >@array/q4</item>
- <item >@array/q5</item>
- </array>
- <string-array name="q1">
- <item>foo1</item>
- <item>bar1</item>
- <item>baz1</item>
- </string-array>
- <string-array name="q2">
- <item>foo2</item>
- <item>bar2</item>
- <item>baz2</item>
- </string-array>
- <string-array name="q3">
- <item>foo3</item>
- <item>bar3</item>
- <item>baz3</item>
- </string-array>
- <string-array name="q4">
- <item>foo4</item>
- <item>bar4</item>
- <item>baz4</item>
- <item>foo4</item>
- <item>bar4</item>
- <item>baz4</item>
- </string-array>
- <string-array name="q5">
- <item>foo5</item>
- <item>bar5</item>
- <item>baz5</item>
-
- </string-array>
-</resources>
\ No newline at end of file
+ <integer-array name='answers'>
+ <item>
+ 0
+ </item>
+ <item>
+ 1
+ </item>
+ <item>
+ 3
+ </item>
+ <item>
+ 0
+ </item>
+ <item>
+ 2
+ </item>
+ </integer-array>
+ <string-array name='questions'>
+ <item>
+ ガロア体GF(2)において、素多項式がx^2+x+1の時、x・xはいくつになるか。\n
+ </item>
+ <item>
+ パリティ検査行列が以下の行列で表されているとする。\n1 1 1 0 0 0\n1 0 0 1 1 0\n1 1 0 1 0 1\nこの時、シンドロームが(100)だった場合、受信後の何ビット目に誤りが含まれるか。\n
+ </item>
+ <item>
+ 次の線形符号のうち、巡回符号でないのはどれか。\n
+ </item>
+ <item>
+ RS符号の情報記号数kはどのように求められるか。ただし、nを符号長、dを最小距離とする。\n
+ </item>
+ <item>
+ BCH符号、RS符号、ハミング符号を古い順に並べた時正しいのはどれか。\n
+ </item>
+ </string-array>
+ <array name='choices'>
+ <item>
+ @array/q0
+ </item>
+ <item>
+ @array/q1
+ </item>
+ <item>
+ @array/q2
+ </item>
+ <item>
+ @array/q3
+ </item>
+ <item>
+ @array/q4
+ </item>
+ </array>
+ <string-array name='q0'>
+ <item>
+ x+1
+ </item>
+ <item>
+ x
+ </item>
+ <item>
+ 1
+ </item>
+ <item>
+ 0
+ </item>
+ </string-array>
+ <string-array name='q1'>
+ <item>
+ 1
+ </item>
+ <item>
+ 3
+ </item>
+ <item>
+ 5
+ </item>
+ <item>
+ 誤りなし
+ </item>
+ </string-array>
+ <string-array name='q2'>
+ <item>
+ {(00),(11)}
+ </item>
+ <item>
+ {(000),(111)}
+ </item>
+ <item>
+ {(000),(010),(101),(111)}
+ </item>
+ <item>
+ {(000),(001),(010),(100)(111)}
+ </item>
+ </string-array>
+ <string-array name='q3'>
+ <item>
+ k=n−d+1
+ </item>
+ <item>
+ k=n+d+1
+ </item>
+ <item>
+ k=n+d−1
+ </item>
+ <item>
+ k=n−d−1
+ </item>
+ </string-array>
+ <string-array name='q4'>
+ <item>
+ BCH符号、ハミング符号、RS符号
+ </item>
+ <item>
+ RS符号、BCH符号、ハミング符号
+ </item>
+ <item>
+ ハミング符号、BCH符号、RS符号
+ </item>
+ <item>
+ ハミング符号、RS符号、BCH符号
+ </item>
+ </string-array>
+</resources>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
<resources>
- <string name="app_name">Q and A</string>
- <string name="first">質問の答えをそれぞれ一つ選んでねっ</string>
-</resources>
\ No newline at end of file
+ <string name='app_name'>
+ Q and A
+ </string>
+ <string name='first'>
+ 符号理論Q&A(2)
+ </string>
+</resources>