www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 62197c4e2b5412258fb8dc5b7c5c5336a0e7db5a
parent 6ddc2d7d8f83be9a98ca231a25cb6a345e6a5fc9
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Tue, 10 Jan 2012 13:25:42 +0100

Correction sur Triangle::surface() .

Diffstat:
Mgeometry/quad.cpp | 2--
Mgeometry/triangle.cpp | 4+---
Mgeometry/vertex.cpp | 8++++----
Mmain.cpp | 5+----
Mrules/chose.cpp | 2+-
5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/geometry/quad.cpp b/geometry/quad.cpp @@ -126,7 +126,5 @@ 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(); } diff --git a/geometry/triangle.cpp b/geometry/triangle.cpp @@ -57,9 +57,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 hauteur = Segment(c[TOP], c[LEFT] + (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; } diff --git a/geometry/vertex.cpp b/geometry/vertex.cpp @@ -19,12 +19,12 @@ Vertex intersection(Vertex a, Vertex b, Vertex c, Vertex d) { ); } +// TODO : n'est qu'en 2D ! Vertex Vertex::projectOn(Vertex v) const { // http://www.developpez.net/forums/d202580/applications/developpement-2d-3d-jeux/contribuez/faq-mat-quat-ajout-calculs-vectoriels/ - float scalaire = (this->x)*(v.x) + (this->y)*(v.y); - float normecarre = v.norm(); - normecarre *= normecarre; - return Vertex(v.x * scalaire / normecarre, v.y * scalaire / normecarre, 0); + float scalaire = (this->x)*(v.x) + (this->y)*(v.y) + (this->z)*(v.z); + float norme = v.norm(); + return Vertex(v.x, v.y, v.z) * scalaire / (norme * norme); } Vertex Vertex::setNorm(float n) const { diff --git a/main.cpp b/main.cpp @@ -14,9 +14,6 @@ int main() { c->triangulation(); c->updateAABB(); - //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); + new View(c); return 0; } diff --git a/rules/chose.cpp b/rules/chose.cpp @@ -145,4 +145,4 @@ void Chose::drawAABB() { ); } -unsigned int Chose::initialSeed = 1032729551;//random_seed(); +unsigned int Chose::initialSeed = random_seed();