AABB Ellipse::TransformShape(ECS::Transform &transform) { static const float FATNESS = 1.2f; AABB bound; _position = Vector2(transform.PositionWC()); _dimensions = Vector2(transform.ScaleWC()); _rotation = transform.RootRotation2D(); // store the cosine and sine of the rotation Math::SinCos(_rotation, _s, _c); if (_dimensions.x == _dimensions.y) { bound.low_bound = _position - _dimensions; bound.up_bound = _position + _dimensions; } else { Vector2 extent = Vector2( GetSupport(Vector2(1, 0)).x, GetSupport(Vector2(0, 1)).y ); Vector2 dimensions = (extent - _position) * FATNESS; bound.low_bound = _position - dimensions; bound.up_bound = _position + dimensions; } return bound; }
void EWACore::InitLutTable() { lut = new float[LUT_SIZE]; float filter_end = GetSupport()*GetSupport(); lut_factor = ((float) (LUT_SIZE - 16)) / filter_end; for (int i = 0; i < LUT_SIZE; i++) { lut[i] = factor((float)i / lut_factor); } }
// take CurItemH, compose item sets of next size and fill the frequent ones in CandItemH void TTrawling::GenCandAndCntSupp(const int& FqItemsetLen) { CandItemH.Clr(false); TIntV JoinItem; if (CurItemH.Len() == 0) { return; } if (CurItemH.GetKey(0).Len() == 1) { // join 1-items into 2-items for (int i = 0; i < CurItemH.Len(); i++) { for (int j = i+1; j < CurItemH.Len(); j++) { JoinItems(CurItemH.GetKey(i), CurItemH.GetKey(j), JoinItem); if (JoinItem.Len() == CurItemH.GetKey(i).Len()+1) { const int Supp = GetSupport(JoinItem); if (Supp >= MinSup) { CandItemH.AddDat(JoinItem, Supp); } } } } } else { // join longer item sets CurItemH.SortByKey(); TIntV JoinSet(CurItemH.Len()); for (int i = 0; i < CurItemH.Len(); i++) { const TIntV& CurSet = CurItemH.GetKey(i); const int Val = CurSet[CurSet.Len()-2]; // keep chacking next itemsets that differ only at last element for (int j=i+1; j < CurItemH.Len() && CurItemH.GetKey(j)[CurItemH.GetKey(j).Len()-2] == Val; j++) { JoinItems(CurSet, CurItemH.GetKey(j), JoinItem); if (JoinItem.Len() == CurSet.Len()+1) { // new set is of the right length const int Supp = GetSupport(JoinItem); if (Supp >= MinSup) { CandItemH.AddDat(JoinItem, Supp); JoinSet[i]=1; JoinSet[j]=1; } } } if (FqItemsetLen!=-1 && CurSet.Len() >= FqItemsetLen && JoinSet[i]==0) { // expansion was not frequent MxFqItemSetV.Add(CurSet); } } } }
void TTrawling::CountSupport() { for (int c = 0; c < CandItemH.Len(); c++) { CandItemH[c] = GetSupport(CandItemH.GetKey(c)); if (c % Kilo(100) == 0) { printf("."); } } }
//------------------------------------------------------------------------------ // Purpose : Return the structural support for this pane. Assumes window // is upright. Still works for windows parallel to the ground // but simulation isn't quite as good // Input : // Output : //------------------------------------------------------------------------------ float CBreakableSurface::RecalcSupport(int nWidth, int nHeight) { // Always has some support. Zero signifies that it has been broken float flSupport = 0.01; // ------------ // Top support // ------------ if (nHeight == m_nNumHigh-1) { flSupport += 1.0; } else { flSupport += GetSupport(nWidth,nHeight+1); } // ------------ // Bottom Support // ------------ if (nHeight == 0) { flSupport += 1.25; } else { flSupport += 1.25 * GetSupport(nWidth,nHeight-1); } // ------------ // Left Support // ------------ if (nWidth == 0) { flSupport += 1.0; } else { flSupport += GetSupport(nWidth-1,nHeight); } // -------------- // Right Support // -------------- if (nWidth == m_nNumWide-1) { flSupport += 1.0; } else { flSupport += GetSupport(nWidth+1,nHeight); } // -------------------- // Bottom Left Support // -------------------- if (nHeight == 0 || nWidth == 0) { flSupport += 1.0; } else { flSupport += GetSupport(nWidth-1,nHeight-1); } // --------------------- // Bottom Right Support // --------------------- if (nHeight == 0 || nWidth == m_nNumWide-1) { flSupport += 1.0; } else { flSupport += GetSupport(nWidth+1,nHeight-1); } // ----------------- // Top Right Support // ----------------- if (nHeight == m_nNumHigh-1 || nWidth == m_nNumWide-1) { flSupport += 0.25; } else { flSupport += 0.25 * GetSupport(nWidth+1,nHeight+1); } // ----------------- // Top Left Support // ----------------- if (nHeight == m_nNumHigh-1 || nWidth == 0) { flSupport += 0.25; } else { flSupport += 0.25 * GetSupport(nWidth-1,nHeight+1); } return flSupport; }