24 lines
720 B
C++
24 lines
720 B
C++
|
//
|
||
|
// Created by max on 27.04.23.
|
||
|
//
|
||
|
|
||
|
#include "isometric_coordinate_transformer.h"
|
||
|
|
||
|
IsometricCoordinateTransformer::IsometricCoordinateTransformer() {
|
||
|
worldToScreenMatrix = Eigen::Matrix<float, 2, 3>();
|
||
|
worldToScreenMatrix << 0.5f, 0.5f, 0,
|
||
|
-0.5f, 0.5f, -1;
|
||
|
}
|
||
|
|
||
|
ScreenCoordinates IsometricCoordinateTransformer::worldToScreen(WorldCoordinates worldCoordinates) const {
|
||
|
Eigen::Vector3f worldCoordinatesVector;
|
||
|
worldCoordinatesVector << worldCoordinates.x, worldCoordinates.y, worldCoordinates.z;
|
||
|
|
||
|
Eigen::Vector2f screenCoordinatesVector = worldToScreenMatrix * worldCoordinatesVector;
|
||
|
|
||
|
return {
|
||
|
screenCoordinatesVector.x(),
|
||
|
screenCoordinatesVector.y()
|
||
|
};
|
||
|
}
|