Files
3DChess/app/src/main/java/chess/view/DDDrender/DDDPlacement.java
fl.du.pr Grens 97950403a5
All checks were successful
Linux arm64 / Build (push) Successful in 33s
class documentation - a shitload of it
2025-05-18 20:08:22 +02:00

24 lines
638 B
Java

package chess.view.DDDrender;
import org.joml.Vector2f;
import chess.model.Coordinate;
/**
* Helper functions to convert from 2D to 3D coordinates systems.
*/
public class DDDPlacement {
public static Vector2f coordinatesToVector(Coordinate coo) {
return coordinatesToVector(coo.getX(), coo.getY());
}
public static Vector2f coordinatesToVector(float x, float y) {
return new Vector2f(1.0f - 0.125f - x * 0.250f, 1.0f - 0.125f - y * 0.250f);
}
public static Coordinate vectorToCoordinates(Vector2f pos) {
int x = (int) ((1.0f - pos.x) * 4.0f);
int y = (int) ((1.0f - pos.y) * 4.0f);
return new Coordinate(x, y);
}
}