8 #ifndef META_OCEAN_MATH_LOOKUP2_H
9 #define META_OCEAN_MATH_LOOKUP2_H
28 template <
typename T,
typename TScalar = Scalar>
51 inline const T*
data()
const;
93 explicit inline operator bool()
const;
196 template <
typename T,
typename TScalar = Scalar>
252 inline bool isInside(
const TScalar x,
const TScalar y)
const;
259 inline size_t binX(
const TScalar x)
const;
266 inline size_t binY(
const TScalar y)
const;
422 template <
typename T,
typename TScalar = Scalar>
507 bool nearestValue(
const TScalar x,
const TScalar y, T& value)
const;
518 bool bilinearValue(
const TScalar x,
const TScalar y, T& value)
const;
530 bool bilinearValue(
const TScalar x,
const TScalar y,
const unsigned int minimalValidBins, T& value)
const;
634 template <
typename T,
typename TScalar = Scalar>
690 inline bool isInside(
const TScalar x,
const TScalar y)
const;
697 inline size_t binX(
const TScalar x)
const;
704 inline size_t binY(
const TScalar y)
const;
765 template <
typename TTarget = T>
779 template <
typename TTarget = T>
780 void bilinearValues(
const size_t x,
const size_t y,
const size_t size, TTarget* values)
const;
797 void bilinearValue(
const TScalar x,
const TScalar y, T& topLeft, T& topRight, T& bottomLeft, T& bottomRight, TScalar& factorTopLeft, TScalar& factorTopRight, TScalar& factorBottomLeft, TScalar& factorBottomRight)
const;
890 template <
typename T,
typename TScalar>
892 sizeX_(lookup.sizeX_),
893 sizeY_(lookup.sizeY_),
894 binsX_(lookup.binsX_),
895 binsY_(lookup.binsY_),
896 invSizeX_(lookup.invSizeX_),
897 invSizeY_(lookup.invSizeY_),
898 invBinsX_(lookup.invBinsX_),
899 invBinsY_(lookup.invBinsY_),
900 values_(lookup.values_)
905 template <
typename T,
typename TScalar>
907 sizeX_(lookup.sizeX_),
908 sizeY_(lookup.sizeY_),
909 binsX_(lookup.binsX_),
910 binsY_(lookup.binsY_),
911 invSizeX_(lookup.invSizeX_),
912 invSizeY_(lookup.invSizeY_),
913 invBinsX_(lookup.invBinsX_),
914 invBinsY_(lookup.invBinsY_),
915 values_(std::move(lookup.values_))
922 lookup.invSizeX_ = 0;
923 lookup.invSizeY_ = 0;
924 lookup.invBinsX_ = 0;
925 lookup.invBinsY_ = 0;
928 template <
typename T,
typename TScalar>
931 return values_.data();
934 template <
typename T,
typename TScalar>
937 return values_.data();
940 template <
typename T,
typename TScalar>
946 template <
typename T,
typename TScalar>
952 template <
typename T,
typename TScalar>
958 template <
typename T,
typename TScalar>
964 template <
typename T,
typename TScalar>
980 template <
typename T,
typename TScalar>
985 sizeX_ = lookup.sizeX_;
986 sizeY_ = lookup.sizeY_;
987 binsX_ = lookup.binsX_;
988 binsY_ = lookup.binsY_;
989 invSizeX_ = lookup.invSizeX_;
990 invSizeY_ = lookup.invSizeY_;
991 invBinsX_ = lookup.invBinsX_;
992 invBinsY_ = lookup.invBinsY_;
993 values_ = std::move(lookup.values_);
999 lookup.invSizeX_ = 0;
1000 lookup.invSizeY_ = 0;
1001 lookup.invBinsX_ = 0;
1002 lookup.invBinsY_ = 0;
1008 template <
typename T,
typename TScalar>
1011 return values_.empty();
1014 template <
typename T,
typename TScalar>
1017 return !values_.empty();
1020 template <
typename T,
typename TScalar>
1026 template <
typename T,
typename TScalar>
1029 return !(*
this == lookup);
1032 template <
typename T,
typename TScalar>
1039 template <
typename T,
typename TScalar>
1046 template <
typename T,
typename TScalar>
1059 ocean_assert(
sizeX > 0);
1060 ocean_assert(
sizeY > 0);
1064 ocean_assert(
binsX > 0);
1065 ocean_assert(
binsY > 0);
1070 template <
typename T,
typename TScalar>
1074 ocean_assert(binValues);
1085 ocean_assert(
sizeX > 0);
1086 ocean_assert(
sizeY > 0);
1090 ocean_assert(
binsX > 0);
1091 ocean_assert(
binsY > 0);
1095 for (
size_t n = 0; n < this->
values_.size(); ++n)
1097 this->
values_[n] = binValues[n];
1101 template <
typename T,
typename TScalar>
1111 ocean_assert(this->
binsX_ <= sizeX);
1112 ocean_assert(this->
binsY_ <= sizeY);
1114 ocean_assert(
sizeX > 0);
1115 ocean_assert(
sizeY > 0);
1119 ocean_assert(this->
binsX_ > 0);
1120 ocean_assert(this->
binsY_ > 0);
1125 template <
typename T,
typename TScalar>
1128 ocean_assert(!this->isEmpty());
1129 return x >= TScalar(0) && y >= TScalar(0) && x <= TScalar(this->sizeX_ - 1) && y <= TScalar(this->sizeY_ - 1);
1132 template <
typename T,
typename TScalar>
1135 ocean_assert(this->sizeX_ > 0);
1136 ocean_assert(x >= 0 && x <= TScalar(this->sizeX_ - 1));
1138 const size_t result = size_t(x * TScalar(this->binsX_) * this->invSizeX_ + (std::is_same<TScalar, float>::value ? TScalar(0.0001) :
NumericT<TScalar>::eps()));
1139 ocean_assert(result < this->binsX_);
1144 template <
typename T,
typename TScalar>
1147 ocean_assert(this->sizeY_ > 0);
1148 ocean_assert(y >= 0 && y <= TScalar(this->sizeY_ - 1));
1150 const size_t result = size_t(y * TScalar(this->binsY_) * this->invSizeY_ + (std::is_same<TScalar, float>::value ? TScalar(0.0001) :
NumericT<TScalar>::eps()));
1151 ocean_assert(result < this->binsY_);
1156 template <
typename T,
typename TScalar>
1159 ocean_assert(binX < this->binsX_);
1162 ocean_assert(binX == this->binX(TScalar(x)));
1167 template <
typename T,
typename TScalar>
1170 ocean_assert(binY < this->binsY_);
1173 ocean_assert(binY == this->binY(TScalar(y)));
1178 template <
typename T,
typename TScalar>
1181 ocean_assert(binX < this->binsX_);
1185 ocean_assert(x >= 1);
1186 ocean_assert(binX == this->binX(TScalar(x - 1)));
1191 template <
typename T,
typename TScalar>
1194 ocean_assert(binY < this->binsY_);
1198 ocean_assert(y >= 1);
1199 ocean_assert(binY == this->binY(TScalar(y - 1)));
1204 template <
typename T,
typename TScalar>
1207 ocean_assert(binX < this->binsX_);
1209 const TScalar result = TScalar(binTopLeftX(binX) + binBottomRightX(binX)) * TScalar(0.5);
1210 ocean_assert(result >= 0 && result < TScalar(this->sizeX_));
1215 template <
typename T,
typename TScalar>
1218 ocean_assert(binY < this->binsY_);
1220 const TScalar result = TScalar(binTopLeftY(binY) + binBottomRightY(binY)) * TScalar(0.5);
1221 ocean_assert(result >= 0 && result < TScalar(this->sizeY_));
1226 template <
typename T,
typename TScalar>
1229 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1231 return Vector2(binCenterPositionX(binX), binCenterPositionY(binY));
1234 template <
typename T,
typename TScalar>
1237 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1238 return this->values_[binY * this->binsX_ + binX];
1241 template <
typename T,
typename TScalar>
1244 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1245 return this->values_[binY * this->binsX_ + binX];
1248 template <
typename T,
typename TScalar>
1251 ocean_assert(this->isInside(x, y));
1253 const size_t bx = this->binX(x);
1254 const size_t by = this->binY(y);
1256 return this->values_[by * this->binsX_ + bx];
1259 template <
typename T,
typename TScalar>
1262 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1263 ocean_assert(this->isInside(x, y));
1265 const size_t bX = this->binX(x);
1266 const size_t bY = this->binY(y);
1268 const TScalar bCenterX = this->binCenterPositionX(bX);
1269 const TScalar bCenterY = this->binCenterPositionY(bY);
1271 const size_t xLowBin = (x >= bCenterX) ? bX : max(0,
int(bX) - 1);
1272 const size_t xHighBin = (x < bCenterX) ? bX : min(xLowBin + 1, this->binsX_ - 1);
1273 const size_t yLowBin = (y >= bCenterY) ? bY : max(0,
int(bY) - 1);
1274 const size_t yHighBin = (y < bCenterY) ? bY : min(yLowBin + 1, this->binsY_ - 1);
1275 ocean_assert(((xLowBin == 0 || xLowBin == this->binsX_ - 1) && xHighBin == xLowBin) || xLowBin + 1 == xHighBin);
1276 ocean_assert(((yLowBin == 0 || yLowBin == this->binsY_ - 1) && yHighBin == yLowBin) || yLowBin + 1 == yHighBin);
1278 const TScalar leftCenter = this->binCenterPositionX(xLowBin);
1279 const TScalar rightCenter = this->binCenterPositionX(xHighBin);
1280 const TScalar topCenter = this->binCenterPositionY(yLowBin);
1281 const TScalar bottomCenter = this->binCenterPositionY(yHighBin);
1282 ocean_assert(leftCenter <= rightCenter);
1283 ocean_assert(topCenter <= bottomCenter);
1288 const TScalar xFactor = xLowBin != xHighBin ? (x - leftCenter) / (rightCenter - leftCenter) : TScalar(1);
1289 const TScalar yFactor = yLowBin != yHighBin ? (y - topCenter) / (bottomCenter - topCenter) : TScalar(1);
1294 const TScalar factorTopLeft = (TScalar(1) - xFactor) * (TScalar(1) - yFactor);
1295 const TScalar factorTopRight = xFactor * (TScalar(1) - yFactor);
1296 const TScalar factorBottomLeft = (TScalar(1) - xFactor) * yFactor;
1297 const TScalar factorBottomRight = xFactor * yFactor;
1299 const T& topLeft = binCenterValue(xLowBin, yLowBin);
1300 const T& topRight = binCenterValue(xHighBin, yLowBin);
1301 const T& bottomLeft = binCenterValue(xLowBin, yHighBin);
1302 const T& bottomRight = binCenterValue(xHighBin, yHighBin);
1304 return topLeft * factorTopLeft + topRight * factorTopRight
1305 + bottomLeft * factorBottomLeft + bottomRight * factorBottomRight;
1308 template <
typename T,
typename TScalar>
1311 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1312 ocean_assert(this->isInside(x, y));
1314 const size_t bX = this->binX(x);
1315 const size_t bY = this->binY(y);
1317 const TScalar bCenterX = this->binCenterPositionX(bX);
1318 const TScalar bCenterY = this->binCenterPositionY(bY);
1320 const size_t xLowBin = (x >= bCenterX) ? bX : max(0,
int(bX) - 1);
1321 const size_t xHighBin = (x < bCenterX) ? bX : min(xLowBin + 1, this->binsX_ - 1);
1322 const size_t yLowBin = (y >= bCenterY) ? bY : max(0,
int(bY) - 1);
1323 const size_t yHighBin = (y < bCenterY) ? bY : min(yLowBin + 1, this->binsY_ - 1);
1324 ocean_assert(((xLowBin == 0 || xLowBin == this->binsX_ - 1) && xHighBin == xLowBin) || xLowBin + 1 == xHighBin);
1325 ocean_assert(((yLowBin == 0 || yLowBin == this->binsY_ - 1) && yHighBin == yLowBin) || yLowBin + 1 == yHighBin);
1328 const size_t xMinusBin = max(0,
int(xLowBin) - 1);
1329 const size_t xPlusBin = min(xHighBin + 1, this->binsX_ - 1);
1330 const size_t yMinusBin = max(0,
int(yLowBin) - 1);
1331 const size_t yPlusBin = min(yHighBin + 1, this->binsY_ - 1);
1333 const TScalar leftCenter = this->binCenterPositionX(xLowBin);
1334 const TScalar rightCenter = this->binCenterPositionX(xHighBin);
1335 const TScalar topCenter = this->binCenterPositionY(yLowBin);
1336 const TScalar bottomCenter = this->binCenterPositionY(yHighBin);
1337 ocean_assert(leftCenter <= rightCenter);
1338 ocean_assert(topCenter <= bottomCenter);
1343 const TScalar xFactor = xLowBin != xHighBin ? (x - leftCenter) / (rightCenter - leftCenter) : TScalar(1);
1344 const TScalar yFactor = yLowBin != yHighBin ? (y - topCenter) / (bottomCenter - topCenter) : TScalar(1);
1349 return Interpolation::cubic(
Interpolation::cubic(binCenterValue(xMinusBin, yMinusBin), binCenterValue(xLowBin, yMinusBin), binCenterValue(xHighBin, yMinusBin), binCenterValue(xPlusBin, yMinusBin), xFactor),
1350 Interpolation::cubic(binCenterValue(xMinusBin, yLowBin), binCenterValue(xLowBin, yLowBin), binCenterValue(xHighBin, yLowBin), binCenterValue(xPlusBin, yLowBin), xFactor),
1351 Interpolation::cubic(binCenterValue(xMinusBin, yHighBin), binCenterValue(xLowBin, yHighBin), binCenterValue(xHighBin, yHighBin), binCenterValue(xPlusBin, yHighBin), xFactor),
1352 Interpolation::cubic(binCenterValue(xMinusBin, yPlusBin), binCenterValue(xLowBin, yPlusBin), binCenterValue(xHighBin, yPlusBin), binCenterValue(xPlusBin, yPlusBin), xFactor), yFactor);
1355 template <
typename T,
typename TScalar>
1358 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1360 return nearestValue(minmax<TScalar>(0, x, TScalar(this->sizeX_ - 1)), minmax<TScalar>(0, y, TScalar(this->sizeY_ - 1)));
1363 template <
typename T,
typename TScalar>
1366 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1368 return bilinearValue(minmax<TScalar>(0, x, TScalar(this->sizeX_ - 1)), minmax<TScalar>(0, y, TScalar(this->sizeY_ - 1)));
1371 template <
typename T,
typename TScalar>
1374 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1376 return bicubicValue(minmax<TScalar>(0, x, TScalar(this->sizeX_ - 1)), minmax<TScalar>(0, y, TScalar(this->sizeY_ - 1)));
1379 template <
typename T,
typename TScalar>
1382 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1383 this->values_[binY * this->binsX_ + binX] = value;
1386 template <
typename T,
typename TScalar>
1393 template <
typename T,
typename TScalar>
1396 validBins_(lookup.validBins_)
1401 template <
typename T,
typename TScalar>
1404 validBins_(std::move(lookup.validBins_))
1409 template <
typename T,
typename TScalar>
1412 validBins_(binsX * binsY, 1u)
1417 template <
typename T,
typename TScalar>
1420 validBins_(binsX * binsY, binsValid ? 1u : 0u)
1425 template <
typename T,
typename TScalar>
1427 LookupCenter2<T, TScalar>(sizeX, sizeY, binsX, binsY, binValues),
1428 validBins_(binsX * binsY)
1433 template <
typename T,
typename TScalar>
1436 validBins_(lookup.validBins_)
1441 template <
typename T,
typename TScalar>
1444 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1445 return validBins_[binY * this->binsX_ + binX] != 0u;
1448 template <
typename T,
typename TScalar>
1451 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1452 ocean_assert(this->values_.size() == validBins_.size());
1453 ocean_assert(this->isInside(x, y));
1455 const size_t bx = this->binX(x);
1456 const size_t by = this->binY(y);
1458 if (validBins_[by * this->binsX_ + bx] == 0u)
1463 value = this->values_[by * this->binsX_ + bx];
1467 template <
typename T,
typename TScalar>
1470 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1471 ocean_assert(this->values_.size() == validBins_.size());
1472 ocean_assert(this->isInside(x, y));
1474 const size_t bX = this->binX(x);
1475 const size_t bY = this->binY(y);
1477 const TScalar bCenterX = this->binCenterPositionX(bX);
1478 const TScalar bCenterY = this->binCenterPositionY(bY);
1480 const size_t xLowBin = (x >= bCenterX) ? bX : max(0,
int(bX) - 1);
1481 const size_t xHighBin = (x < bCenterX) ? bX : min(xLowBin + 1, this->binsX_ - 1);
1482 const size_t yLowBin = (y >= bCenterY) ? bY : max(0,
int(bY) - 1);
1483 const size_t yHighBin = (y < bCenterY) ? bY : min(yLowBin + 1, this->binsY_ - 1);
1484 ocean_assert(((xLowBin == 0 || xLowBin == this->binsX_ - 1) && xHighBin == xLowBin) || xLowBin + 1 == xHighBin);
1485 ocean_assert(((yLowBin == 0 || yLowBin == this->binsY_ - 1) && yHighBin == yLowBin) || yLowBin + 1 == yHighBin);
1487 const TScalar leftCenter = this->binCenterPositionX(xLowBin);
1488 const TScalar rightCenter = this->binCenterPositionX(xHighBin);
1489 const TScalar topCenter = this->binCenterPositionY(yLowBin);
1490 const TScalar bottomCenter = this->binCenterPositionY(yHighBin);
1491 ocean_assert(leftCenter <= rightCenter);
1492 ocean_assert(topCenter <= bottomCenter);
1497 const TScalar xFactor = xLowBin != xHighBin ? (x - leftCenter) / (rightCenter - leftCenter) : TScalar(1);
1498 const TScalar yFactor = yLowBin != yHighBin ? (y - topCenter) / (bottomCenter - topCenter) : TScalar(1);
1503 const T& topLeft = this->binCenterValue(xLowBin, yLowBin);
1504 const T& topRight = this->binCenterValue(xHighBin, yLowBin);
1505 const T& bottomLeft = this->binCenterValue(xLowBin, yHighBin);
1506 const T& bottomRight = this->binCenterValue(xHighBin, yHighBin);
1508 const bool validTopLeft = validBins_[yLowBin * this->binsX_ + xLowBin] != 0u;
1509 const bool validTopRight = validBins_[yLowBin * this->binsX_ + xHighBin] != 0u;
1510 const bool validBottomLeft = validBins_[yHighBin * this->binsX_ + xLowBin] != 0u;
1511 const bool validBottomRight = validBins_[yHighBin * this->binsX_ + xHighBin] != 0u;
1513 if (validTopLeft || validTopRight || validBottomLeft || validBottomRight)
1515 value =
Interpolation::bilinear(topLeft, topRight, bottomLeft, bottomRight, validTopLeft, validTopRight, validBottomLeft, validBottomRight, xFactor, yFactor);
1522 template <
typename T,
typename TScalar>
1525 ocean_assert(minimalValidBins >= 1u && minimalValidBins <= 4u);
1526 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1527 ocean_assert(this->values_.size() == validBins_.size());
1528 ocean_assert(this->isInside(x, y));
1530 const size_t bX = this->binX(x);
1531 const size_t bY = this->binY(y);
1533 const TScalar bCenterX = this->binCenterPositionX(bX);
1534 const TScalar bCenterY = this->binCenterPositionY(bY);
1536 const size_t xLowBin = (x >= bCenterX) ? bX : max(0,
int(bX) - 1);
1537 const size_t xHighBin = (x < bCenterX) ? bX : min(xLowBin + 1, this->binsX_ - 1);
1538 const size_t yLowBin = (y >= bCenterY) ? bY : max(0,
int(bY) - 1);
1539 const size_t yHighBin = (y < bCenterY) ? bY : min(yLowBin + 1, this->binsY_ - 1);
1540 ocean_assert(((xLowBin == 0 || xLowBin == this->binsX_ - 1) && xHighBin == xLowBin) || xLowBin + 1 == xHighBin);
1541 ocean_assert(((yLowBin == 0 || yLowBin == this->binsY_ - 1) && yHighBin == yLowBin) || yLowBin + 1 == yHighBin);
1543 const TScalar leftCenter = this->binCenterPositionX(xLowBin);
1544 const TScalar rightCenter = this->binCenterPositionX(xHighBin);
1545 const TScalar topCenter = this->binCenterPositionY(yLowBin);
1546 const TScalar bottomCenter = this->binCenterPositionY(yHighBin);
1547 ocean_assert(leftCenter <= rightCenter);
1548 ocean_assert(topCenter <= bottomCenter);
1553 const TScalar xFactor = xLowBin != xHighBin ? (x - leftCenter) / (rightCenter - leftCenter) : TScalar(1);
1554 const TScalar yFactor = yLowBin != yHighBin ? (y - topCenter) / (bottomCenter - topCenter) : TScalar(1);
1559 const T& topLeft = this->binCenterValue(xLowBin, yLowBin);
1560 const T& topRight = this->binCenterValue(xHighBin, yLowBin);
1561 const T& bottomLeft = this->binCenterValue(xLowBin, yHighBin);
1562 const T& bottomRight = this->binCenterValue(xHighBin, yHighBin);
1564 const bool validTopLeft = validBins_[yLowBin * this->binsX_ + xLowBin] != 0u;
1565 const bool validTopRight = validBins_[yLowBin * this->binsX_ + xHighBin] != 0u;
1566 const bool validBottomLeft = validBins_[yHighBin * this->binsX_ + xLowBin] != 0u;
1567 const bool validBottomRight = validBins_[yHighBin * this->binsX_ + xHighBin] != 0u;
1569 ocean_assert(validTopLeft == 0 || validTopLeft == 1);
1570 ocean_assert(validTopRight == 0 || validTopRight == 1);
1571 ocean_assert(validBottomLeft == 0 || validBottomLeft == 1);
1572 ocean_assert(validBottomRight == 0 || validBottomRight == 1);
1574 if ((
unsigned int)(validTopLeft + validTopRight + validBottomLeft + validBottomRight) >= minimalValidBins)
1576 value =
Interpolation::bilinear(topLeft, topRight, bottomLeft, bottomRight, validTopLeft, validTopRight, validBottomLeft, validBottomRight, xFactor, yFactor);
1583 template <
typename T,
typename TScalar>
1586 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1588 return nearestValue(minmax<TScalar>(0, x, TScalar(this->sizeX_ - 1)), minmax<TScalar>(0, y, TScalar(this->sizeY_ - 1)), value);
1591 template <
typename T,
typename TScalar>
1594 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1596 return bilinearValue(minmax<TScalar>(0, x, TScalar(this->sizeX_ - 1)), minmax<TScalar>(0, y, TScalar(this->sizeY_ - 1)), value);
1599 template <
typename T,
typename TScalar>
1602 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1604 this->values_[binY * this->binsX_ + binX] = value;
1605 validBins_[binY * this->binsX_ + binX] = isValid ? 1u : 0u;
1608 template <
typename T,
typename TScalar>
1611 ocean_assert(binX < this->binsX_ && binY < this->binsY_);
1612 validBins_[binY * this->binsX_ + binX] = isValid ? 1u: 0u;
1615 template <
typename T,
typename TScalar>
1618 if (
this != &lookup)
1621 validBins_ = std::move(lookup.validBins_);
1627 template <
typename T,
typename TScalar>
1633 template <
typename T,
typename TScalar>
1636 return !(*
this == lookup);
1639 template <
typename T,
typename TScalar>
1641 Lookup2<T, TScalar>(std::move(lookup))
1646 template <
typename T,
typename TScalar>
1653 template <
typename T,
typename TScalar>
1666 ocean_assert(
sizeX >= 1);
1667 ocean_assert(
sizeY >= 1);
1671 ocean_assert(
binsX > 0);
1672 ocean_assert(
binsY > 0);
1677 template <
typename T,
typename TScalar>
1681 ocean_assert(binCornerValues);
1692 ocean_assert(
sizeX > 1);
1693 ocean_assert(
sizeY > 1);
1697 ocean_assert(
binsX > 0);
1698 ocean_assert(
binsY > 0);
1702 for (
size_t n = 0; n < this->
values_.size(); ++n)
1704 this->
values_[n] = binCornerValues[n];
1708 template <
typename T,
typename TScalar>
1718 ocean_assert(this->
binsX_ <= sizeX);
1719 ocean_assert(this->
binsY_ <= sizeY);
1721 ocean_assert(
sizeX > 1);
1722 ocean_assert(
sizeY > 1);
1726 ocean_assert(this->
binsX_ > 0);
1727 ocean_assert(this->
binsY_ > 0);
1732 template <
typename T,
typename TScalar>
1735 ocean_assert(!this->isEmpty());
1736 return x >= TScalar(0) && y >= TScalar(0) && x <= TScalar(this->sizeX_) && y <= TScalar(this->sizeY_);
1739 template <
typename T,
typename TScalar>
1742 ocean_assert(this->sizeX_ > 0);
1743 ocean_assert(x >= 0 && x <= TScalar(this->sizeX_));
1745 const size_t result = size_t(x * TScalar(this->binsX_) * this->invSizeX_);
1746 ocean_assert(result <= this->binsX_);
1751 template <
typename T,
typename TScalar>
1754 ocean_assert(this->sizeY_ > 0);
1755 ocean_assert(y >= 0 && y <= TScalar(this->sizeY_));
1757 const size_t result = size_t(y * TScalar(this->binsY_) * this->invSizeY_);
1758 ocean_assert(result <= this->binsY_);
1763 template <
typename T,
typename TScalar>
1766 ocean_assert(binX <= this->binsX_ && this->sizeX_ >= 1);
1768 const TScalar result = TScalar(binX * this->sizeX_) * this->invBinsX_;
1771 return minmax<TScalar>(0, result, TScalar(this->sizeX_));
1774 template <
typename T,
typename TScalar>
1777 ocean_assert(binY <= this->binsY_ && this->sizeY_ >= 1);
1779 const TScalar result = TScalar(binY * this->sizeY_) * this->invBinsY_;
1782 return minmax<TScalar>(0, result, TScalar(this->sizeY_));
1785 template <
typename T,
typename TScalar>
1788 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1790 return Vector2(binTopLeftCornerPositionX(binX), binTopLeftCornerPositionY(binY));
1793 template <
typename T,
typename TScalar>
1796 ocean_assert(binX <= this->binsX_ && binY <= this->binsY_);
1797 return this->values_[binY * (this->binsX_ + 1) + binX];
1800 template <
typename T,
typename TScalar>
1803 ocean_assert(this->isInside(x, y));
1805 const size_t bx = size_t(x * TScalar(this->binsX_) * this->invSizeX_ + TScalar(0.5));
1806 ocean_assert(bx <= this->binsX_);
1808 const size_t by = size_t(y * TScalar(this->binsY_) * this->invSizeY_ + TScalar(0.5));
1809 ocean_assert(by <= this->binsY_);
1811 return this->values_[by * (this->binsX_ + 1) + bx];
1814 template <
typename T,
typename TScalar>
1817 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1818 ocean_assert(this->isInside(x, y));
1820 const size_t xLowBin = this->binX(x);
1821 const size_t yLowBin = this->binY(y);
1823 ocean_assert(xLowBin <= this->binsX_);
1824 ocean_assert(yLowBin <= this->binsY_);
1826 const TScalar leftPosition = this->binTopLeftCornerPositionX(xLowBin);
1827 const TScalar topPosition = this->binTopLeftCornerPositionY(yLowBin);
1829 const TScalar xFactor = (x - leftPosition) * TScalar(this->binsX_) * this->invSizeX_;
1830 const TScalar yFactor = (y - topPosition) * TScalar(this->binsY_) * this->invSizeY_;
1833 if (std::is_same<TScalar, float>::value)
1845 const TScalar factorTopLeft = (TScalar(1) - xFactor) * (TScalar(1) - yFactor);
1846 const TScalar factorTopRight = xFactor * (TScalar(1) - yFactor);
1847 const TScalar factorBottomLeft = (TScalar(1) - xFactor) * yFactor;
1848 const TScalar factorBottomRight = xFactor * yFactor;
1850 const size_t xHighBin = min(xLowBin + 1, this->binsX_);
1851 const size_t yHighBin = min(yLowBin + 1, this->binsY_);
1853 const T& topLeft = this->binTopLeftCornerValue(xLowBin, yLowBin);
1854 const T& topRight = this->binTopLeftCornerValue(xHighBin, yLowBin);
1855 const T& bottomLeft = this->binTopLeftCornerValue(xLowBin, yHighBin);
1856 const T& bottomRight = this->binTopLeftCornerValue(xHighBin, yHighBin);
1858 return topLeft * factorTopLeft + topRight * factorTopRight
1859 + bottomLeft * factorBottomLeft + bottomRight * factorBottomRight;
1862 template <
typename T,
typename TScalar>
1863 template <
typename TTarget>
1866 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1867 ocean_assert(this->binsX_ <= this->sizeX_ && this->binsY_ <= this->sizeY_);
1869 ocean_assert(y < this->sizeY_);
1870 ocean_assert(values !=
nullptr);
1872 const size_t yLowBin = (y * this->binsY_) / this->sizeY_;
1873 ocean_assert(yLowBin < this->binsY_);
1874 ocean_assert(std::abs(
int(yLowBin) -
int(this->binY(TScalar(y)))) <= 1);
1876 const size_t yHighBin = yLowBin + 1;
1877 ocean_assert(yHighBin <= this->binsY_);
1879 const TScalar yLowBinPosition = this->binTopLeftCornerPositionY(yLowBin);
1880 const TScalar yHighBinPosition = this->binTopLeftCornerPositionY(yHighBin);
1881 ocean_assert(yLowBinPosition < yHighBinPosition);
1883 const TScalar yFactor = (TScalar(y) - yLowBinPosition) / (yHighBinPosition - yLowBinPosition);
1886 const Vector2* lowBinValues = this->values_.
data() + (yLowBin * (this->binsX_ + 1));
1887 const Vector2* highBinValues = this->values_.
data() + (yHighBin * (this->binsX_ + 1));
1889 Vector2 leftBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1890 Vector2 rightBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1892 unsigned int nextBinX = 1u;
1894 TScalar leftBinPositionX = TScalar(0);
1895 TScalar rightBinPositionX = TScalar(nextBinX++ * this->sizeX_) * this->invBinsX_;
1898 TScalar invBinWidthX = TScalar(1) / (rightBinPositionX - leftBinPositionX);
1900 for (
size_t x = 0; x < this->sizeX_; ++x)
1902 if (TScalar(x) > rightBinPositionX)
1904 leftBinValue = rightBinValue;
1905 rightBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1907 leftBinPositionX = rightBinPositionX;
1908 rightBinPositionX = TScalar(nextBinX++ * this->sizeX_) * this->invBinsX_;
1911 invBinWidthX = TScalar(1) / (rightBinPositionX - leftBinPositionX);
1914 ocean_assert(leftBinPositionX <= TScalar(x));
1916 const TScalar xFactor = (TScalar(x) - leftBinPositionX) * invBinWidthX;
1918 if constexpr (std::is_same<TScalar, float>::value)
1927 values[x] = TTarget(leftBinValue * (TScalar(1) - xFactor) + rightBinValue * xFactor);
1930 const T debugTestValue = this->bilinearValue(TScalar(x), TScalar(y));
1931 const TScalar debugError = debugTestValue.distance(T(values[x]));
1932 ocean_assert(debugError < TScalar(0.1));
1937 template <
typename T,
typename TScalar>
1938 template <
typename TTarget>
1941 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
1942 ocean_assert(this->binsX_ <= this->sizeX_ && this->binsY_ <= this->sizeY_);
1944 ocean_assert(x + size <= this->sizeX_);
1946 ocean_assert(y < this->sizeY_);
1947 ocean_assert(values !=
nullptr);
1949 ocean_assert(size >= 1);
1951 const size_t xLowBin = (x * this->binsX_) / this->sizeX_;
1952 ocean_assert(xLowBin < this->binsX_);
1953 ocean_assert(std::abs(
int(xLowBin) -
int(this->binX(TScalar(x)))) <= 1);
1955 const size_t yLowBin = (y * this->binsY_) / this->sizeY_;
1956 ocean_assert(yLowBin < this->binsY_);
1957 ocean_assert(std::abs(
int(yLowBin) -
int(this->binY(TScalar(y)))) <= 1);
1959 const size_t yHighBin = yLowBin + 1;
1960 ocean_assert(yHighBin <= this->binsY_);
1962 const TScalar yLowBinPosition = this->binTopLeftCornerPositionY(yLowBin);
1963 const TScalar yHighBinPosition = this->binTopLeftCornerPositionY(yHighBin);
1964 ocean_assert(yLowBinPosition < yHighBinPosition);
1966 const TScalar yFactor = (TScalar(y) - yLowBinPosition) / (yHighBinPosition - yLowBinPosition);
1969 const Vector2* lowBinValues = this->values_.
data() + (yLowBin * (this->binsX_ + 1)) + xLowBin;
1970 const Vector2* highBinValues = this->values_.
data() + (yHighBin * (this->binsX_ + 1)) + xLowBin;
1972 Vector2 leftBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1973 Vector2 rightBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1975 size_t nextBinX = xLowBin + 1u;
1977 TScalar leftBinPositionX = TScalar(xLowBin * this->sizeX_) * this->invBinsX_;
1978 TScalar rightBinPositionX = TScalar(nextBinX++ * this->sizeX_) * this->invBinsX_;
1981 TScalar invBinWidthX = TScalar(1) / (rightBinPositionX - leftBinPositionX);
1983 for (
size_t nX = x; nX < x + size; ++nX)
1985 if (TScalar(nX) > rightBinPositionX)
1987 leftBinValue = rightBinValue;
1988 rightBinValue = *lowBinValues++ * (TScalar(1) - yFactor) + *highBinValues++ * yFactor;
1990 leftBinPositionX = rightBinPositionX;
1991 rightBinPositionX = TScalar(nextBinX++ * this->sizeX_) * this->invBinsX_;
1994 invBinWidthX = TScalar(1) / (rightBinPositionX - leftBinPositionX);
1999 const TScalar xFactor = (TScalar(nX) - leftBinPositionX) * invBinWidthX;
2002 *values++ = TTarget(leftBinValue * (TScalar(1) - xFactor) + rightBinValue * xFactor);
2005 const T debugTestValue = this->bilinearValue(TScalar(nX), TScalar(y));
2006 const TScalar debugError = debugTestValue.distance(T(TTarget(leftBinValue * (TScalar(1) - xFactor) + rightBinValue * xFactor)));
2007 ocean_assert(debugError < TScalar(0.1));
2012 template <
typename T,
typename TScalar>
2013 void LookupCorner2<T, TScalar>::bilinearValue(
const TScalar x,
const TScalar y, T& topLeft, T& topRight, T& bottomLeft, T& bottomRight, TScalar& factorTopLeft, TScalar& factorTopRight, TScalar& factorBottomLeft, TScalar& factorBottomRight)
const
2015 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
2016 ocean_assert(this->isInside(x, y));
2018 const size_t xLowBin = this->binX(x);
2019 const size_t yLowBin = this->binY(y);
2021 ocean_assert(xLowBin <= this->binsX_);
2022 ocean_assert(yLowBin <= this->binsY_);
2024 const TScalar leftPosition = this->binTopLeftCornerPositionX(xLowBin);
2025 const TScalar topPosition = this->binTopLeftCornerPositionY(yLowBin);
2027 const TScalar xFactor = (x - leftPosition) * TScalar(this->binsX_) * this->invSizeX_;
2028 const TScalar yFactor = (y - topPosition) * TScalar(this->binsY_) * this->invSizeY_;
2031 if (std::is_same<TScalar, float>::value)
2043 factorTopLeft = (TScalar(1) - xFactor) * (TScalar(1) - yFactor);
2044 factorTopRight = xFactor * (TScalar(1) - yFactor);
2045 factorBottomLeft = (TScalar(1) - xFactor) * yFactor;
2046 factorBottomRight = xFactor * yFactor;
2048 const size_t xHighBin = min(xLowBin + 1, this->binsX_);
2049 const size_t yHighBin = min(yLowBin + 1, this->binsY_);
2051 topLeft = this->binTopLeftCornerValue(xLowBin, yLowBin);
2052 topRight = this->binTopLeftCornerValue(xHighBin, yLowBin);
2053 bottomLeft = this->binTopLeftCornerValue(xLowBin, yHighBin);
2054 bottomRight = this->binTopLeftCornerValue(xHighBin, yHighBin);
2057 template <
typename T,
typename TScalar>
2060 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
2061 ocean_assert(this->isInside(x, y));
2063 const size_t xLowBin = this->binX(x);
2064 const size_t yLowBin = this->binY(y);
2066 ocean_assert(xLowBin <= this->binsX_);
2067 ocean_assert(yLowBin <= this->binsY_);
2069 const TScalar leftPosition = this->binTopLeftCornerPositionX(xLowBin);
2070 const TScalar topPosition = this->binTopLeftCornerPositionY(yLowBin);
2072 const TScalar xFactor = (x - leftPosition) * TScalar(this->binsX_) * this->invSizeX_;
2073 const TScalar yFactor = (y - topPosition) * TScalar(this->binsY_) * this->invSizeY_;
2076 if (std::is_same<TScalar, float>::value)
2088 const size_t xHighBin = min(xLowBin + 1, this->binsX_);
2089 const size_t yHighBin = min(yLowBin + 1, this->binsY_);
2092 const size_t xMinusBin = max(0,
int(xLowBin) - 1);
2093 const size_t xPlusBin = min(xLowBin + 2, this->binsX_);
2094 const size_t yMinusBin = max(0,
int(yLowBin) - 1);
2095 const size_t yPlusBin = min(yLowBin + 2, this->binsY_);
2097 return Interpolation::cubic(
Interpolation::cubic(binTopLeftCornerValue(xMinusBin, yMinusBin), binTopLeftCornerValue(xLowBin, yMinusBin), binTopLeftCornerValue(xHighBin, yMinusBin), binTopLeftCornerValue(xPlusBin, yMinusBin), xFactor),
2098 Interpolation::cubic(binTopLeftCornerValue(xMinusBin, yLowBin), binTopLeftCornerValue(xLowBin, yLowBin), binTopLeftCornerValue(xHighBin, yLowBin), binTopLeftCornerValue(xPlusBin, yLowBin), xFactor),
2099 Interpolation::cubic(binTopLeftCornerValue(xMinusBin, yHighBin), binTopLeftCornerValue(xLowBin, yHighBin), binTopLeftCornerValue(xHighBin, yHighBin), binTopLeftCornerValue(xPlusBin, yHighBin), xFactor),
2100 Interpolation::cubic(binTopLeftCornerValue(xMinusBin, yPlusBin), binTopLeftCornerValue(xLowBin, yPlusBin), binTopLeftCornerValue(xHighBin, yPlusBin), binTopLeftCornerValue(xPlusBin, yPlusBin), xFactor), yFactor);
2103 template <
typename T,
typename TScalar>
2106 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
2108 return nearestValue(minmax<TScalar>(0, x, TScalar(this->sizeX_)), minmax<TScalar>(0, y, TScalar(this->sizeY_)));
2111 template <
typename T,
typename TScalar>
2114 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
2116 return bilinearValue(minmax<TScalar>(0, x, TScalar(this->sizeX_)), minmax<TScalar>(0, y, TScalar(this->sizeY_)));
2119 template <
typename T,
typename TScalar>
2122 ocean_assert(this->binsX_ > 0 && this->binsY_ > 0);
2124 return bicubicValue(minmax<TScalar>(0, x, TScalar(this->sizeX_)), minmax<TScalar>(0, y, TScalar(this->sizeY_)));
2127 template <
typename T,
typename TScalar>
2130 ocean_assert(binX <= this->binsX_ && binY <= this->binsY_);
2131 this->values_[binY * (this->binsX_ + 1) + binX] = value;
2134 template <
typename T,
typename TScalar>
2139 for (
size_t n = 0; n < result.
values_.size(); ++n)
2147 template <
typename T,
typename TScalar>
2150 for (
size_t n = 0; n < this->values_.size(); ++n)
2152 this->values_[n] += offset;
2158 template <
typename T,
typename TScalar>
2163 for (
size_t n = 0; n < result.
values_.size(); ++n)
2171 template <
typename T,
typename TScalar>
2174 for (
size_t n = 0; n < this->values_.size(); ++n)
2176 this->values_[n] -= offset;
2182 template <
typename T,
typename TScalar>
2189 template <
typename T,
typename TScalar>
This class implements an advanced 2D lookup object with values at the bins' center positions defining...
Definition: Lookup2.h:424
void setBinCenterValid(const size_t binX, const size_t binY, const bool isValid)
Sets whether a specific lookup bin is valid.
Definition: Lookup2.h:1609
bool nearestValue(const TScalar x, const TScalar y, T &value) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1449
bool bilinearValue(const TScalar x, const TScalar y, T &value) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1468
ValidBins validBins_
The vector individually storing whether a bin is valid or not.
Definition: Lookup2.h:595
bool clampedBilinearValue(const TScalar x, const TScalar y, T &value) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:1592
bool operator!=(const AdvancedLookupCenter2< T, TScalar > &lookup) const
Returns whether two lookup objects are not identical.
Definition: Lookup2.h:1634
AdvancedLookupCenter2()=default
Creates a new empty lookup object.
std::vector< unsigned char > ValidBins
Definition of a vector holding 1 byte values.
Definition: Lookup2.h:430
void setBinCenterValue(const size_t binX, const size_t binY, const T &value, const bool isValid)
Sets the value of one specific lookup bin's center and defines whether this bin is valid.
Definition: Lookup2.h:1600
bool clampedNearestValue(const TScalar x, const TScalar y, T &value) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:1584
bool operator==(const AdvancedLookupCenter2< T, TScalar > &lookup) const
Returns whether two lookup objects are identical.
Definition: Lookup2.h:1628
bool binCenterValid(const size_t binX, const size_t binY) const
Returns whether a specific bin of this lookup object is valid.
Definition: Lookup2.h:1442
AdvancedLookupCenter2< T, TScalar > & operator=(AdvancedLookupCenter2< T, TScalar > &&lookup) noexcept
Move operator.
Definition: Lookup2.h:1616
static T cubic(const T &v0, const T &v1, const T &v2, const T &v3, const TFactor &t)
Performs a cubic (Catmull-Rom) interpolation between mainly two values while two further supporting p...
Definition: Interpolation.h:627
static T bilinear(const T &v00, const T &v01, const T &v10, const T &v11, const TFactor &tx, const TFactor &ty)
Performs a bi-linear interpolation between four values within a 2x2 neighborhood.
Definition: Interpolation.h:525
This class implements a 2D lookup object allowing to separate a two dimensional lookup area into indi...
Definition: Lookup2.h:30
Values values_
The values of the lookup bins.
Definition: Lookup2.h:169
std::vector< T > Values
Definition of a vector holding lookup values.
Definition: Lookup2.h:43
Lookup2< T, TScalar > & operator=(const Lookup2< T, TScalar > &lookup)
Assign operator.
Definition: Lookup2.h:965
TScalar invBinsY_
Inverse number of vertical bins.
Definition: Lookup2.h:166
size_t binsY_
Number of vertical bins.
Definition: Lookup2.h:154
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition: Lookup2.h:947
const T * data() const
Returns a pointer to the constant bin data (row aligned).
Definition: Lookup2.h:929
TScalar invSizeY_
Inverse vertical dimension of this lookup object.
Definition: Lookup2.h:160
T * data()
Returns a pointer to the bin data (row aligned).
Definition: Lookup2.h:935
size_t binsX_
Number of horizontal bins.
Definition: Lookup2.h:151
Lookup2(Lookup2< T, TScalar > &&lookup) noexcept
Move constructor.
Definition: Lookup2.h:906
Lookup2< T, TScalar > & operator=(Lookup2< T, TScalar > &&lookup) noexcept
Move operator.
Definition: Lookup2.h:981
size_t sizeX_
Horizontal dimension of this lookup object.
Definition: Lookup2.h:145
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition: Lookup2.h:941
bool operator==(const Lookup2< T, TScalar > &lookup) const
Returns whether two lookup objects are identical.
Definition: Lookup2.h:1021
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition: Lookup2.h:1009
size_t binsY() const
Returns the number of vertical bins of this lookup object.
Definition: Lookup2.h:959
size_t sizeY_
Vertical dimension of this lookup object.
Definition: Lookup2.h:148
Lookup2(const Lookup2< T, TScalar > &lookup)
Copy constructor.
Definition: Lookup2.h:891
TScalar invBinsX_
Inverse number of horizontal bins.
Definition: Lookup2.h:163
size_t binsX() const
Returns the number of horizontal bins of this lookup object.
Definition: Lookup2.h:953
T Type
Definition of the lookup data type.
Definition: Lookup2.h:36
bool operator!=(const Lookup2< T, TScalar > &lookup) const
Returns whether two lookup objects are not identical.
Definition: Lookup2.h:1027
TScalar invSizeX_
Inverse horizontal dimension of this lookup object.
Definition: Lookup2.h:157
Lookup2()=default
Creates a new empty lookup object.
This class implements a 2D lookup object with values at the bins' center positions defining the indiv...
Definition: Lookup2.h:198
T nearestValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1249
LookupCenter2< T, TScalar > & operator=(LookupCenter2< T, TScalar > &&lookup) noexcept
Move operator.
Definition: Lookup2.h:1387
void setBinCenterValue(const size_t binX, const size_t binY, const T &value)
Sets the value of one specific lookup bin's center.
Definition: Lookup2.h:1380
TScalar binCenterPositionY(const size_t binY) const
Returns the vertical center position of a specific bin in relation to the dimension of this lookup ob...
Definition: Lookup2.h:1216
T clampedBilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:1364
T clampedNearestValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:1356
T bicubicValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1309
LookupCenter2(const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY)
Creates a new lookup object by definition of the dimensions and bin numbers.
Definition: Lookup2.h:1047
size_t binY(const TScalar y) const
Returns the vertical bin that corresponds to a precise vertical lookup position.
Definition: Lookup2.h:1145
size_t binTopLeftY(const size_t binY) const
Returns the vertical top left position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1168
T clampedBicubicValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:1372
LookupCenter2(const LookupCenter2< T, TScalar > &lookup)
Copy constructor.
Definition: Lookup2.h:1033
size_t binBottomRightY(const size_t binY) const
Returns the vertical bottom right position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1192
LookupCenter2()=default
Creates a new empty lookup object.
LookupCenter2(LookupCenter2< T, TScalar > &&lookup) noexcept
Move constructor.
Definition: Lookup2.h:1040
TScalar binCenterPositionX(const size_t binX) const
Returns the horizontal center position of a specific bin in relation to the dimension of this lookup ...
Definition: Lookup2.h:1205
size_t binBottomRightX(const size_t binX) const
Returns the horizontal bottom right position (including) of a specified bin with pixel accuracy.
Definition: Lookup2.h:1179
size_t binTopLeftX(const size_t binX) const
Returns the horizontal top left position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1157
LookupCenter2(const size_t sizeX, const size_t sizeY, const LookupCenter2< T, TScalar > &lookup)
Creates a new lookup object by definition of the dimensions and a given lookup object.
Definition: Lookup2.h:1102
Vector2 binCenterPosition(const size_t binX, const size_t binY) const
Returns the center position of a specific bin in relation to the dimension of this lookup object.
Definition: Lookup2.h:1227
size_t binX(const TScalar x) const
Returns the horizontal bin that corresponds to a precise horizontal lookup position.
Definition: Lookup2.h:1133
const T & binCenterValue(const size_t binX, const size_t binY) const
Returns the lookup value of a specific bin's center of this lookup object.
Definition: Lookup2.h:1235
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1260
bool isInside(const TScalar x, const TScalar y) const
Returns whether a given position lies inside this lookup object and therefore whether this position c...
Definition: Lookup2.h:1126
LookupCenter2(const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const T *binValues)
Creates a new lookup object by definition of the dimensions and bin numbers.
Definition: Lookup2.h:1071
T & binCenterValue(const size_t binX, const size_t binY)
Returns the lookup value of a specific bin's center of this lookup object.
Definition: Lookup2.h:1242
This class implements a 2D lookup object with values at the bins' corners defining the individual loo...
Definition: Lookup2.h:636
LookupCorner2(LookupCorner2< T, TScalar > &&lookup) noexcept
Move constructor.
Definition: Lookup2.h:1647
T clampedNearestValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:2104
LookupCorner2()=default
Creates a new empty lookup object.
T clampedBicubicValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:2120
LookupCorner2< T, TScalar > & operator+=(const T &offset)
Adds an offset value to each lookup value.
Definition: Lookup2.h:2148
bool isInside(const TScalar x, const TScalar y) const
Returns whether a given position lies inside this lookup object and therefore whether this position c...
Definition: Lookup2.h:1733
LookupCorner2< T, TScalar > operator+(const T &offset) const
Adds an offset value to each lookup value.
Definition: Lookup2.h:2135
Vector2 binTopLeftCornerPosition(const size_t binX, const size_t binY) const
Returns the corner position (the top left corner) of a specific bin in relation to the dimension of t...
Definition: Lookup2.h:1786
const T & binTopLeftCornerValue(const size_t binX, const size_t binY) const
Returns the lookup value of a specific bin corner (the top left corner value) of this lookup object.
Definition: Lookup2.h:1794
size_t binX(const TScalar x) const
Returns the horizontal bin that corresponds to a precise horizontal lookup position.
Definition: Lookup2.h:1740
void bilinearValue(const TScalar x, const TScalar y, T &topLeft, T &topRight, T &bottomLeft, T &bottomRight, TScalar &factorTopLeft, TScalar &factorTopRight, TScalar &factorBottomLeft, TScalar &factorBottomRight) const
Applies a lookup for a specific position in this lookup object but does not apply the bilinear interp...
Definition: Lookup2.h:2013
LookupCorner2(const size_t sizeX, const size_t sizeY, const LookupCorner2< T, TScalar > &lookup)
Creates a new lookup object by definition of the dimensions and a given lookup object.
Definition: Lookup2.h:1709
void setBinTopLeftCornerValue(const size_t binX, const size_t binY, const T &value)
Sets the value of one specific lookup bin's top left corner.
Definition: Lookup2.h:2128
LookupCorner2< T, TScalar > & operator-=(const T &offset)
Subtracts an offset value from each lookup value.
Definition: Lookup2.h:2172
void bilinearValues(const size_t y, TTarget *values) const
Applies a lookup for an entire row in this lookup object.
Definition: Lookup2.h:1864
T nearestValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1801
T clampedBilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:2112
T bicubicValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:2058
size_t binY(const TScalar y) const
Returns the vertical bin that corresponds to a precise vertical lookup position.
Definition: Lookup2.h:1752
void bilinearValues(const size_t x, const size_t y, const size_t size, TTarget *values) const
Applies a lookup for a subset of a row in this lookup object.
Definition: Lookup2.h:1939
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1815
LookupCorner2(const LookupCorner2< T, TScalar > &lookup)
Copy constructor.
Definition: Lookup2.h:1640
LookupCorner2(const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const T *binCornerValues)
Creates a new lookup object by definition of the dimensions and bin numbers.
Definition: Lookup2.h:1678
LookupCorner2< T, TScalar > operator-(const T &offset) const
Subtracts an offset value from each lookup value.
Definition: Lookup2.h:2159
TScalar binTopLeftCornerPositionY(const size_t binY) const
Returns the vertical corner position of a specific bin corner (the top left corner) in relation to th...
Definition: Lookup2.h:1775
LookupCorner2(const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY)
Creates a new lookup object by definition of the dimensions and bin numbers.
Definition: Lookup2.h:1654
TScalar binTopLeftCornerPositionX(const size_t binX) const
Returns the horizontal corner position of a specific bin corner (the top left corner) in relation to ...
Definition: Lookup2.h:1764
LookupCorner2< T, TScalar > & operator=(LookupCorner2< T, TScalar > &&lookup) noexcept
Move operator.
Definition: Lookup2.h:2190
LookupCorner2< T, TScalar > & operator=(const LookupCorner2< T, TScalar > &lookup)
Copy operator.
Definition: Lookup2.h:2183
This class provides basic numeric functionalities.
Definition: Numeric.h:57
const T * data() const noexcept
Returns an pointer to the vector elements.
Definition: Vector2.h:722
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15