| 124 | } |
| 125 | |
| 126 | static Point |
| 127 | getLeftPointAt(const BezierCPs& cps, |
| 128 | double time, |
| 129 | double t) |
| 130 | { |
| 131 | int ncps = (int)cps.size(); |
| 132 | |
| 133 | assert(ncps); |
| 134 | if (!ncps) { |
| 135 | throw std::logic_error("getLeftPointAt()"); |
| 136 | } |
| 137 | if (t < 0) { |
| 138 | t += ncps; |
| 139 | } |
| 140 | int t_i = (int)std::floor(t) % ncps; |
| 141 | int t_i_plus_1 = t_i % ncps; |
| 142 | assert(t_i >= 0 && t_i < ncps && t_i_plus_1 >= 0 && t_i_plus_1 < ncps); |
| 143 | if (t == t_i) { |
| 144 | BezierCPs::const_iterator it = cps.begin(); |
| 145 | std::advance(it, t_i); |
| 146 | Point ret; |
| 147 | (*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y); |
| 148 | |
| 149 | return ret; |
| 150 | } else if (t == t_i_plus_1) { |
| 151 | BezierCPs::const_iterator it = cps.begin(); |
| 152 | std::advance(it, t_i_plus_1); |
| 153 | Point ret; |
| 154 | (*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y); |
| 155 | |
| 156 | return ret; |
| 157 | } |
| 158 | |
| 159 | BezierCPs::const_iterator it = cps.begin(); |
| 160 | std::advance(it, t_i); |
| 161 | BezierCPs::const_iterator next = it; |
| 162 | ++next; |
| 163 | if ( next == cps.end() ) { |
| 164 | next = cps.begin(); |
| 165 | } |
| 166 | |
| 167 | t = t - t_i; |
| 168 | |
| 169 | Point a, b, c, ab, bc, abc; |
| 170 | Point ret; |
| 171 | (*it)->getPositionAtTime(false, time, ViewIdx(0), &a.x, &a.y); |
| 172 | (*it)->getRightBezierPointAtTime(false, time, ViewIdx(0), &b.x, &b.y); |
| 173 | (*next)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &c.x, &c.y); |
| 174 | ab.x = (1. - t) * a.x + t * b.x; |
| 175 | ab.y = (1. - t) * a.y + t * b.y; |
| 176 | |
| 177 | bc.x = (1. - t) * b.x + t * c.x; |
| 178 | bc.y = (1. - t) * b.y + t * c.y; |
| 179 | |
| 180 | abc.x = (1. - t) * ab.x + t * bc.x; |
| 181 | abc.y = (1. - t) * ab.y + t * bc.y; |
| 182 | if ( (abc.x == a.x) && (abc.y == a.y) ) { |
| 183 | (*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0), &ret.x, &ret.y); |
no test coverage detected