1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2023 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.bandaged;
|
11
|
|
12
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
13
|
|
14
|
public class BandagedElement
|
15
|
{
|
16
|
private final float[][] mCuts;
|
17
|
private final int[] mNumCuts;
|
18
|
private final float[][] mRotAxis;
|
19
|
private final int[] mRotationRow;
|
20
|
private final float[] mPos;
|
21
|
private final int mVariant;
|
22
|
|
23
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
24
|
|
25
|
BandagedElement(float[] pos, int index, float[][] rotAxis, float[][] cuts, int variant)
|
26
|
{
|
27
|
mPos = new float[] { pos[index], pos[index+1], pos[index+2] };
|
28
|
|
29
|
int numAxis = rotAxis.length;
|
30
|
mRotAxis = rotAxis;
|
31
|
mRotationRow = new int[numAxis];
|
32
|
mNumCuts = new int[numAxis];
|
33
|
mCuts = cuts;
|
34
|
mVariant = variant;
|
35
|
|
36
|
for(int i=0; i<numAxis; i++)
|
37
|
{
|
38
|
mNumCuts[i] = (mCuts==null || mCuts[i]==null ? 0 : mCuts[i].length);
|
39
|
mRotationRow[i] = computeRow(i);
|
40
|
}
|
41
|
}
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
private int computeRow(int rotAx)
|
46
|
{
|
47
|
float[] ax = mRotAxis[rotAx];
|
48
|
float casted = mPos[0]*ax[0] + mPos[1]*ax[1] + mPos[2]*ax[2];
|
49
|
int num = mNumCuts[rotAx];
|
50
|
float[] cuts = mCuts[rotAx];
|
51
|
|
52
|
for(int i=0; i<num; i++)
|
53
|
if( casted<cuts[i] ) return i;
|
54
|
|
55
|
return num;
|
56
|
}
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
int[] getRotRow()
|
61
|
{
|
62
|
return mRotationRow;
|
63
|
}
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
float[] getPos()
|
68
|
{
|
69
|
return mPos;
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
int getVariant()
|
75
|
{
|
76
|
return mVariant;
|
77
|
}
|
78
|
}
|