MCPcopy Create free account
hub / github.com/BuildCraft/BuildCraft / Matrix4i

Class Matrix4i

common/buildcraft/lib/misc/Matrix4i.java:8–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import buildcraft.lib.misc.data.Box;
7
8public class Matrix4i {
9 public static final Matrix4i IDENTITY = makeScale(VecUtil.POS_ONE);
10
11 private final int m00, m01, m02, m03;
12 private final int m10, m11, m12, m13;
13 private final int m20, m21, m22, m23;
14 private final int m30, m31, m32, m33;
15
16 public static Matrix4i makeTranslation(Vec3i vec) {
17 // @formatter:off
18 return new Matrix4i(
19 1, 0, 0, vec.getX(),
20 0, 1, 0, vec.getY(),
21 0, 0, 1, vec.getZ(),
22 0, 0, 0, 1);
23 // @formatter:on
24 }
25
26 public static Matrix4i makeScale(Vec3i vec) {
27 // @formatter:off
28 return new Matrix4i(
29 vec.getX(), 0, 0, 0,
30 0, vec.getY(), 0, 0,
31 0, 0, vec.getZ(), 0,
32 0, 0, 0, 1);
33 // @formatter:on
34 }
35
36 public static Matrix4i makeRotY(int ang) {
37 if (ang % 90 != 0) throw new IllegalArgumentException("You can only have angles in increments of 90 degrees!");
38 ang %= 360;
39
40 if (ang == 90) {
41 // @formatter:off
42 return new Matrix4i(
43 0, 0, 1, 0,
44 0, 1, 0, 0,
45 -1, 0, 0, 0,
46 0, 0, 0, 1);
47 // @formatter:on
48 } else if (ang == 180) {
49 // @formatter:off
50 return new Matrix4i(
51 -1, 0, 0, 0,
52 0, 1, 0, 0,
53 0, 0,-1, 0,
54 0, 0, 0, 1);
55 // @formatter:on
56 } else if (ang == 270) {
57 // @formatter:off
58 return new Matrix4i(
59 0, 0,-1, 0,
60 0, 1, 0, 0,
61 1, 0, 0, 0,
62 0, 0, 0, 1);
63 // @formatter:on
64 } else return IDENTITY;
65 }

Callers

nothing calls this directly

Calls 1

makeScaleMethod · 0.95

Tested by

no test coverage detected