Aabb Aabb::SplitAlongZ(float startU, float endU) const { Vec3f nmin, nmax; nmin = InterpolateLinear(m_min, Vec3f(m_min[0], m_min[1], m_max[2]), startU); nmax = InterpolateLinear(Vec3f(m_max[0], m_max[1], m_min[2]), m_max, endU); return Aabb(nmin, nmax); }
void DoSegment(int i,double *V0, double A) { double d,t,angle; d = dist[i]; // get distance for this segment // determine how much time will be required to go this distance // at a starting Velocity of V0 while accelerating at A if (A!=0) { // must solve quadratic to determine time at end t = (-(*V0) + sqrt((*V0)*(*V0) + 2.0f*A*d))/A; } else { // constant velocity case is simple t = d/(*V0); } // determine the direction of the segment so we can control the tagential knife angle = FindAngle(pointx[i]-pointx[i-1],pointy[i]-pointy[i-1]); x0=x1; // this segment starts at the beg of previous y0=y1; a0=a1; x1=pointx[i]*RESX; y1=pointy[i]*RESY; a1=angle*RESA; InterpolateLinear(0.0, 0.5*A/d, *V0/d, 0.0, t); // add to coordinated motion buffer *V0 += t * A; // return new final velocity }
void InterpolatorKNN::KollinearWithDistinctPositions(NNCandidate candidates[3], Vertex v) { // project v onto line <v_01, v_02> with hesse normal form D3DXVECTOR3 v_01 = candidates[1].vertex.pos-candidates[0].vertex.pos; D3DXVECTOR3 v_02 = candidates[2].vertex.pos-candidates[0].vertex.pos; D3DXVECTOR3 v_0v = v.pos-candidates[0].vertex.pos; D3DXVECTOR3 v_1v = v.pos-candidates[1].vertex.pos; D3DXVECTOR3 v_2v = v.pos-candidates[2].vertex.pos; D3DXVECTOR3 v_2 = CrossProd(v_01, v_0v); if(v_2.x != 0.0f || v_2.y != 0.0f || v_2.z != 0.0f) { D3DXVECTOR3 normal = Normalize(CrossProd(v_01, v_2)); D3DXVECTOR3 pointOnPlane = candidates[0].vertex.pos; float d = DotProd(normal, pointOnPlane); float distance = DotProd(normal, v.pos) - d; v.pos = v.pos + distance * (-normal); } if(DotProd(v_01, v_02) < -0.9f) { // 0 is in the middle if(DotProd(v_01, v_0v) > 0.9f){ // v on the same side as 1 InterpolateLinear(candidates[0], candidates[1], v); candidates[2].weight = 0.0f; } else{ // v on the same side as 2 InterpolateLinear(candidates[0], candidates[2], v); candidates[1].weight = 0.0f; } } if(Length(v_01) < Length(v_02)) { // 1 is in the middle if(DotProd(-v_01, v_1v) > 0.9f){ // v on the same side as 0 InterpolateLinear(candidates[1], candidates[0], v); candidates[2].weight = 0.0f; } else{ // v on the same side as 2 InterpolateLinear(candidates[1], candidates[2], v); candidates[0].weight = 0.0f; } } else{ // 2 is in the middle if(DotProd(-v_02, v_2v) > 0.9f){ // v on the same side as 0 InterpolateLinear(candidates[2], candidates[0], v); candidates[1].weight = 0.0f; } else{ // v on the same side as 1 InterpolateLinear(candidates[2], candidates[1], v); candidates[0].weight = 0.0f; } } }
T InterpolateLinear(T start, T end, float startT, float endT, float time) { return InterpolateLinear(start, end, (time-startT)/(endT-startT)); };