OctahedralGroup.java
com.mojang.math.OctahedralGroup
信息
- 全限定名:com.mojang.math.OctahedralGroup
- 类型:public enum
- 包:com.mojang.math
- 源码路径:src/main/java/com/mojang/math/OctahedralGroup.java
- 起始行号:L15
- 实现:StringRepresentable
- 职责:
TODO
字段/常量
-
false, false, true, true, false, true, true, true, false, false, true, false, true, true, true, false, true, false, true, false, false, true, false, false, true, false, false, true, true, false, true, true, false, false, false, true, false, false, false, false, true, true, true, false, false, true, true, true- 类型:
IDENTITY(,SymmetricGroup3.P123,false,false, - 修饰符:
package-private - 源码定位:
L16 - 说明:
TODO
- 类型:
-
BLOCK_ROT_X_270- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L65 - 说明:
TODO
- 类型:
-
BLOCK_ROT_X_180- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L66 - 说明:
TODO
- 类型:
-
BLOCK_ROT_X_90- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L67 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Y_270- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L68 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Y_180- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L69 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Y_90- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L70 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Z_270- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L71 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Z_180- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L72 - 说明:
TODO
- 类型:
-
BLOCK_ROT_Z_90- 类型:
OctahedralGroup - 修饰符:
public static final - 源码定位:
L73 - 说明:
TODO
- 类型:
-
transformation- 类型:
Matrix3fc - 修饰符:
private final - 源码定位:
L74 - 说明:
TODO
- 类型:
-
name- 类型:
String - 修饰符:
private final - 源码定位:
L75 - 说明:
TODO
- 类型:
-
rotatedDirections- 类型:
Map<Direction,Direction> - 修饰符:
private - 源码定位:
L76 - 说明:
TODO
- 类型:
-
invertX- 类型:
boolean - 修饰符:
private final - 源码定位:
L77 - 说明:
TODO
- 类型:
-
invertY- 类型:
boolean - 修饰符:
private final - 源码定位:
L78 - 说明:
TODO
- 类型:
-
invertZ- 类型:
boolean - 修饰符:
private final - 源码定位:
L79 - 说明:
TODO
- 类型:
-
permutation- 类型:
SymmetricGroup3 - 修饰符:
private final - 源码定位:
L80 - 说明:
TODO
- 类型:
-
CAYLEY_TABLE- 类型:
OctahedralGroup[][] - 修饰符:
private static final - 源码定位:
L81 - 说明:
TODO
- 类型:
-
INVERSE_TABLE- 类型:
OctahedralGroup[] - 修饰符:
private static final - 源码定位:
L98 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private OctahedralGroup(String name, SymmetricGroup3 permutation, boolean invertX, boolean invertY, boolean invertZ) @ L102
- 构造器名:OctahedralGroup
- 源码定位:L102
- 修饰符:private
参数:
- name: String
- permutation: SymmetricGroup3
- invertX: boolean
- invertY: boolean
- invertZ: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static int trace(boolean invertX, boolean invertY, boolean invertZ, SymmetricGroup3 permutation) @ L111
- 方法名:trace
- 源码定位:L111
- 返回类型:int
- 修饰符:private static
参数:
- invertX: boolean
- invertY: boolean
- invertZ: boolean
- permutation: SymmetricGroup3
说明:
TODO
private int trace() @ L116
- 方法名:trace
- 源码定位:L116
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
public OctahedralGroup compose(OctahedralGroup that) @ L120
- 方法名:compose
- 源码定位:L120
- 返回类型:OctahedralGroup
- 修饰符:public
参数:
- that: OctahedralGroup
说明:
TODO
public OctahedralGroup inverse() @ L124
- 方法名:inverse
- 源码定位:L124
- 返回类型:OctahedralGroup
- 修饰符:public
参数:
- 无
说明:
TODO
public Matrix3fc transformation() @ L128
- 方法名:transformation
- 源码定位:L128
- 返回类型:Matrix3fc
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L132
- 方法名:toString
- 源码定位:L132
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public String getSerializedName() @ L137
- 方法名:getSerializedName
- 源码定位:L137
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public Direction rotate(Direction direction) @ L142
- 方法名:rotate
- 源码定位:L142
- 返回类型:Direction
- 修饰符:public
参数:
- direction: Direction
说明:
TODO
public Vector3i rotate(Vector3i v) @ L156
- 方法名:rotate
- 源码定位:L156
- 返回类型:Vector3i
- 修饰符:public
参数:
- v: Vector3i
说明:
TODO
public boolean inverts(Direction.Axis axis) @ L164
- 方法名:inverts
- 源码定位:L164
- 返回类型:boolean
- 修饰符:public
参数:
- axis: Direction.Axis
说明:
TODO
public SymmetricGroup3 permutation() @ L172
- 方法名:permutation
- 源码定位:L172
- 返回类型:SymmetricGroup3
- 修饰符:public
参数:
- 无
说明:
TODO
public FrontAndTop rotate(FrontAndTop input) @ L176
- 方法名:rotate
- 源码定位:L176
- 返回类型:FrontAndTop
- 修饰符:public
参数:
- input: FrontAndTop
说明:
TODO
代码
public enum OctahedralGroup implements StringRepresentable {
IDENTITY("identity", SymmetricGroup3.P123, false, false, false),
ROT_180_FACE_XY("rot_180_face_xy", SymmetricGroup3.P123, true, true, false),
ROT_180_FACE_XZ("rot_180_face_xz", SymmetricGroup3.P123, true, false, true),
ROT_180_FACE_YZ("rot_180_face_yz", SymmetricGroup3.P123, false, true, true),
ROT_120_NNN("rot_120_nnn", SymmetricGroup3.P231, false, false, false),
ROT_120_NNP("rot_120_nnp", SymmetricGroup3.P312, true, false, true),
ROT_120_NPN("rot_120_npn", SymmetricGroup3.P312, false, true, true),
ROT_120_NPP("rot_120_npp", SymmetricGroup3.P231, true, false, true),
ROT_120_PNN("rot_120_pnn", SymmetricGroup3.P312, true, true, false),
ROT_120_PNP("rot_120_pnp", SymmetricGroup3.P231, true, true, false),
ROT_120_PPN("rot_120_ppn", SymmetricGroup3.P231, false, true, true),
ROT_120_PPP("rot_120_ppp", SymmetricGroup3.P312, false, false, false),
ROT_180_EDGE_XY_NEG("rot_180_edge_xy_neg", SymmetricGroup3.P213, true, true, true),
ROT_180_EDGE_XY_POS("rot_180_edge_xy_pos", SymmetricGroup3.P213, false, false, true),
ROT_180_EDGE_XZ_NEG("rot_180_edge_xz_neg", SymmetricGroup3.P321, true, true, true),
ROT_180_EDGE_XZ_POS("rot_180_edge_xz_pos", SymmetricGroup3.P321, false, true, false),
ROT_180_EDGE_YZ_NEG("rot_180_edge_yz_neg", SymmetricGroup3.P132, true, true, true),
ROT_180_EDGE_YZ_POS("rot_180_edge_yz_pos", SymmetricGroup3.P132, true, false, false),
ROT_90_X_NEG("rot_90_x_neg", SymmetricGroup3.P132, false, false, true),
ROT_90_X_POS("rot_90_x_pos", SymmetricGroup3.P132, false, true, false),
ROT_90_Y_NEG("rot_90_y_neg", SymmetricGroup3.P321, true, false, false),
ROT_90_Y_POS("rot_90_y_pos", SymmetricGroup3.P321, false, false, true),
ROT_90_Z_NEG("rot_90_z_neg", SymmetricGroup3.P213, false, true, false),
ROT_90_Z_POS("rot_90_z_pos", SymmetricGroup3.P213, true, false, false),
INVERSION("inversion", SymmetricGroup3.P123, true, true, true),
INVERT_X("invert_x", SymmetricGroup3.P123, true, false, false),
INVERT_Y("invert_y", SymmetricGroup3.P123, false, true, false),
INVERT_Z("invert_z", SymmetricGroup3.P123, false, false, true),
ROT_60_REF_NNN("rot_60_ref_nnn", SymmetricGroup3.P312, true, true, true),
ROT_60_REF_NNP("rot_60_ref_nnp", SymmetricGroup3.P231, true, false, false),
ROT_60_REF_NPN("rot_60_ref_npn", SymmetricGroup3.P231, false, false, true),
ROT_60_REF_NPP("rot_60_ref_npp", SymmetricGroup3.P312, false, false, true),
ROT_60_REF_PNN("rot_60_ref_pnn", SymmetricGroup3.P231, false, true, false),
ROT_60_REF_PNP("rot_60_ref_pnp", SymmetricGroup3.P312, true, false, false),
ROT_60_REF_PPN("rot_60_ref_ppn", SymmetricGroup3.P312, false, true, false),
ROT_60_REF_PPP("rot_60_ref_ppp", SymmetricGroup3.P231, true, true, true),
SWAP_XY("swap_xy", SymmetricGroup3.P213, false, false, false),
SWAP_YZ("swap_yz", SymmetricGroup3.P132, false, false, false),
SWAP_XZ("swap_xz", SymmetricGroup3.P321, false, false, false),
SWAP_NEG_XY("swap_neg_xy", SymmetricGroup3.P213, true, true, false),
SWAP_NEG_YZ("swap_neg_yz", SymmetricGroup3.P132, false, true, true),
SWAP_NEG_XZ("swap_neg_xz", SymmetricGroup3.P321, true, false, true),
ROT_90_REF_X_NEG("rot_90_ref_x_neg", SymmetricGroup3.P132, true, false, true),
ROT_90_REF_X_POS("rot_90_ref_x_pos", SymmetricGroup3.P132, true, true, false),
ROT_90_REF_Y_NEG("rot_90_ref_y_neg", SymmetricGroup3.P321, true, true, false),
ROT_90_REF_Y_POS("rot_90_ref_y_pos", SymmetricGroup3.P321, false, true, true),
ROT_90_REF_Z_NEG("rot_90_ref_z_neg", SymmetricGroup3.P213, false, true, true),
ROT_90_REF_Z_POS("rot_90_ref_z_pos", SymmetricGroup3.P213, true, false, true);
public static final OctahedralGroup BLOCK_ROT_X_270 = ROT_90_X_POS;
public static final OctahedralGroup BLOCK_ROT_X_180 = ROT_180_FACE_YZ;
public static final OctahedralGroup BLOCK_ROT_X_90 = ROT_90_X_NEG;
public static final OctahedralGroup BLOCK_ROT_Y_270 = ROT_90_Y_POS;
public static final OctahedralGroup BLOCK_ROT_Y_180 = ROT_180_FACE_XZ;
public static final OctahedralGroup BLOCK_ROT_Y_90 = ROT_90_Y_NEG;
public static final OctahedralGroup BLOCK_ROT_Z_270 = ROT_90_Z_POS;
public static final OctahedralGroup BLOCK_ROT_Z_180 = ROT_180_FACE_XY;
public static final OctahedralGroup BLOCK_ROT_Z_90 = ROT_90_Z_NEG;
private final Matrix3fc transformation;
private final String name;
private @Nullable Map<Direction, Direction> rotatedDirections;
private final boolean invertX;
private final boolean invertY;
private final boolean invertZ;
private final SymmetricGroup3 permutation;
private static final OctahedralGroup[][] CAYLEY_TABLE = Util.make(() -> {
OctahedralGroup[] values = values();
OctahedralGroup[][] table = new OctahedralGroup[values.length][values.length];
Map<Integer, OctahedralGroup> fingerprints = Arrays.stream(values).collect(Collectors.toMap(OctahedralGroup::trace, o -> (OctahedralGroup)o));
for (OctahedralGroup first : values) {
for (OctahedralGroup second : values) {
SymmetricGroup3 composedPermutation = second.permutation.compose(first.permutation);
boolean composedInvertX = first.inverts(Direction.Axis.X) ^ second.inverts(first.permutation.permuteAxis(Direction.Axis.X));
boolean composedInvertY = first.inverts(Direction.Axis.Y) ^ second.inverts(first.permutation.permuteAxis(Direction.Axis.Y));
boolean composedInvertZ = first.inverts(Direction.Axis.Z) ^ second.inverts(first.permutation.permuteAxis(Direction.Axis.Z));
table[first.ordinal()][second.ordinal()] = fingerprints.get(trace(composedInvertX, composedInvertY, composedInvertZ, composedPermutation));
}
}
return table;
});
private static final OctahedralGroup[] INVERSE_TABLE = Arrays.stream(values())
.map(f -> Arrays.stream(values()).filter(s -> f.compose(s) == IDENTITY).findAny().get())
.toArray(OctahedralGroup[]::new);
private OctahedralGroup(String name, SymmetricGroup3 permutation, boolean invertX, boolean invertY, boolean invertZ) {
this.name = name;
this.invertX = invertX;
this.invertY = invertY;
this.invertZ = invertZ;
this.permutation = permutation;
this.transformation = new Matrix3f().scaling(invertX ? -1.0F : 1.0F, invertY ? -1.0F : 1.0F, invertZ ? -1.0F : 1.0F).mul(permutation.transformation());
}
private static int trace(boolean invertX, boolean invertY, boolean invertZ, SymmetricGroup3 permutation) {
int inversionIndex = (invertZ ? 4 : 0) + (invertY ? 2 : 0) + (invertX ? 1 : 0);
return permutation.ordinal() << 3 | inversionIndex;
}
private int trace() {
return trace(this.invertX, this.invertY, this.invertZ, this.permutation);
}
public OctahedralGroup compose(OctahedralGroup that) {
return CAYLEY_TABLE[this.ordinal()][that.ordinal()];
}
public OctahedralGroup inverse() {
return INVERSE_TABLE[this.ordinal()];
}
public Matrix3fc transformation() {
return this.transformation;
}
@Override
public String toString() {
return this.name;
}
@Override
public String getSerializedName() {
return this.name;
}
public Direction rotate(Direction direction) {
if (this.rotatedDirections == null) {
this.rotatedDirections = Util.makeEnumMap(Direction.class, facing -> {
Direction.Axis oldAxis = facing.getAxis();
Direction.AxisDirection oldDirection = facing.getAxisDirection();
Direction.Axis newAxis = this.permutation.inverse().permuteAxis(oldAxis);
Direction.AxisDirection newDirection = this.inverts(newAxis) ? oldDirection.opposite() : oldDirection;
return Direction.fromAxisAndDirection(newAxis, newDirection);
});
}
return this.rotatedDirections.get(direction);
}
public Vector3i rotate(Vector3i v) {
this.permutation.permuteVector(v);
v.x = v.x * (this.invertX ? -1 : 1);
v.y = v.y * (this.invertY ? -1 : 1);
v.z = v.z * (this.invertZ ? -1 : 1);
return v;
}
public boolean inverts(Direction.Axis axis) {
return switch (axis) {
case X -> this.invertX;
case Y -> this.invertY;
case Z -> this.invertZ;
};
}
public SymmetricGroup3 permutation() {
return this.permutation;
}
public FrontAndTop rotate(FrontAndTop input) {
return FrontAndTop.fromFrontAndTop(this.rotate(input.front()), this.rotate(input.top()));
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段/方法调用/返回值 - 关联成员:
Direction.fromAxisAndDirection()
- 引用位置:
-
- 引用位置:
参数/方法调用/返回值 - 关联成员:
FrontAndTop.fromFrontAndTop()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.make(), Util.makeEnumMap()
- 引用位置: