-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract affine changes to discreet branch
- Loading branch information
Showing
8 changed files
with
175 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
api/src/main/java/net/countercraft/movecraft/util/AffineTransformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.countercraft.movecraft.util; | ||
|
||
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(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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.