// *********************************************************
// Triangle Class
// Author : Tamy Boubekeur (boubek@gmail.com).
// Copyright (C) 2008 Tamy Boubekeur.
// All rights reserved.
// *********************************************************

#include "Triangle.h"

using namespace std;

ostream & operator<< (ostream & output, const Triangle & t) {
    output << t.getVertex (0) << " " << t.getVertex (1) << " " << t.getVertex (2);
    return output;
}

float Triangle::minPos(unsigned int axis, const std::vector<Vertex>& vertices) const
{
    float res = vertices[v[0]].getPos()[axis];
    if(vertices[v[1]].getPos()[axis] < res) res = vertices[v[1]].getPos()[axis];
    if(vertices[v[2]].getPos()[axis] < res) res = vertices[v[2]].getPos()[axis];
    return res;
}

float Triangle::maxPos(unsigned int axis, const std::vector<Vertex>& vertices) const
{
    float res = vertices[v[0]].getPos()[axis];
    if(vertices[v[1]].getPos()[axis] > res) res = vertices[v[1]].getPos()[axis];
    if(vertices[v[2]].getPos()[axis] > res) res = vertices[v[2]].getPos()[axis];
    return res;
}
