Real Sample(const AngleSet& angles) { Real sum=0; for(size_t i=0;i<angles.size();i++) sum += angles[i].d; Real u=Rand()*sum; for(size_t i=0;i<angles.size();i++) { if(u <= angles[i].d) return AngleNormalize(angles[i].c+u); u -= angles[i].d; } AssertNotReached(); return 0; }
void SawtoothAngleEnvelope::setAngles(const AngleSet& angles) { Assert(!angles.empty()); setInterval(angles[0]); flip_y(); SawtoothAngleEnvelope temp; for(size_t i=1;i<angles.size();i++) { temp.setInterval(angles[i]); temp.flip_y(); upperEnvelope(temp); } flip_y(); /* cout<<"Sawtooth "; for(size_t i=0;i<v.size();i++) { cout<<v[i]<<", "; } cout<<endl; */ }