本文整理汇总了C++中CCircle类的典型用法代码示例。如果您正苦于以下问题:C++ CCircle类的具体用法?C++ CCircle怎么用?C++ CCircle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCircle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool CBox2D::Intersects( const CCircle& Circle ) const
{
CFVec2 vOffset = (Circle.Centre() - m_vCentre);
vOffset.SetAbs();
vOffset -= m_vExtents;
return ( vOffset.X() < Circle.Radius() && vOffset.Y() < Circle.Radius() );
}
示例2: Update
void CMole::Update(FLOAT32 _fTimeDelta)
{
m_pMoleAgent->Update(_fTimeDelta);
// Turn.
m_fHeading += m_pMoleAgent->GetRotationalSpeed() * _fTimeDelta;
// Update position.
CFVec2 vHeading;
vHeading.SetToRotationZ(m_fHeading);
CFVec2 vVelocity = vHeading * m_pMoleAgent->GetSpeed() * _fTimeDelta;
m_vPosition += vVelocity;
if ((m_vDestination - m_vPosition).Magnitude() < fMOLE_RADIUS)
{
Messages::send(DESTINATION_REACHED_EVENT, this);
}
// finally check if that pesky rodent got caught:
CCircle Bounds;
Bounds.Initialise( m_vPosition, fMOLE_RADIUS );
if ( CMMMContext::GetInstance().GetSquirrel()->Intersects( Bounds ) )
{
CMMMContext::GetInstance().GetSquirrel()->LoseLife();
Messages::send(DESTINATION_REACHED_EVENT, this);
}
}
示例3:
void
CMole::DrawTargetAcorn(const CAcorn* _kpAcorn) const
{
GDE::CRenderer* pRenderer = CMMMContext::GetInstance().GetRenderer();
GDE::SVertex FirstLine[2];
FirstLine[0].m_uColour = 0xFFFFFF00;
FirstLine[1].m_uColour = 0xFFFFFF00;
FirstLine[0].m_fX = m_vPosition.X();
FirstLine[0].m_fY = m_vPosition.Y();
FirstLine[0].m_fZ = 0.0f;
FirstLine[1].m_fX = _kpAcorn->GetPosition().X();
FirstLine[1].m_fY = _kpAcorn->GetPosition().Y();
FirstLine[1].m_fZ = 0.0f;
pRenderer->DrawPrimitives(GDE::PT_LineList, 1, FirstLine);
CCircle AcornCircle;
AcornCircle.Initialise(_kpAcorn->GetPosition(), 14.0f);
AcornCircle.Draw(0xAAFFFF00, true);
}
示例4:
void CSquirrel::LoseLife( void )
{
if ( m_uNumLives )
{
// do not lose a life if over a tunnel:
CTunnel* pTunnels;
UINT32 uNumTunnels;
CMMMContext::GetInstance().GetTunnels( pTunnels, uNumTunnels );
CCircle Bounds;
Bounds.Initialise( m_vPosition, m_fRadius );
for ( UINT32 i=0; i<uNumTunnels; i++ )
{
if ( pTunnels[i].Intersects( Bounds ) )
{
return; // immune, over a tunnel!
}
}
for ( UINT32 i=0; i<m_uNumAcorns; i++ )
{
m_ppAcorns[i]->SetState( CAcorn::ES_Available );
}
m_uNumAcorns = 0;
m_uNumLives--;
if ( m_uNumLives )
{
Spawn();
} else
{
CMMMContext::GetInstance().NotifySquirrelDeath();
}
}
}
示例5: VSquareSize
bool suken::CCollisionManager::CollisionCircle(CCircle &A , CCircle &B)
{
// 前位置及び到達位置におけるパーティクル間のベクトルを算出
suken::Vector2D C0 = B.center.prePosition - A.center.prePosition;
suken::Vector2D C1 = B.center.position - A.center.position;
suken::Vector2D D = C1 - C0;
// 衝突判定用の2次関数係数の算出
float P = VSquareSize( D );
// 同じ方向に移動
if(P==0){
return false;
}
float Q = VDot( C0, D );
float R = VSquareSize( C0 );
// 距離
float r = A.radius + B.radius;
// 衝突判定式
float Judge = Q*Q - P*(R-r*r);
if( Judge < 0 ){
// 衝突していない
return false;
}
// 衝突時間の算出
float t_plus = (-Q + sqrt( Judge ) ) / P;
float t_minus = ( -Q - sqrt( Judge ) ) / P;
// 衝突位置の決定
suken::Vector2D pOut_colli_A = A.center.prePosition + ( A.center.position - A.center.prePosition) * t_minus;
suken::Vector2D pOut_colli_B = B.center.prePosition + ( B.center.position - B.center.prePosition) * t_minus;
// 衝突時間の決定(t_minus側が常に最初の衝突)
float pOut_t0 = t_minus;
float pOut_t1 = t_plus;
// 時間内衝突できるか?
// t_minusが1より大きいと届かず衝突していない
// t_plus、t_minusが両方ともマイナスだと反対方向なので衝突しない
if( (t_minus > 1) || (t_minus < 0 && t_plus < 0) ){
return false;
}
//衝突処理
A.SetCollisionState(true);
B.SetCollisionState(true);
A.OnCollisionFunc();
B.OnCollisionFunc();
#ifdef DEBUG_DRAW
DxLib::DrawCircle((int)(A.center.position.x +0.5), (int)(A.center.position.y+0.5) , (int)(A.radius+0.5) ,GREEN ,true );
DxLib::DrawCircle((int)(B.center.position.x +0.5), (int)(B.center.position.y+0.5) , (int)(B.radius+0.5) ,GREEN ,true );
#endif
CollisionCircleCalc(A ,B ,( 1.0f - abs(pOut_t0) ) / 60.0f );
return true; // 衝突報告
}
示例6: checkIfCircle
bool CMinSquareRecognizing::checkIfCircle( CCircle& circle, std::vector< cv::Point >& contour )
{
if( circle.GetAccuracy() < accuracyThreshold && circle.GetRadius() > 50 ) {
return true;
}
return false;
}
示例7: METHOD_ENTRY
////////////////////////////////////////////////////////////////////////////////
///
/// \brief Clones circle
///
/// \return Pointer to cloned circle
///
////////////////////////////////////////////////////////////////////////////////
CCircle* CCircle::clone() const
{
METHOD_ENTRY("CCircle::clone");
CCircle* pClone = new CCircle();
MEM_ALLOC("IShape")
pClone->copy(this);
return pClone;
}
示例8: main
int main () {
CPolygon* polygons[4];
polygons[0] = new CRectangle(20,30);
polygons[1] = new CTriangle(20,25);
polygons[2] = new CCircle(25,25);
polygons[3] = new CSquare(18,18);
for(int i = 0; i < 4; i++)
{
CTriangle* trin = dynamic_cast <CTriangle *> (polygons[i]);
if (trin != 0)
{
trin->set_values(10, 10);
assert(trin->area() != 50);
}
CCircle* circ = dynamic_cast <CCircle *> (polygons[i]);
if (circ != 0)
{
circ->set_values(10, 10);
assert(circ->area() != 78);
}
CSquare* sqrr = dynamic_cast <CSquare *> (polygons[i]);
if (sqrr != 0)
{
sqrr->set_values(10, 10);
assert(sqrr->area() != 100);
}
CRectangle* rect = dynamic_cast <CRectangle *> (polygons[i]);
if (rect != 0)
{
rect->set_values(10, 20);
assert(rect->area() != 200);
}
}
/*
*/
return 0;
}
示例9: Draw
/**
* Draw the board.
* Should be properly decoupled, oops.
*/
void CGameBoard::Draw( void )
{
CCircle Circle;
UINT32 colCurrent;
bool bHighlighted = false;
for ( int y=0; y<m_iHeight; y++ )
{
for ( int x=0; x<m_iWidth; x++ )
{
switch( GetBoardPos( x, y ) )
{
default:
case BOARD_ERROR:
assert_now( "Error with board" );
case EMPTY:
colCurrent = colEMPTY;
break;
case PLAYER1:
colCurrent = colPLAYER_ONE;
break;
case PLAYER2:
colCurrent = colPLAYER_TWO;
break;
}
const FLOAT32 fXPos = fPIECE_RADIUS+fPIECE_SPACING+(fPIECE_SPACING + fPIECE_RADIUS*2)*x;
const FLOAT32 fYPos = fPIECE_RADIUS+fPIECE_SPACING+(fPIECE_SPACING + fPIECE_RADIUS*2)*y;
Circle.Initialise( SFVec2( fXPos, fYPos ), fPIECE_RADIUS );
CConnect4Context::GetInstance().DrawFilledCircle( Circle, colCurrent );
if ( false == bHighlighted )
{
if ( m_iColumnHighlighted == x )
{
CConnect4Context::GetInstance().DrawCircle( Circle, colHIGHLIGHT );
}
}
}
}
}
示例10: Draw
void CMole::Draw( void )
{
m_pSprite->RenderEx( m_vPosition.X(), m_vPosition.Y(), m_fHeading, 1.0f, 1.0f );
if ( m_bHighlighted )
{
CCircle Bounds;
Bounds.Initialise( m_vPosition, fMOLE_RADIUS );
CMMMContext::GetInstance().DrawCircle( Bounds, 0xFFFF0000 );
}
#ifndef _EDITOR
if (CMMMContext::GetInstance().IsDrawingMoleState())
{
CCircle radiusCircle;
radiusCircle.Initialise(m_vPosition, fMOLE_RADIUS);
CMMMContext::GetInstance().DrawCircle(radiusCircle, 0xFF00FF00);
CCircle destinationCircle;
destinationCircle.Initialise(m_vDestination, 5.0f );
CMMMContext::GetInstance().DrawCircle(destinationCircle, 0xFF8800FF);
}
m_pMoleAgent->Draw();
#endif
}
示例11: main
int main() {
CCircle circle;
double input_radius;
cout << "CS138 C++ Final Project" << endl;
cout << "Cameron Carroll --- Fall 2012" << endl;
cout << endl;
cout << "Please enter a circle radius: ";
cin >> input_radius;
circle.setRadius(input_radius);
cout << "Your circle radius is: " << circle.getRadius() << endl;
cout << "Area: " << circle.getArea() << endl;
cout << "Diameter: " << circle.getDiameter() << endl;
cout << "Circumference: " << circle.getCircumference() << endl;
}
示例12: Draw
void CPathFindingAgent::Draw() const
{
if (m_path.size() > 1)
{
for (UINT32 uiIndex = 0; uiIndex < m_path.size() - 1; uiIndex++)
{
CCircle waypointCircle;
waypointCircle.Initialise(m_path[uiIndex]->GetPosition(), 5.0f);
CMMMContext::GetInstance().DrawCircle(waypointCircle, 0xFFBFBD2B);
CMMMContext::GetInstance().DrawLine(m_path[uiIndex]->GetPosition(), m_path[uiIndex + 1]->GetPosition(), 0xFFBFBD2B);
}
CCircle waypointCircle;
waypointCircle.Initialise(m_path.back()->GetPosition(), 5.0f);
CMMMContext::GetInstance().DrawCircle(waypointCircle, 0xFFBFBD2B);
CCircle destinationCircle;
destinationCircle.Initialise(m_vDestination, fGRID_SIZE);
CMMMContext::GetInstance().DrawCircle(destinationCircle, 0xFFBFBD2B);
}
}
示例13: Intersects
bool CSquirrel::Intersects( const CCircle& Circle ) const
{
CCircle Bounds;
Bounds.Initialise( m_vPosition, m_fRadius );
return Circle.Overlaps( Bounds );
}
示例14: Intersects
bool CMole::Intersects( const CBox2D& Box ) const
{
CCircle Bounds;
Bounds.Initialise( m_vPosition, fMOLE_RADIUS );
return Box.Intersects( Bounds );
}
示例15: SFVec2
void CSquirrel::Update( FLOAT32 fTimeDelta )
{
if ( 0 == m_uNumLives )
{
return;
}
const static CFVec2 s_vMoveOffsets[] =
{
SFVec2( -1.0f, 0.0f ), //"Left",
SFVec2( 1.0f, 0.0f ), //"Right",
SFVec2( 0.0f, -1.0f ), //"Up",
SFVec2( 0.0f, 1.0f ), //"Down"
};
_COMPILE_ASSERT( _ARRAY_SIZE( s_vMoveOffsets ) == EMove_COUNT );
CFVec2 vMove = SFVec2( 0.0f, 0.0f );
for ( UINT32 i=0; i< EMove_COUNT; i++ )
{
if ( m_Movements[i].m_bValue )
{
vMove += s_vMoveOffsets[i];
}
}
// great, now we have the movement direction.
if ( vMove.SquareMagnitude() != 0.0f )
{
m_fDistTimeMoving += fTimeDelta;
vMove.Normalise();
FLOAT32 fStep = 1.0f;
CFVec2 vTestedMove = vMove * fTimeDelta * m_fSpeed * fStep;
// now check the target position - is it embedded in any walls?
CCircle TargetBounds;
while ( fStep > 0.0f )
{
TargetBounds.Initialise( m_vPosition + vTestedMove, m_fRadius );
if ( false == CMMMContext::GetInstance().CircleIntersectsGeometry( TargetBounds ) )
{
break; // found a valid, allowable movement.
}
fStep -= 0.2f;
vTestedMove = vMove * fTimeDelta * m_fSpeed * fStep;
}
// now update to the new position
m_vPosition += vTestedMove;
// finally what happens at the new position
// is an acorn collected?
if ( m_uNumAcorns != m_uMaxAcorns )
{
CAcorn* pLevelAcorns;
UINT32 uNumLevelAcorns;
CMMMContext::GetInstance().GetAcorns( pLevelAcorns, uNumLevelAcorns );
for ( UINT32 i=0; i<uNumLevelAcorns; i++ )
{
if ( pLevelAcorns[i].GetState() == CAcorn::ES_Available )
{
if ( pLevelAcorns[i].Intersects( TargetBounds ) )
{
pLevelAcorns[i].SetState( CAcorn::ES_Carried );
m_ppAcorns[m_uNumAcorns++] = pLevelAcorns+i;
if ( m_uNumAcorns == m_uMaxAcorns )
{
break; // cannont collect any more!
}
}
}
}
}
// is a tunnel reached?
if ( m_uNumAcorns > 0 )
{
CTunnel* pTunnels;
UINT32 uNumTunnels;
CMMMContext::GetInstance().GetTunnels( pTunnels, uNumTunnels );
for ( UINT32 i=0; i<uNumTunnels; i++ )
{
if ( pTunnels[i].Intersects( TargetBounds ) )
{
// reached the tunnel.
for ( UINT32 i=0; i<m_uNumAcorns; i++ )
{
m_ppAcorns[i]->SetState( CAcorn::ES_Collected );
m_uScore++;
}
m_uNumAcorns = 0;
}
}
}
}
m_fTimeToDisturbance -= fTimeDelta;
if ( m_fTimeToDisturbance <= 0.0f )
{
// schedule the next disturbance.
m_fTimeToDisturbance = FLOAT32(rand())/FLOAT32(RAND_MAX);
m_fTimeToDisturbance *= m_fMaxDistSep-m_fMinDistSep;
m_fTimeToDisturbance += m_fMinDistSep;
//.........这里部分代码省略.........