Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
isoMath.hxx
Go to the documentation of this file.
1 #ifndef ISOMATH_HXX_
2 #define ISOMATH_HXX_
3 
4 #include <vector>
5 #include <algorithm>
6 #include <SDL.h>
7 
8 #include "Point.hxx"
9 
10 // calculate clicked column (x coordinate) without heigh taken into account.
17 Point calculateIsoCoordinates(const SDL_Point &screenCoordinates);
18 
27 SDL_Point convertIsoToScreenCoordinates(const Point &isoCoordinates, bool calcWithoutOffset = false);
28 
37 Point convertScreenToIsoCoordinates(const SDL_Point &screenCoordinates);
38 
44 std::vector<Point> createBresenhamLine(const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd);
45 
51 std::vector<Point> getRectangleSelectionNodes(const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd);
52 
57 // bool isPointWithinMapBoundaries(int x, int y);
58 // bool isPointWithinMapBoundaries(const Point &isoCoordinates);
59 bool isPointWithinMapBoundaries(const std::vector<Point> &isoCoordinates);
60 
61 //TODO: Remove this when switching to C++17 and use std::clamp instead
63 template <typename T> T clamp(const T &n, const T &lower, const T &upper) { return std::max(lower, std::min(n, upper)); }
64 
65 #endif
getRectangleSelectionNodes
std::vector< Point > getRectangleSelectionNodes(const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd)
Gets all nodes in a rectangle between start and end point.
convertIsoToScreenCoordinates
SDL_Point convertIsoToScreenCoordinates(const Point &isoCoordinates, bool calcWithoutOffset=false)
converts coordinates from isometric to screen space
Definition: isoMath.cxx:25
clamp
T clamp(const T &n, const T &lower, const T &upper)
Clamp value.
Definition: isoMath.hxx:63
Point
Definition: Point.hxx:7
calculateIsoCoordinates
Point calculateIsoCoordinates(const SDL_Point &screenCoordinates)
Calculates screen space coordinates to isometric space coordinates.
Definition: isoMath.cxx:11
createBresenhamLine
std::vector< Point > createBresenhamLine(const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd)
Creates a line between two points using the Bresenham Line algorithm.
isPointWithinMapBoundaries
bool isPointWithinMapBoundaries(const std::vector< Point > &isoCoordinates)
Check if given coordinates are within map boundaries.
Definition: isoMath.cxx:81
convertScreenToIsoCoordinates
Point convertScreenToIsoCoordinates(const SDL_Point &screenCoordinates)
converts screen space coordinates to isometric space coordinates.
Definition: isoMath.cxx:49
Point.hxx