Skip to content

Commit

Permalink
Use matricies
Browse files Browse the repository at this point in the history
  • Loading branch information
oh-noey committed Aug 31, 2024
1 parent 2f198b8 commit f5d2375
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions Movecraft/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ commands:
usage: /craftinfo [player] [page]
libraries:
- org.roaringbitmap:RoaringBitmap:1.0.6
- org.ejml:ejml-simple:0.43
1 change: 1 addition & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
api(libs.it.unimi.dsi.fastutil)
api(libs.net.kyori.adventure.api)
api(libs.net.kyori.adventure.platform.bukkit)
api(libs.org.ejml.simple.library)
testImplementation(libs.org.junit.jupiter.junit.jupiter.api)
testImplementation(libs.junit.junit)
testImplementation(libs.org.hamcrest.hamcrest.library)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,33 @@
import net.countercraft.movecraft.MovecraftLocation;
import net.countercraft.movecraft.MovecraftRotation;
import org.bukkit.block.structure.Mirror;
import org.ejml.simple.SimpleMatrix;
import org.jetbrains.annotations.NotNull;

// TODO: Implement with 4d matrix
public record AffineTransformation(){
public static @NotNull AffineTransformation NONE = null;
public static @NotNull AffineTransformation of(MovecraftLocation translation){ return null; }
public static @NotNull AffineTransformation of(MovecraftRotation rotation){ return null; }
public @NotNull AffineTransformation mult(AffineTransformation other){ return null; }
public @NotNull MovecraftLocation apply(MovecraftLocation location){ return location; }
public record AffineTransformation(SimpleMatrix backingMatrix){
public static @NotNull AffineTransformation NONE = new AffineTransformation(SimpleMatrix.identity(4));
public static @NotNull AffineTransformation of(MovecraftLocation translation){
var ret = SimpleMatrix.identity(4);
ret.set(3, 0, translation.getX());
ret.set(3, 1, translation.getY());
ret.set(3, 2, translation.getZ());

return new AffineTransformation(ret);
}
public static @NotNull AffineTransformation of(MovecraftRotation rotation){

return null;
}
public @NotNull AffineTransformation mult(AffineTransformation other){
return new AffineTransformation(backingMatrix.mult(other.backingMatrix));
}

public @NotNull MovecraftLocation apply(MovecraftLocation location){
var transformed = backingMatrix.mult(new SimpleMatrix(new double[]{location.getX(), location.getY(), location.getZ(), 1}));

return new MovecraftLocation((int) transformed.get(0), (int) transformed.get(1), (int) transformed.get(2));
}
public @NotNull MovecraftRotation extractRotation(){ return null; }
public @NotNull Mirror extractMirror(){ return null; }
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ it-unimi-dsi-fastutil = "8.5.13"
junit-junit = "4.13.2"
net-kyori-adventure-api = "4.17.0"
net-kyori-adventure-platform-bukkit = "4.3.2"
org-ejml-library = "0.42"
org-hamcrest-hamcrest-library = "1.3"
org-jetbrains-annotations = "24.1.0"
org-junit-jupiter-junit-jupiter-api = "5.10.2"
Expand All @@ -21,6 +22,7 @@ it-unimi-dsi-fastutil = { module = "it.unimi.dsi:fastutil", version.ref = "it-un
junit-junit = { module = "junit:junit", version.ref = "junit-junit" }
net-kyori-adventure-api = { module = "net.kyori:adventure-api", version.ref = "net-kyori-adventure-api" }
net-kyori-adventure-platform-bukkit = { module = "net.kyori:adventure-platform-bukkit", version.ref = "net-kyori-adventure-platform-bukkit" }
org-ejml-simple-library = { module = "org.ejml:ejml-simple", version.ref = "org-ejml-library" }
org-hamcrest-hamcrest-library = { module = "org.hamcrest:hamcrest-library", version.ref = "org-hamcrest-hamcrest-library" }
org-jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "org-jetbrains-annotations" }
org-junit-jupiter-junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "org-junit-jupiter-junit-jupiter-api" }
Expand Down

0 comments on commit f5d2375

Please sign in to comment.