46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
|
#include "GroundFlatMesh.hpp"
|
||
|
|
||
|
#include <vector>
|
||
|
|
||
|
const int GroundFlatMesh::MIN_I = -40;
|
||
|
const int GroundFlatMesh::MAX_I = 100;
|
||
|
const int GroundFlatMesh::MIN_J = -40;
|
||
|
const int GroundFlatMesh::MAX_J = 100;
|
||
|
|
||
|
GroundFlatMesh::GroundFlatMesh(const Point& center, double decay_speed)
|
||
|
: center(center), decay_speed(decay_speed)
|
||
|
{
|
||
|
std::vector<std::vector<size_t> > vertice_at(MAX_I - MIN_I + 1,
|
||
|
std::vector<size_t>(MAX_J - MIN_J + 1));
|
||
|
|
||
|
for(int i=MIN_I; i < MAX_I + 1; ++i) {
|
||
|
for(int j=MIN_J; j < MAX_J + 1; ++j) {
|
||
|
vertice_at[i - MIN_I][j - MIN_J] =
|
||
|
output.add_vertice(
|
||
|
tile_position(i, j),
|
||
|
Point(0., 1., 0.));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for(int i=MIN_I; i < MAX_I; ++i) {
|
||
|
for(int j=MIN_J; j < MAX_J; ++j) {
|
||
|
output.add_face(Face(
|
||
|
vertice_at[i - MIN_I][j - MIN_J],
|
||
|
vertice_at[i - MIN_I][j + 1 - MIN_J],
|
||
|
vertice_at[i + 1 - MIN_I][j + 1 - MIN_J]));
|
||
|
output.add_face(Face(
|
||
|
vertice_at[i - MIN_I][j - MIN_J],
|
||
|
vertice_at[i + 1 - MIN_I][j + 1 - MIN_J],
|
||
|
vertice_at[i + 1- MIN_I][j - MIN_J]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
double GroundFlatMesh::ith_dist(int i) const {
|
||
|
return ((i < 0) ? -1 : 1) * decay_speed * i * i;
|
||
|
}
|
||
|
|
||
|
Point GroundFlatMesh::tile_position(int i, int j) const {
|
||
|
return Point(ith_dist(i), 0., ith_dist(j));
|
||
|
}
|