Preview only show first 10 pages with watermark. For full document please download

Geometria Computacional - Segmento 2d

classes de geometria computacional

   EMBED


Share

Transcript

"#include ""Segmento_2D.h // impressao de um Segmento_2D ostream & operator << (ostream & output, const Segmento_2D &_l) { output << ""Segmento_2D["" << _l.P0 << "," "" << _l.P1 << ""]"";", return output;,, },, ,, // funcao que verifica se um ponto pertence ou nao a um Segmento,, const bool Segmento_2D :: Pertence (const Ponto &_P)const{,, Rac rx,ry;, if(!this->Linha_2D :: Intersecao(_P,rx,ry))return false; if(((rx >= -1) && (rx <= 1))&&((ry >= -1) && (ry <= 1)))return true;,, ,, return false;,, },, ,, // funcao que retorna o ponto ortogonal,, const bool Segmento_2D :: Ponto_Ortogonal(const Ponto &_P, Ponto &_I)const{, Linha l1;,, Racional r = this-> Linha_2D::Intersecao(_P);,, if((r < -1) "" (r > 1) )return false;,, _I = ((((1-r)/2)*P0) + (((1+r)/2)*P1));,, ,, return true;,, },, ,, // funcao que calcula a intersecao de dois Segmentos,, const bool Segmento_2D :: Intersecao (const Segmento_2D &_l1, Ponto &_I)const{, Rac r1,r2;, if(!this->Linha_2D::Intersecao(_l1,r1,r2))return false; if(((r1 < -1) "" (r1 > 1)) "" ((r2 < -1) "" (r2 > 1)))return false;,, _I = ((((1-r1)/2)*P0) + (((1+r1)/2)*P1));,, ,, return true;,, },, ,, // funcao que calcula a intersecao de Segmento e Linha,, const bool Segmento_2D :: Intersecao (const Linha_2D &_l1, Ponto & _I)const{, return _l1.Intersecao ( *this, _I);, },, ,, ,, // funcao que calcula a intersecao de Segmento e Raio,, const bool Segmento_2D :: Intersecao (const Raio &_r, Ponto & _I)const{, return _r.Intersecao(*this, _I);, },,