MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / fixLocation

Function fixLocation

Samples/NiViewer/Draw.cpp:1465–1485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1463}
1464
1465void fixLocation(IntRect* pLocation, int xRes, int yRes)
1466{
1467 double resRatio = (double)xRes / yRes;
1468
1469 double locationRatio = double(pLocation->uRight - pLocation->uLeft) / (pLocation->uTop - pLocation->uBottom);
1470
1471 if (locationRatio > resRatio)
1472 {
1473 // location is wider. use height as reference.
1474 double width = (pLocation->uTop - pLocation->uBottom) * resRatio;
1475 pLocation->uLeft += (pLocation->uRight - pLocation->uLeft - width) / 2;
1476 pLocation->uRight = (pLocation->uLeft + width);
1477 }
1478 else if (locationRatio < resRatio)
1479 {
1480 // res is wider. use width as reference.
1481 double height = (pLocation->uRight - pLocation->uLeft) / resRatio;
1482 pLocation->uBottom += (pLocation->uTop - pLocation->uBottom - height) / 2;
1483 pLocation->uTop = (pLocation->uBottom + height);
1484 }
1485}
1486
1487bool isPointInRect(IntPair point, IntRect* pRect)
1488{

Callers 1

drawFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected