SymmetricGroup3.java
com.mojang.math.SymmetricGroup3
信息
- 全限定名:com.mojang.math.SymmetricGroup3
- 类型:public enum
- 包:com.mojang.math
- 源码路径:src/main/java/com/mojang/math/SymmetricGroup3.java
- 起始行号:L11
- 职责:
TODO
字段/常量
-
P123, P213, P132, P312, P231, P321- 类型:
SymmetricGroup3 - 修饰符:
package-private - 源码定位:
L12 - 说明:
TODO
- 类型:
-
p0- 类型:
int - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
p1- 类型:
int - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
p2- 类型:
int - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
transformation- 类型:
Matrix3fc - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
CAYLEY_TABLE- 类型:
SymmetricGroup3[][] - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
INVERSE_TABLE- 类型:
SymmetricGroup3[] - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private SymmetricGroup3(int p0, int p1, int p2) @ L44
- 构造器名:SymmetricGroup3
- 源码定位:L44
- 修饰符:private
参数:
- p0: int
- p1: int
- p2: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public SymmetricGroup3 compose(SymmetricGroup3 that) @ L51
- 方法名:compose
- 源码定位:L51
- 返回类型:SymmetricGroup3
- 修饰符:public
参数:
- that: SymmetricGroup3
说明:
TODO
public SymmetricGroup3 inverse() @ L55
- 方法名:inverse
- 源码定位:L55
- 返回类型:SymmetricGroup3
- 修饰符:public
参数:
- 无
说明:
TODO
public int permute(int i) @ L59
- 方法名:permute
- 源码定位:L59
- 返回类型:int
- 修饰符:public
参数:
- i: int
说明:
TODO
public Direction.Axis permuteAxis(Direction.Axis axis) @ L68
- 方法名:permuteAxis
- 源码定位:L68
- 返回类型:Direction.Axis
- 修饰符:public
参数:
- axis: Direction.Axis
说明:
TODO
public Vector3f permuteVector(Vector3f v) @ L72
- 方法名:permuteVector
- 源码定位:L72
- 返回类型:Vector3f
- 修饰符:public
参数:
- v: Vector3f
说明:
TODO
public Vector3i permuteVector(Vector3i v) @ L79
- 方法名:permuteVector
- 源码定位:L79
- 返回类型:Vector3i
- 修饰符:public
参数:
- v: Vector3i
说明:
TODO
public Matrix3fc transformation() @ L86
- 方法名:transformation
- 源码定位:L86
- 返回类型:Matrix3fc
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public enum SymmetricGroup3 {
P123(0, 1, 2),
P213(1, 0, 2),
P132(0, 2, 1),
P312(2, 0, 1),
P231(1, 2, 0),
P321(2, 1, 0);
private final int p0;
private final int p1;
private final int p2;
private final Matrix3fc transformation;
private static final SymmetricGroup3[][] CAYLEY_TABLE = Util.make(() -> {
SymmetricGroup3[] values = values();
SymmetricGroup3[][] table = new SymmetricGroup3[values.length][values.length];
for (SymmetricGroup3 first : values) {
for (SymmetricGroup3 second : values) {
int p0 = first.permute(second.p0);
int p1 = first.permute(second.p1);
int p2 = first.permute(second.p2);
SymmetricGroup3 result = Arrays.stream(values).filter(p -> p.p0 == p0 && p.p1 == p1 && p.p2 == p2).findFirst().get();
table[first.ordinal()][second.ordinal()] = result;
}
}
return table;
});
private static final SymmetricGroup3[] INVERSE_TABLE = Util.make(() -> {
SymmetricGroup3[] values = values();
return Arrays.stream(values).map(f -> Arrays.stream(values()).filter(s -> f.compose(s) == P123).findAny().get()).toArray(SymmetricGroup3[]::new);
});
private SymmetricGroup3(int p0, int p1, int p2) {
this.p0 = p0;
this.p1 = p1;
this.p2 = p2;
this.transformation = new Matrix3f().zero().set(this.permute(0), 0, 1.0F).set(this.permute(1), 1, 1.0F).set(this.permute(2), 2, 1.0F);
}
public SymmetricGroup3 compose(SymmetricGroup3 that) {
return CAYLEY_TABLE[this.ordinal()][that.ordinal()];
}
public SymmetricGroup3 inverse() {
return INVERSE_TABLE[this.ordinal()];
}
public int permute(int i) {
return switch (i) {
case 0 -> this.p0;
case 1 -> this.p1;
case 2 -> this.p2;
default -> throw new IllegalArgumentException("Must be 0, 1 or 2, but got " + i);
};
}
public Direction.Axis permuteAxis(Direction.Axis axis) {
return Direction.Axis.VALUES[this.permute(axis.ordinal())];
}
public Vector3f permuteVector(Vector3f v) {
float v0 = v.get(this.p0);
float v1 = v.get(this.p1);
float v2 = v.get(this.p2);
return v.set(v0, v1, v2);
}
public Vector3i permuteVector(Vector3i v) {
int v0 = v.get(this.p0);
int v1 = v.get(this.p1);
int v2 = v.get(this.p2);
return v.set(v0, v1, v2);
}
public Matrix3fc transformation() {
return this.transformation;
}
}