当前位置: 首页>>代码示例>>C++>>正文


C++ ofPolyline::getCentroid2D方法代码示例

本文整理汇总了C++中ofPolyline::getCentroid2D方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPolyline::getCentroid2D方法的具体用法?C++ ofPolyline::getCentroid2D怎么用?C++ ofPolyline::getCentroid2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofPolyline的用法示例。


在下文中一共展示了ofPolyline::getCentroid2D方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkIfHole

int Shadows::checkIfHole(ofPolyline& _contourLine){
    int rta = -1;
    
    //  Calculate the centroid
    //
    ofPoint centroid = _contourLine.getCentroid2D();
    
    //  Check if it fits inside another another non-active blob.
    //
    for( map<int,AnimatedShadow*>::reverse_iterator rit = hands.rbegin(); rit != hands.rend(); rit++ ){
        if ( !(rit->second->bActive) ) {
            if ( rit->second->isInside( centroid ) ){
                rta = rit->second->getId();
            }
        }
    }
    
    return rta;
}
开发者ID:patriciogonzalezvivo,项目名称:mesaDelTiempo,代码行数:19,代码来源:Shadows.cpp

示例2: draw


//.........这里部分代码省略.........
    ofNoFill();
    ofSetLineWidth(2);
    
    ofSetColor(255, 0, 0);
    ofCircle(nearestPoint, 5);
    
    ofSetColor(255, 255, 0);
    ofCircle(nearestDataPoint, 7);
    
    // interpolating on indices
    {
        ofPoint p = poly.getPointAtIndexInterpolated(sinIndex);

        ofSetColor(0, 255, 255);
        ofCircle(p, 10);
        
        ofSetColor(255, 0, 0);
        ofLine(p, p + poly.getTangentAtIndexInterpolated(sinIndex) * 60);
        
        ofSetColor(0, 255, 0);
        ofLine(p, p + poly.getNormalAtIndexInterpolated(sinIndex) * 60);
        
        ofSetColor(0, 128, 255);
        ofLine(p, p + poly.getRotationAtIndexInterpolated(sinIndex) * 60);
    }
    
    // interpolating on length percentages
    {
        ofPoint p = poly.getPointAtIndexInterpolated(sinIndexLength);
        
        ofSetColor(255, 0, 255);
        ofCircle(p, 10);
        
        ofSetColor(255, 0, 0);
        ofLine(p, p + poly.getTangentAtIndexInterpolated(sinIndexLength) * 60);
        
        ofSetColor(0, 255, 0);
        ofLine(p, p + poly.getNormalAtIndexInterpolated(sinIndexLength) * 60);
        
        ofSetColor(0, 128, 255);
        ofLine(p, p + poly.getRotationAtIndexInterpolated(sinIndexLength) * 60);
    }
    
    
    ofSetColor(255, 255, 255);
    ofCircle(poly.getCentroid2D(), 20);
    
    ofPopMatrix();
    
    
    stringstream s;
    s << "Number of points: " << poly.size() << endl;
    s << "totalLength: " << totalLength << endl;
    
    s << endl;
    s << "nearestIndex: " << nearestIndex << endl;
    s << "nearestPoint: " << nearestPoint << endl;
    s << "nearestDataPoint: " << nearestDataPoint << endl;
    
    s << endl;
    s << "lengthAtIndex: " << lengthAtIndex << endl;
    s << "pointAtIndex: " << pointAtIndex << endl;
    
    s << endl;
    s << "pointAtLength: " << pointAtLength << endl;
    s << "pointAtPercent: " << pointAtPercent << endl;
    
    s << endl;
    s << "indexAtLength: " << indexAtLength << endl;
    
    
    s << endl;
    s << "sinTime: " << sinTime << endl;
    s << "sinIndex: " << sinIndex << endl;
    s << "sinIndexLength: " << sinIndexLength << endl;
    
    s << endl;
    s << "lengthAtIndexSin: " << lengthAtIndexSin << endl;
    s << "pointAtIndexSin: " << pointAtIndexSin << endl;
    s << "pointAtPercentSin: " << pointAtPercentSin << endl;
    
    s << endl;
    s << "angleAtIndex: " << angleAtIndex << endl;
    s << "angleAtIndexSin: " << angleAtIndexSin << endl;
    
    s << endl;
    s << "rotAtIndex: " << rotAtIndex << endl;
    s << "rotAtIndexSin: " << rotAtIndexSin << endl;
    
    s << endl;
    s << "rotMagAtIndex: " << rotMagAtIndex << endl;
    s << "rotMagAtIndexSin: " << rotMagAtIndexSin << endl;
    
    s << endl;
    s << "normalAtIndex: " << normalAtIndex << endl;
    s << "normalAtIndexSin: " << normalAtIndexSin << endl;
    
    ofSetColor(255);
    ofDrawBitmapString(s.str(), 10, 30);
}
开发者ID:2bbb,项目名称:openFrameworks,代码行数:101,代码来源:ofApp.cpp

示例3: kill

void LetterParticle::kill()
{
    BaseParticle::kill(); // call the super /parent class!

    std::vector<ofTTFCharacter> paths = font.getStringAsPoints(text);

    std::vector<ofTTFCharacter>::iterator pathsIter = paths.begin();

    while(pathsIter != paths.end())
    {
std:
        vector<ofPolyline> polylines = (*pathsIter).getOutline();

        std::vector<ofPolyline>::const_iterator polyIter = polylines.begin();

        while(polyIter != polylines.end())
        {
            if((*polyIter).size() > 0)
            {
                ofPolyline resampled = (*polyIter).getResampledBySpacing(2); // this number tells us how many particles

                if(resampled.size() > 0)
                {
                    const ofPolyline poly = resampled.getVertices();

                    auto centroid = poly.getCentroid2D();  // find the middle

                    // create a particle group
                    std::shared_ptr<BaseParticleGroup> particleGroup(new BaseParticleGroup());

                    // add particles to the particle system AND to the particle group
                    for(int i = 0; i < poly.size(); ++i)
                    {
                        std::shared_ptr<ParticleGroupMember> particle(new ParticleGroupMember());

                        // this is how we get the particle to move away from the center
                        // of the group (as calculated by the centroid)
                        auto newVelocity = glm::normalize(poly[i] - centroid) * ofRandom(.5,2);

                        particle->position = position + poly[i];
                        particle->velocity = velocity + newVelocity;
                        particle->acceleration = acceleration;
                        particle->maxAge = ofRandom(50,100);

                        particle->particleSystem = particleSystem; // make a link back to the particle system

                        particleSystem->addParticle(particle);

                        particleGroup->members.push_back(particle);
                    }

                    // add the particle group to the particle system
                    particleSystem->addParticleGroup(particleGroup);
                }
            }

            ++polyIter;
        }

        ++pathsIter;
    }
}
开发者ID:SAIC-ATS,项目名称:ARTTECH-5010,代码行数:62,代码来源:LetterParticle.cpp


注:本文中的ofPolyline::getCentroid2D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。