aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-04-15 21:00:16 +0200
committer GitHub <noreply@github.com>2024-04-15 21:00:16 +0200
commit8f97145e9570a9b728010a818137cb31a51fd5f6 (patch)
treeefe1150a7b6c92bf983dfcab2e0bd147bfcf54bf /src/openvic-simulation/dataloader/NodeTools.hpp
parenta57e81703102bc52297fbdc074da755fa8edbedd (diff)
parenta7f125a5f276e2951d1236fe88e32c5c08271504 (diff)
Merge pull request #155 from OpenVicProject/province-positions
Province positions
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp
index c41c09e..0df057a 100644
--- a/src/openvic-simulation/dataloader/NodeTools.hpp
+++ b/src/openvic-simulation/dataloader/NodeTools.hpp
@@ -506,5 +506,24 @@ namespace OpenVic {
return warn;
};
}
+
+ /* Often used for rotations which must be negated due to OpenVic's coordinate system being orientated
+ * oppositely to Vic2's. */
+ template<typename T = fixed_point_t>
+ constexpr Callback<T> auto negate_callback(Callback<T> auto callback) {
+ return [callback](T val) -> bool {
+ return callback(-val);
+ };
+ }
+
+ /* Often used for map-space coordinates which must have their y-coordinate flipped due to OpenVic using the
+ * top-left of the map as the origin as opposed Vic2 using the bottom-left. */
+ template<typename T>
+ constexpr Callback<vec2_t<T>> auto flip_y_callback(Callback<vec2_t<T>> auto callback, T height) {
+ return [callback, height](vec2_t<T> val) -> bool {
+ val.y = height - val.y;
+ return callback(val);
+ };
+ }
}
}