This commit is contained in:
Georges Dupéron 2012-01-10 13:07:45 +01:00
parent d9dcbdb206
commit 6ddc2d7d8f
4 changed files with 10 additions and 3 deletions

View File

@ -126,5 +126,7 @@ Vertex Quad::randomPoint(int seed, int n) const {
float Quad::surface() const {
Triangle ne(c[NW], c[NE], c[SE]);
Triangle sw(c[SE], c[SW], c[NW]);
std::cout << sw[LEFT] << " " << sw[TOP] << " " << sw[RIGHT] << std::endl;
std::cout << "{" << ne.surface() << " " << sw.surface() << "}" << std::endl;
return ne.surface() + sw.surface();
}

View File

@ -59,5 +59,7 @@ Vertex Triangle::randomPoint(int seed, int n) const {
float Triangle::surface() const {
float hauteur = Segment(c[TOP], (c[TOP] - c[LEFT]).projectOn(c[RIGHT] - c[LEFT])).length();
float base = Segment(c[LEFT], c[RIGHT]).length();
std::cout << "Triangle = " << c[LEFT] << " " << c[TOP] << " " << c[RIGHT] << std::endl;
std::cout << "Triangle : b=" << base << " h=" << hauteur << " " << (c[TOP] - c[LEFT]).projectOn(c[RIGHT] - c[LEFT]) << std::endl;
return (base * hauteur) / 2.f;
}

View File

@ -5,7 +5,7 @@
int main() {
// Générer une tile de base
std::cout << "Initial seed = " << Chose::initialSeed << std::endl;
float size = 10;
float size = 20000;
Vertex ne(size, size, 0);
Vertex se(size, 0, 0);
Vertex sw(0, 0, 0);
@ -14,6 +14,9 @@ int main() {
c->triangulation();
c->updateAABB();
new View(c);
//std::cout << Triangle(se, sw, nw).surface() << std::endl;
std::cout << Quad(Vertex(10,10,0), Vertex(10,0,0), Vertex(0,0,0), Vertex(0,10,0)).surface() << std::endl;
//new View(c);
return 0;
}

View File

@ -145,4 +145,4 @@ void Chose::drawAABB() {
);
}
unsigned int Chose::initialSeed = random_seed();
unsigned int Chose::initialSeed = 1032729551;//random_seed();