本文整理匯總了C++中Area函數的典型用法代碼示例。如果您正苦於以下問題:C++ Area函數的具體用法?C++ Area怎麽用?C++ Area使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Area函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ADDTOCALLSTACK
//.........這裏部分代碼省略.........
{
g_Log.EventDebug("Failed to get non-parent reference (multi) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pMultiItem->GetDispID(),pMultiItem->m_dx+pItem->GetTopPoint().m_x,pMultiItem->m_dy+pItem->GetTopPoint().m_y,pMultiItem->m_dz+pItem->GetTopPoint().m_z);
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
}
else
{
zHeight = pDupeDef->GetHeight();
wBlockThis = ( pDupeDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove - CAN flags cannot be inherited from the parent item due to bad script pack...
}
}
}
else if ( pMultiItem->GetDispID() )
CItemBase::GetItemTiledataFlags(wBlockThis,pMultiItem->GetDispID());
block.CheckTile_Item( wBlockThis, z, zHeight, pMultiItem->GetDispID() + TERRAIN_QTY );
}
}
}
}
}
}
pItemDef = NULL;
pDupeDef = NULL;
pItem = NULL;
wBlockThis = 0;
x2 = y2 = iQty = 0;
zHeight = 0;
z = 0;
// Any dynamic items here ?
// NOTE: This could just be an item that an NPC could just move ?
CWorldSearch Area( pt );
for (;;)
{
pItem = Area.GetItem();
if ( !pItem )
break;
z = pItem->GetTopZ();
if ( !block.IsUsableZ( z, block.m_zHeight ) )
continue;
// Invis items should not block ???
pItemDef = CItemBase::FindItemBase( pItem->GetDispID() );
if ( pItemDef )
{
if ( pItemDef->GetDispID() == pItem->GetDispID() )//parent item
{
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove
}
else //non-parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pItem->GetDispID()));
if ( ! pDupeDef )
{
g_Log.EventDebug("Failed to get non-parent reference (dynamic) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pItem->GetDispID(),pItem->GetTopPoint().m_x,pItem->GetTopPoint().m_y,pItem->GetTopPoint().m_z);
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
}
else
{
示例2: Process
bool HSTriangular::Process( const HSVector2dV &contour,HSVector2dV &outResult )
{
/* allocate and initialize list of Vertices in polygon */
int n = contour.size();
if ( n < 3 ) return false;
int *V = new int[n];
/* we want a counter-clockwise polygon in V */
if ( 0.0f < Area(contour) )
for (int v=0; v<n; v++) V[v] = v;
else
for(int v=0; v<n; v++) V[v] = (n-1)-v;
int nv = n;
/* remove nv-2 Vertices, creating 1 triangle every time */
int count = 2*nv; /* error detection */
for(int m=0, v=nv-1; nv>2; )
{
/* if we loop, it is probably a non-simple polygon */
if (0 >= (count--))
{
//** Triangulate: ERROR - probable bad polygon!
return false;
}
/* three consecutive vertices in current polygon, <u,v,w> */
int u = v ; if (nv <= u) u = 0; /* previous */
v = u+1; if (nv <= v) v = 0; /* new v */
int w = v+1; if (nv <= w) w = 0; /* next */
if ( Snip(contour,u,v,w,nv,V) )
{
int a,b,c,s,t;
/* true names of the vertices */
a = V[u]; b = V[v]; c = V[w];
/* output Triangle */
outResult.push_back( contour[a] );
outResult.push_back( contour[b] );
outResult.push_back( contour[c] );
m++;
/* remove v from remaining polygon */
for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; nv--;
/* resest error detection counter */
count = 2*nv;
}
}
delete V;
return true;
}
示例3: Area
Area Area::getOffset( const Vec2i &offset ) const
{
return Area( x1 + offset.x, y1 + offset.y, x2 + offset.x, y2 + offset.y );
}
示例4: Area
Area BoundProcessor::resultArea() const
{
return Area();
}
示例5: InRadius
/// radius of its inscribed circle
double Triangle::InRadius() const
{
// r = 2*area/perimeter
return 2*Area()/Perimeter();
}
示例6: InitTriangles
int
InitTriangles(XParms xp, Parms p, int reps)
{
int i, j, numPoints;
int rows;
int x, y;
int size, iradius;
double phi, phiinc, radius, delta, phi2, area, aarea;
XPoint *curPoint;
pgc = xp->fggc;
size = p->special;
phi = 0.0;
delta = 2.0 * PI / ((double) NUM_POINTS);
if (xp->version == VERSION1_2) {
radius = ((double) size) * sqrt(3.0)/2.0;
phiinc = delta/10.0;
} else {
/* Version 1.2's radius computation was completely bogus, and resulted
in triangles with sides about 50% longer than advertised. However,
this inadvertently resulted in triangles with areas just a little bit
smaller than the triangle that covers size^2 pixels, which would
make the area directly comparable to 10x10 rectangles and 10x10
trapezoids. So here's the new computation so -triangleN has the same
area as -rectN.
*/
radius = ((double) size) * sqrt(sqrt(16.0/27.0));
phiinc = 1.75*PI / ((double) p->objects);
}
iradius = (int) (radius + 0.5);
numPoints = (p->objects) * NUM_POINTS;
points = (XPoint *)malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = iradius;
y = iradius;
rows = 0;
aarea = 0.0;
for (i = 0; i != p->objects; i++) {
for (j = 0; j != NUM_POINTS; j++) {
phi2 = phi + ((double) j) * delta;
curPoint->x = (int) ((double)x + (radius * cos(phi2)) + 0.5);
curPoint->y = (int) ((double)y + (radius * sin(phi2)) + 0.5);
curPoint++;
}
area = Area(curPoint[-1], curPoint[-2], curPoint[-3]);
aarea += area;
/* printf("%6.1lf %6.1lf %6.1lf %6.1lf\n",
Distance(curPoint[-1], curPoint[-2]),
Distance(curPoint[-1], curPoint[-3]),
Distance(curPoint[-2], curPoint[-3]),
area);
*/
phi += phiinc;
y += 2 * iradius;
rows++;
if (y + iradius > HEIGHT || rows == MAXROWS) {
rows = 0;
y = iradius;
x += 2 * iradius;
if (x + iradius > WIDTH) {
x = iradius;
}
}
}
/* printf("Average area = %6.2lf\n", aarea/p->objects); */
SetFillStyle(xp, p);
return reps;
}
示例7: Area
bool Polygon::IsDegenerate(float epsilon) const
{
return p.size() < 3 || Area() <= epsilon;
}
示例8: area_tet
double area_tet(tetrahedron T)
{
double area = 0;
for(int i=0; i<4; i++) area = area + Area(Side(T,i));
return area;
}
示例9: SCOPE_CYCLE_COUNTER
void USceneCapturer::CaptureComponent( int32 CurrentHorizontalStep, int32 CurrentVerticalStep, FString Folder, USceneCaptureComponent2D* CaptureComponent, TArray<FColor>& Atlas )
{
TArray<FColor> SurfaceData;
{
SCOPE_CYCLE_COUNTER( STAT_SPReadStrip );
FTextureRenderTargetResource* RenderTarget = CaptureComponent->TextureTarget->GameThread_GetRenderTargetResource();
//TODO: ikrimae: Might need to validate that this divides evenly. Might not matter
int32 CenterX = CaptureWidth / 2;
int32 CenterY = CaptureHeight / 2;
SurfaceData.AddUninitialized( StripWidth * StripHeight );
// Read pixels
FIntRect Area( CenterX - ( StripWidth / 2 ), CenterY - ( StripHeight / 2 ), CenterX + ( StripWidth / 2 ), CenterY + ( StripHeight / 2) );
auto readSurfaceDataFlags = FReadSurfaceDataFlags();
readSurfaceDataFlags.SetLinearToGamma(false);
RenderTarget->ReadPixelsPtr( SurfaceData.GetData(), readSurfaceDataFlags, Area );
}
// Copy off strip to atlas texture
CopyToUnprojAtlas( CurrentHorizontalStep, CurrentVerticalStep, Atlas, SurfaceData );
if( FStereoPanoramaManager::GenerateDebugImages->GetInt() != 0 )
{
SCOPE_CYCLE_COUNTER( STAT_SPSavePNG );
// Generate name
FString TickString = FString::Printf( TEXT( "_%05d_%04d_%04d" ), CurrentFrameCount, CurrentHorizontalStep, CurrentVerticalStep );
FString CaptureName = OutputDir / Timestamp / Folder / TickString + TEXT( ".png" );
UE_LOG( LogStereoPanorama, Log, TEXT( "Writing snapshot: %s" ), *CaptureName );
// Write out PNG
if (FStereoPanoramaManager::GenerateDebugImages->GetInt() == 2)
{
//Read Whole Capture Buffer
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper( EImageFormat::PNG );
TArray<FColor> SurfaceDataWhole;
SurfaceDataWhole.AddUninitialized(CaptureWidth * CaptureHeight);
// Read pixels
FTextureRenderTargetResource* RenderTarget = CaptureComponent->TextureTarget->GameThread_GetRenderTargetResource();
RenderTarget->ReadPixelsPtr(SurfaceDataWhole.GetData(), FReadSurfaceDataFlags());
// Force alpha value
if (bForceAlpha)
{
for (FColor& Color : SurfaceDataWhole)
{
Color.A = 255;
}
}
ImageWrapper->SetRaw(SurfaceDataWhole.GetData(), SurfaceDataWhole.GetAllocatedSize(), CaptureWidth, CaptureHeight, ERGBFormat::BGRA, 8);
const TArray<uint8>& PNGData = ImageWrapper->GetCompressed(100);
FFileHelper::SaveArrayToFile(PNGData, *CaptureName);
ImageWrapper.Reset();
}
else
{
if (bForceAlpha)
{
for (FColor& Color : SurfaceData)
{
Color.A = 255;
}
}
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
ImageWrapper->SetRaw(SurfaceData.GetData(), SurfaceData.GetAllocatedSize(), StripWidth, StripHeight, ERGBFormat::BGRA, 8);
const TArray<uint8>& PNGData = ImageWrapper->GetCompressed(100);
FFileHelper::SaveArrayToFile( PNGData, *CaptureName );
ImageWrapper.Reset();
}
}
}
示例10: Area
void PlayerShip::draw()
{
cinder::gl::draw( shipTexture, Area(Vec2f(SIZE*(floor(tween)+FRAMENO), 0), Vec2f(SIZE*(floor(tween)+FRAMENO) + SIZE, SIZE)), Rectf(mMouseLoc - Vec2f(SIZE/2,0), mMouseLoc + Vec2f(SIZE/2,SIZE)) );
pg.draw();
}
示例11: ShowCircle
void ShowCircle( )
{
ShowPoint( ); // F
cout<<" Radius: "<<r<<'\t';
cout<<"Area: "<<Area( )<<endl; //G
}
示例12: Circumference
string Circle::ToString() const {
stringstream circleStream; // Start reading input into a stringstream
// EDIT: Added the ToString() function of the Shape class to display the ID as well.
circleStream << Shape::ToString() << ": Circle with Center at " << centre.ToString() << " and Radius = "
<< radius << "\nCircumference: " << Circumference() << "\nArea: " << Area(); // Add string to circleStream
return(circleStream.str()); // Output the string using the str() member function
}
示例13: logTraceInWith2Arguments
int peanoclaw::Area::getAreasOverlappedByRemoteGhostlayers(
const tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int>& adjacentRanks,
tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int> overlapOfRemoteGhostlayers,
const tarch::la::Vector<DIMENSIONS, int>& subdivisionFactor,
int rank,
Area areas[THREE_POWER_D_MINUS_ONE]
) {
logTraceInWith2Arguments("getAreasOverlappedByRemoteGhostlayers(...)", adjacentRanks, overlapOfRemoteGhostlayers);
int numberOfAreas = 0;
bool oneAreaCoversCompleteSubgrid = false;
for(int dimensionality = 0; dimensionality < DIMENSIONS; dimensionality++) {
int numberOfManifolds = getNumberOfManifolds(dimensionality);
for(int manifoldIndex = 0; manifoldIndex < numberOfManifolds; manifoldIndex++) {
tarch::la::Vector<DIMENSIONS, int> manifoldPosition = getManifold(dimensionality, manifoldIndex);
int manifoldEntry = linearizeManifoldPosition(manifoldPosition);
logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "Manifold " << manifoldPosition << " of dimensions " << dimensionality
<< ": entry=" << manifoldEntry << ", rank=" << adjacentRanks[manifoldEntry] << ", overlap=" << overlapOfRemoteGhostlayers[manifoldEntry]);
if(adjacentRanks[manifoldEntry] == rank && overlapOfRemoteGhostlayers[manifoldEntry] > 0) {
//Reduce lower-dimensional manifolds
bool canBeOmitted = checkHigherDimensionalManifoldForOverlap(
adjacentRanks,
overlapOfRemoteGhostlayers,
manifoldPosition,
dimensionality,
manifoldEntry,
rank
);
//Restrict size and offset by higher-dimensional manifolds
logDebug("getAreasOverlappedByRemoteGhostlayers(...)","Testing manifold " << manifoldPosition << " of dimensions " << dimensionality
<< ": " << (canBeOmitted ? "omitting" : "consider"));
if(!canBeOmitted) {
tarch::la::Vector<DIMENSIONS, int> size;
tarch::la::Vector<DIMENSIONS, int> offset;
//Initialise size and offset
for(int d = 0; d < DIMENSIONS; d++) {
size(d) = (manifoldPosition(d) == 0) ? subdivisionFactor(d) : std::min(subdivisionFactor(d), overlapOfRemoteGhostlayers[manifoldEntry]);
offset(d) = (manifoldPosition(d) == 1) ? subdivisionFactor(d) - size(d) : 0;
}
//TODO unterweg debug
// std::cout << "offset: " << offset << ", size: " << size << std::endl;
for(int adjacentDimensionality = dimensionality - 1; adjacentDimensionality >= 0; adjacentDimensionality--) {
int numberOfAdjacentManifolds = getNumberOfAdjacentManifolds(manifoldPosition, dimensionality, adjacentDimensionality);
for(int adjacentManifoldIndex = 0; adjacentManifoldIndex < numberOfAdjacentManifolds; adjacentManifoldIndex++) {
tarch::la::Vector<DIMENSIONS, int> adjacentManifoldPosition = getIndexOfAdjacentManifold(
manifoldPosition,
dimensionality,
adjacentDimensionality,
adjacentManifoldIndex
);
//TODO unterweg debug
// std::cout << "adj. manifold " << adjacentManifoldPosition << std::endl;
int adjacentEntry = linearizeManifoldPosition(adjacentManifoldPosition);
if(adjacentRanks[adjacentEntry] == rank) {
for(int d = 0; d < DIMENSIONS; d++) {
if(manifoldPosition(d) == 0) {
if(adjacentManifoldPosition(d) < 0) {
int overlap = std::max(0, overlapOfRemoteGhostlayers[adjacentEntry] - offset(d));
offset(d) += overlap;
size(d) -= overlap;
//TODO unterweg debug
// std::cout << "Reducing bottom " << overlap << std::endl;
} else if(adjacentManifoldPosition(d) > 0) {
assertion2(adjacentManifoldPosition(d) > 0, adjacentManifoldPosition, d);
int overlap = std::max(0, offset(d) + size(d) - (subdivisionFactor(d) - overlapOfRemoteGhostlayers[adjacentEntry]));
size(d) -= overlap;
//TODO unterweg debug
// std::cout << "Reducing top " << overlap << std::endl;
}
}
}
}
}
}
logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "offset: " << offset << ", size: " << size << ", dimensionality=" << dimensionality << ", manifoldIndex=" << manifoldIndex << ", manifoldEntry=" << manifoldEntry);
if(tarch::la::allGreater(size, 0)) {
areas[numberOfAreas++] = Area(offset, size);
oneAreaCoversCompleteSubgrid |= (tarch::la::volume(size) >= tarch::la::volume(subdivisionFactor));
assertion1(tarch::la::allGreaterEquals(offset, 0), offset);
assertion3(tarch::la::allGreaterEquals(subdivisionFactor, offset + size), offset, size, subdivisionFactor);
}
}
}
}
}
//.........這裏部分代碼省略.........
示例14: defined
bool Triangulate::Process(const Vector2dVector &contour,Vector2dVector &result)
{
#if defined(PRECISE_TRIANGULATION)
std::vector<p2t::Point*> _polyline;
for (auto _p : contour){
_polyline.push_back(new p2t::Point(_p.GetX(), _p.GetY()));
}
p2t::CDT* _cdt = new p2t::CDT(_polyline);
_cdt->Triangulate();
std::vector<p2t::Triangle*> _triangles = _cdt->GetTriangles();
for (auto _t : _triangles){
auto _pt1 = _t->GetPoint(0);
auto _pt2 = _t->GetPoint(1);
auto _pt3 = _t->GetPoint(2);
result.push_back(Vector2d(_pt1->x, _pt1->y));
result.push_back(Vector2d(_pt2->x, _pt2->y));
result.push_back(Vector2d(_pt3->x, _pt3->y));
}
delete _cdt;
for (auto _p : _polyline)
delete _p;
return true;
#else
/* allocate and initialize list of Vertices in polygon */
int n = (int)contour.size();
if ( n < 3 ) return false;
int *V = new int[n];
/* we want a counter-clockwise polygon in V */
if ( 0.0f < Area(contour) )
for (int v=0; v<n; v++) V[v] = v;
else
for(int v=0; v<n; v++) V[v] = (n-1)-v;
int nv = n;
/* remove nv-2 Vertices, creating 1 triangle every time */
int count = 2*nv; /* error detection */
for(int m=0, v=nv-1; nv>2; )
{
/* if we loop, it is probably a non-simple polygon */
if (0 >= (count--))
{
//** Triangulate: ERROR - probable bad polygon!
return false;
}
/* three consecutive vertices in current polygon, <u,v,w> */
int u = v ; if (nv <= u) u = 0; /* previous */
v = u+1; if (nv <= v) v = 0; /* new v */
int w = v+1; if (nv <= w) w = 0; /* next */
if ( Snip(contour,u,v,w,nv,V) )
{
int a,b,c,s,t;
/* true names of the vertices */
a = V[u]; b = V[v]; c = V[w];
/* output Triangle */
result.push_back( contour[a] );
result.push_back( contour[b] );
result.push_back( contour[c] );
m++;
/* remove v from remaining polygon */
for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; nv--;
/* resest error detection counter */
count = 2*nv;
}
}
//Danilo S Carvalho Alteration from delete to delete[]
delete[] V;
return true;
#endif
}
示例15: controller
void
BorderResizer::Wrap()
{
auto& controller(widget.get().GetController());
yunseq(
FetchEvent<TouchDown>(controller).Add([this](CursorEventArgs&& e){
yunseq(orig_loc = FetchGUIState().CursorLocation,
locked_bounds = GetBoundsOf(widget), focused = CheckArea(e));
}, 0xE0),
FetchEvent<TouchHeld>(controller).Add([this](CursorEventArgs&& e){
if(e.Strategy == RoutedEventArgs::Direct
&& focused != Area(BorderArea::Center, BorderArea::Center))
{
auto& st(FetchGUIState());
if(st.CheckDraggingOffset())
{
const auto offset(st.CursorLocation - orig_loc);
auto bounds(locked_bounds);
switch(focused.first)
{
case BorderArea::Left:
bounds.Width = max<SPos>(MinSize.Width,
locked_bounds.Width - offset.X);
bounds.X += locked_bounds.Width - bounds.Width;
break;
case BorderArea::Right:
bounds.Width = max<SPos>(MinSize.Width,
locked_bounds.Width + offset.X);
break;
default:
;
}
switch(focused.second)
{
case BorderArea::Up:
bounds.Height = max<SPos>(MinSize.Height,
locked_bounds.Height - offset.Y);
bounds.Y += locked_bounds.Height - bounds.Height;
break;
case BorderArea::Down:
bounds.Height = max<SPos>(MinSize.Height,
locked_bounds.Height + offset.Y);
break;
default:
;
}
YTraceDe(Notice, "BorderResizer: new bounds = %s.\n",
to_string(bounds).c_str());
InvalidateParent(widget);
if(HostMode)
{
const auto& off(
bounds.GetPoint() - locked_bounds.GetPoint());
SetBoundsOf(widget, bounds);
const auto& nloc(FetchGUIState().CursorLocation - off);
if(bounds.Width != MinSize.Width)
orig_loc.X = nloc.X;
if(bounds.Height != MinSize.Height)
orig_loc.Y = nloc.Y;
locked_bounds = GetBoundsOf(widget);
locked_bounds.GetPointRef() -= off;
}
else
SetBoundsOf(widget, bounds);
}
e.Handled = true;
// XXX: Paint context target invalidated.
}
}, 0xE0),
FetchEvent<Click>(controller).Add([this](CursorEventArgs&& e){
CallEvent<ClickAcross>(widget, e);
}, 0xE0),
FetchEvent<ClickAcross>(controller).Add([this](CursorEventArgs&&){
yunseq(orig_loc = Point::Invalid, locked_bounds = Rect(),
focused = {BorderArea::Center, BorderArea::Center});
}, 0xE0)
);
}