示例#1
0
void MatchOrgAthView::OnBnClickedSplitAddtr()
{
	// TODO: 在此添加控件通知处理程序代码
	Troop tro;
	tro._match.ID = matchID;
	Dialog_TrName trn(&tro);
	if(trn.DoModal() == IDOK)
		AddTroToList(&tro);
}
示例#2
0
文件: Model.cpp 项目: davor-/GoSum
void GoSUM::CModelVariables::setNormalization()
{
    int i,j,N=size(),eN=expandedSize(),exsize;
    trn.setZero(eN);
    scl.setOnes(eN);

    for ( i=0,j=0; i<N; i++ ) {
        const CModelVariable &aMV=mvs[i];
        exsize=aMV.expandedSize();
        if ( exsize==1 ) {
//           trn(j)=aMV.minValue();
//           scl(j)=aMV.maxValue()-aMV.minValue();
           trn(j)=aMV.expectedValue();
           scl(j)=sqrt(aMV.variance());
           if ( fabs(scl(j))<TINY ) { trn(j)+=1.;   scl(j)=1.; }
        }
        j+=exsize;
    }
}
示例#3
0
void MatchOrgAthView::OnLbnDblclkTroopList()
{
	// TODO: 在此添加控件通知处理程序代码
	int sel = lbox_troop.GetCurSel();
	if(sel < 0) return;
	Troop tro;
	tro._match.ID = matchID;
	tro.ID = lbox_troop.GetItemData(sel);
	lbox_troop.GetText(sel, tro.Name);
	Dialog_TrName trn(&tro, TRUE);
	if(trn.DoModal() == IDOK){
		lbox_troop.DeleteString(sel);
		lbox_troop.InsertString(sel, tro.Name);
		lbox_troop.SetItemData(sel, tro.ID);
	}
}
示例#4
0
//----------------------------------------------------------------------------
BspNode* BspNodes::CreateNode (const Vector2f& v0, const Vector2f& v1,
                               VertexColor3Effect* effect, const Float3& color)
{
	// Create the model-space separating plane.
	Vector2f dir = v1 - v0;
	AVector normal(dir[1], -dir[0], 0.0f);
	normal.Normalize();
	float constant = normal[0]*v0[0] + normal[1]*v0[1];
	HPlane modelPlane(normal, constant);

	// Create the BSP node.
	BspNode* bsp = new0 BspNode(modelPlane);

	VertexFormat* vformat = VertexFormat::Create(2,
	                        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
	                        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);

	// Create the rectangle representation of the model plane and set the
	// vertex colors to the specified color.
	float xExtent = 0.5f*dir.Length();
	float yExtent = 0.125f;
	TriMesh* rect = StandardMesh(vformat).Rectangle(2, 2, xExtent, yExtent);
	VertexBufferAccessor vba(rect);
	for (int i = 0; i < 4; ++i)
	{
		vba.Color<Float3>(0, i) = color;
	}
	rect->SetEffectInstance(effect->CreateInstance());

	// Set the position and orientation for the world-space plane.
	APoint trn(0.5f*(v0[0] + v1[0]), 0.5f*(v0[1] + v1[1]), yExtent + 0.001f);
	HMatrix zRotate(AVector::UNIT_Z, Mathf::ATan2(dir.Y(),dir.X()));
	HMatrix xRotate(AVector::UNIT_X, Mathf::HALF_PI);
	HMatrix rotate = zRotate*xRotate;
	rect->LocalTransform.SetTranslate(trn);
	rect->LocalTransform.SetRotate(rotate);

	bsp->AttachCoplanarChild(rect);
	return bsp;
}
/* Intersection area */
  template<class K> typename K::FT intersection_area_two_slabs(const Rectangle_2<K>& a, const Rectangle_2<K> &b) {
    typedef typename K::Vector_2 Vector_2;
    typedef typename K::Line_2 Line_2;
    typedef typename K::Point_2 Point_2;
    typedef typename K::FT FT;
    Origin O;
    if(a.is_degenerate() || b.is_degenerate()) return 0;
    std::vector<Vector_2> v;
    std::vector<Line_2> l;
    for(unsigned int i=0; i<4; ++i)    { v.push_back(b[i]-O); l.push_back(b.line(i)); }
    const Vector_2& n = a.normal();
    FT r = a.ratio();
    FT n2 = n.squared_length();
    FT rn2 = r*r*n2;
    Vector_2 vc(a.center()-O);
    Vector_2 trn(-r*n.y(),r*n.x());
    FT ctrn = vc*trn;
    FT cn = vc*n;

    Vector_2 ln[] = {  n, trn };
    FT lc[] = { cn+n2, ctrn+rn2, cn-n2, ctrn-rn2 };

 // basically it is the iterative intersection of the convex polygon initialized with b
 // with the 2 slabs line0/line2 and line1/line3.
    for(unsigned int i=0; i<2; ++i)    {
        int begin0=-1, end0=-1;
        int begin1=-1, end1=-1;
        unsigned int n=v.size();
        for(unsigned int j=0; j<n; ++j) {
            FT dot = ln[i]*v[j];
            if( dot>lc[i]) {
                if(end0==-1 && begin0!=-1) end0=j;
                if(begin1<=end1) begin1=j;
            } else {
                if(begin0<=end0) begin0=j;
                if(dot<lc[i+2]) {
                    if(end1==-1 && begin1!=-1) end1=j;
                } else {
                    if(begin1<=end1) begin1=j;
                }
            }
        }
        if(begin0==-1 || begin1==-1 ) return 0; // outside the slab
        if(end0  ==-1) {
            if(begin0!=0) end0=0;
            else begin0=begin1;
        }
        if(end1  ==-1) {
            if(begin1!=0) end1=0;
            else {
                if(end0==-1) continue; // inside the slab
                begin1=begin0;
            }
        }

        std::vector<Vector_2> w;
        std::vector<Line_2> m;
        if(end0!=-1) {  // cut outside line(i+1)
            for(int j=begin1; j!=end0; j=(j+1)%n) {
                 w.push_back(v[j]);
                 m.push_back(l[j]);
            }
            Point_2 inter(O);
            Line_2 li(ln[i].x(),ln[i].y(),-lc[i]);
            intersection(l[(end0+n-1)%n],li).assign(inter);
            w.push_back(inter-O);
            m.push_back(li);
            m.push_back(l[(begin0+n-1)%n]);
            intersection(li,m.back()).assign(inter);
            w.push_back(inter-O);
        }
        if(end1!=-1) { // cut outside line(i+3)
            for(int j=begin0; j!=end1; j=(j+1)%n) {
                w.push_back(v[j]);
                m.push_back(l[j]);
            }
            Point_2 inter(O);
            Line_2 li(ln[i].x(),ln[i].y(),-lc[i+2]);
            intersection(l[(end1+n-1)%n],li).assign(inter);
            w.push_back(inter-O);
            m.push_back(li);
            m.push_back(l[(begin1+n-1)%n]);
            intersection(li,m.back()).assign(inter);
            w.push_back(inter-O);
        }
        std::swap(v,w);
        std::swap(l,m);
    }
    std::vector<Point_2> p;
    for(unsigned int i=0; i<v.size(); ++i)    { p.push_back(O+v[i]); }
    FT area;
    area_2(p.begin(),p.end(),area);
    return abs(area);
  }