/// Get the key value couple after current point. /// If current point is above maximum key, issues maximum key/value // //ORIGINAL LINE: std::map<Real, Real>.Enumerator _getKeyValueAfter(float pos) const //public std.map<Real, Real>.Enumerator _getKeyValueAfter(float pos) public std_pair <float, float> _getKeyValueAfter(float pos) { std_pair <float, float> it = mKeyFrames.upper_bound(pos); int index = mKeyFrames.find(pos); //if (it==mKeyFrames.end()) if (index == mKeyFrames.Count - 1) { return(mKeyFrames.lower_bound(pos)); //return --it; } else { return(it); } }
/// Get the key value couple before current point. /// If current point is below minimum key, issues minimum key/value // //ORIGINAL LINE: std::map<Real, Real>.Enumerator _getKeyValueBefore(float pos) const //public std.map<Real, Real>.Enumerator _getKeyValueBefore(float pos) public std_pair <float, float> _getKeyValueBefore(float pos) { std_pair <float, float> it = mKeyFrames.upper_bound(pos); int index = mKeyFrames.find(pos); //if (it==mKeyFrames.begin()) if (index == 0) { return(it); } else { return(mKeyFrames.lower_bound(pos)); //return --it; } //std::map<Real, Real>::const_iterator it = mKeyFrames.upper_bound(pos); //if (it==mKeyFrames.begin()) // return it; //else // return --it; }
/// Gets the value on the current point // //ORIGINAL LINE: float getValue(float pos) const public float getValue(float pos) { std_pair <float, float> itAfter = _getKeyValueAfter(pos); std_pair <float, float> itBefore = _getKeyValueBefore(pos); if (itAfter == itBefore) { return(itBefore.second); } //if (itAfter==mKeyFrames.begin()) if (itAfter == mKeyFrames.get(0)) { return(itAfter.second); } Real x1 = itBefore.first; Real y1 = itBefore.second; Real x2 = itAfter.first; Real y2 = itAfter.second; return((pos - x1) / (x2 - x1) * (y2 - y1) + y1); }
//----------------------------------------------------------------------- public bool _sortAngles(std_pair<Radian, uint> one, std_pair<Radian, uint> two) // waiting for lambda functions! { return one.first < two.first; }