47 #include "Primitive.h"
54 : _position_and_color(f)
58 const Vector3& Point::vertex(
int)
const
60 return _position_and_color.pos() ;
65 return _position_and_color ;
70 return ( (i&1)==0 )?P1:P2 ;
78 const Vector3& Segment::vertex(
int i)
const
80 return ( (i&1)==0 )?P1.pos():P2.pos() ;
93 return _vertices[i % nbVertices()] ;
96 const Vector3& Polygone::vertex(
int i)
const
98 return _vertices[i % nbVertices()].pos() ;
102 Polygone::Polygone(
const vector<Feedback3DColor>& fc)
107 for(
unsigned int i=0;i<fc.size();i++)
108 _bbox.include(fc[i].pos()) ;
116 double Polygone::equation(
const Vector3& v)
const
118 return v * _normal - _c ;
121 void Polygone::initNormal()
123 FLOAT anglemax = 0.0 ;
125 FLOAT v12norm = (vertex(1)-vertex(0)).norm() ;
127 for(
unsigned int i=0;i<nbVertices();i++)
133 Vector3 normal_tmp((v3-v2)^(v1-v2)) ;
135 FLOAT v32norm = (v3-v2).norm() ;
137 if(normal_tmp.z() > 0)
140 if((v32norm > 0.0)&&(v12norm > 0.0))
142 double anglemaxtmp = normal_tmp.norm()/v32norm/v12norm ;
144 if(anglemaxtmp > anglemax)
146 anglemax = anglemaxtmp ;
147 normalmax = normal_tmp ;
153 if(anglemax > FLAT_POLYGON_EPS)
160 anglefactor = anglemax ;
161 _c = _normal*vertex(0) ;
164 std::ostream& vrender::operator<<(std::ostream& o,
const Feedback3DColor& f)
166 o <<
"(" << f.pos() <<
") + (" << f.red() <<
"," << f.green() <<
"," << f.blue() <<
"," << f.alpha() <<
")" << endl ;
double infNorm() const
Infinite norm.