Gamedev Framework (gf)  0.5.0
A C++11 framework for 2D games
Geometry.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_GEOMETRY_H
22 #define GF_GEOMETRY_H
23 
24 #include <vector>
25 
26 #include "Portability.h"
27 #include "Random.h"
28 #include "Vector.h"
29 
30 namespace gf {
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 inline namespace v1 {
33 #endif
34 
42  class Bresenham {
43  public:
50  Bresenham(Vector2i p0, Vector2i p1);
51 
58  bool step(Vector2i& res);
59 
60  private:
61  Vector2i m_p0;
62  Vector2i m_p1;
63  Vector2i m_delta;
64  Vector2i m_step;
65  int m_error;
66  };
67 
80  GF_API std::vector<Vector2i> generateLine(Vector2i p0, Vector2i p1);
81 
94  GF_API std::vector<Vector2f> midpointDisplacement1D(Vector2f p0, Vector2f p1, Random& random, unsigned iterations, Vector2f direction, float initialFactor = 1.0f, float reductionFactor = 0.5f);
95 
109  GF_API std::vector<Vector2f> midpointDisplacement1D(Vector2f p0, Vector2f p1, Random& random, unsigned iterations, float initialFactor = 1.0f, float reductionFactor = 0.5f);
110 
111 #ifndef DOXYGEN_SHOULD_SKIP_THIS
112 }
113 #endif
114 }
115 
116 #endif // GF_GEOMETRY_H
A random engine.
Definition: Random.h:43
The namespace for gf classes.
Definition: Action.h:34
State for the Bresenham&#39;s line algorithm.
Definition: Geometry.h:42
std::vector< Vector2f > midpointDisplacement1D(Vector2f p0, Vector2f p1, Random &random, unsigned iterations, Vector2f direction, float initialFactor=1.0f, float reductionFactor=0.5f)
1D midpoint displacement
std::vector< Vector2i > generateLine(Vector2i p0, Vector2i p1)
Generate a line between two positions.