48 const double* pLow,
const double* pHigh,
49 const double* pVLow,
const double* pVHigh,
50 const IInterval& ivT, uint32_t dimension)
52 initialize(pLow, pHigh, pVLow, pVHigh, ivT.getLowerBound(), ivT.getUpperBound(), dimension);
56 const double* pLow,
const double* pHigh,
57 const double* pVLow,
const double* pVHigh,
58 double tStart,
double tEnd, uint32_t dimension)
60 initialize(pLow, pHigh, pVLow, pVHigh, tStart, tEnd, dimension);
73 ivT.getLowerBound(), ivT.getUpperBound(), low.
m_dimension);
79 double tStart,
double tEnd)
90 const Region& mbr,
const Region& vbr,
const IInterval& ivT)
99 const Region& mbr,
const Region& vbr,
double tStart,
double tEnd)
173 void MovingRegion::initialize(
174 const double* pLow,
const double* pHigh,
175 const double* pVLow,
const double* pVHigh,
176 double tStart,
double tEnd, uint32_t dimension)
187 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
210 memcpy(
m_pLow, pLow, m_dimension *
sizeof(
double));
211 memcpy(
m_pHigh, pHigh, m_dimension *
sizeof(
double));
212 memcpy(
m_pVLow, pVLow, m_dimension *
sizeof(
double));
213 memcpy(
m_pVHigh, pVHigh, m_dimension *
sizeof(
double));
252 m_pLow[i] < r.
m_pLow[i] - std::numeric_limits<double>::epsilon() ||
253 m_pLow[i] > r.
m_pLow[i] + std::numeric_limits<double>::epsilon() ||
254 m_pHigh[i] < r.
m_pHigh[i] - std::numeric_limits<double>::epsilon() ||
255 m_pHigh[i] > r.
m_pHigh[i] + std::numeric_limits<double>::epsilon() ||
256 m_pVLow[i] < r.
m_pVLow[i] - std::numeric_limits<double>::epsilon() ||
257 m_pVLow[i] > r.
m_pVLow[i] + std::numeric_limits<double>::epsilon() ||
267 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
353 assert(ivPeriod.getLowerBound() < ivPeriod.getUpperBound());
368 if (tmax <= tmin)
return false;
370 tmin = std::max(tmin, ivPeriod.getLowerBound());
371 tmax = std::min(tmax, ivPeriod.getUpperBound());
374 if (tmax <= tmin)
return false;
376 assert(tmax < std::numeric_limits<double>::max());
377 assert(tmin > -std::numeric_limits<double>::max());
382 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
385 tmin >= ivPeriod.getLowerBound() && tmax <= ivPeriod.getUpperBound() &&
422 assert(tmin <= tmax);
426 tmin >= ivPeriod.getLowerBound() && tmax <= ivPeriod.getUpperBound() &&
430 ivOut.setBounds(tmin, tmax);
451 double tmin = std::max(ivPeriod.getLowerBound(), r.
m_startTime);
452 double tmax = std::min(ivPeriod.getUpperBound(), r.
m_endTime);
456 if (tmax <= tmin || tmin < m_startTime || tmax >
m_endTime)
return false;
458 double intersectionTime;
463 tmin >= ivPeriod.getLowerBound() && tmax <= ivPeriod.getUpperBound() &&
467 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
478 if (tmin < intersectionTime && intersectionTime < tmax)
return false;
479 if (tmin == intersectionTime && r.
m_pVHigh[cDim] >
m_pVHigh[cDim])
return false;
486 if (tmin < intersectionTime && intersectionTime < tmax)
return false;
487 if (tmin == intersectionTime && r.
m_pVLow[cDim] <
m_pVLow[cDim])
return false;
511 double tmin = std::max(ivI.getLowerBound(),
m_startTime);
512 double tmax = std::min(ivI.getUpperBound(),
m_endTime);
514 assert(tmin > -std::numeric_limits<double>::max());
515 assert(tmax < std::numeric_limits<double>::max());
516 assert(tmin <= tmax);
518 if (tmin >= tmax - std::numeric_limits<double>::epsilon() &&
519 tmin <= tmax + std::numeric_limits<double>::epsilon())
522 double dx1, dx2, dx3;
523 double dv1, dv2, dv3;
524 double H = tmax - tmin;
535 H * (dx1 + dx2 + dx3 + dx1*dx2 + dx1*dx3 + dx2*dx3) +
536 H*H * (dv1 + dv2 + dv3 + dx1*dv2 + dv1*dx2 + dx1*dv3 +
537 dv1*dx3 + dx2*dv3 + dv2*dx3) / 2.0 +
538 H*H*H * (dv1*dv2 + dv1*dv3 + dv2*dv3) / 3.0;
546 return H * (dx1 + dx2) + H * H * (dv1 + dv2) / 2.0;
571 assert(ivI.getLowerBound() < ivI.getUpperBound());
577 if (tmax <= tmin)
return 0.0;
579 tmin = std::max(tmin, ivI.getLowerBound());
580 tmax = std::min(tmax, ivI.getUpperBound());
583 if (tmax <= tmin)
return 0.0;
585 assert(tmax < std::numeric_limits<double>::max());
586 assert(tmin > -std::numeric_limits<double>::max());
588 if (tmin >= tmax - std::numeric_limits<double>::epsilon() &&
589 tmin <= tmax + std::numeric_limits<double>::epsilon())
592 double H = tmax - tmin;
596 double a = 0.0, b = 0.0, c = 0.0, f = 0.0, l = 0.0, m = 0.0, n = 0.0;
598 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
608 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
610 a += dv[cDim] * dv[cDim];
611 b += 2.0 * dx[cDim] * dv[cDim];
612 c += dx[cDim] * dx[cDim];
618 if (a == 0.0 && c == 0.0)
return 0.0;
619 if (a == 0.0)
return H * std::sqrt(c);
620 if (c == 0.0)
return H * H * std::sqrt(a) / 2.0;
622 f = std::sqrt(a * H * H + b * H + c);
624 m = 4.0 * a * c - b * b;
625 n = 2.0 * std::sqrt(a);
627 return (l * f + log(l / n + f) * m / n - b * std::sqrt(c) - std::log(b / n + std::sqrt(c)) * m / n) / (4.0 * a);
654 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
685 assert(ivPeriod.getLowerBound() < ivPeriod.getUpperBound());
698 if (tmax <= tmin)
return false;
700 tmin = std::max(tmin, ivPeriod.getLowerBound());
701 tmax = std::min(tmax, ivPeriod.getUpperBound());
704 if (tmax <= tmin)
return false;
706 assert(tmax < std::numeric_limits<double>::max());
707 assert(tmin > -std::numeric_limits<double>::max());
709 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
712 tmin >= ivPeriod.getLowerBound() && tmax <= ivPeriod.getUpperBound() &&
746 if (tmin > tmax)
return false;
749 ivOut.setBounds(tmin, tmax);
770 double tmin = std::max(ivPeriod.getLowerBound(), p.
m_startTime);
771 double tmax = std::min(ivPeriod.getUpperBound(), p.
m_endTime);
774 if (tmax <= tmin || tmin < m_startTime || tmax >
m_endTime)
return false;
776 double intersectionTime;
779 tmin >= ivPeriod.getLowerBound() && tmax <= ivPeriod.getUpperBound() &&
783 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
793 if (tmin < intersectionTime && intersectionTime < tmax)
return false;
801 if (tmin < intersectionTime && intersectionTime < tmax)
return false;
802 if (tmin == intersectionTime && p.
m_pVCoords[cDim] <
m_pVLow[cDim])
return false;
813 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
839 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
873 assert(ivI.getLowerBound() < ivI.getUpperBound());
880 if (tmax <= tmin)
return 0.0;
882 tmin = std::max(tmin, ivI.getLowerBound());
883 tmax = std::min(tmax, ivI.getUpperBound());
886 if (tmax <= tmin)
return 0.0;
888 assert(tmax < std::numeric_limits<double>::max());
889 assert(tmin > -std::numeric_limits<double>::max());
899 assert(tmin <= tmax);
901 assert(tmin >= ivI.getLowerBound() && tmax <= ivI.getUpperBound());
915 std::priority_queue < CrossPoint, std::vector<CrossPoint>, decltype(ascending)> pq(ascending);
930 assert(c.
m_t >= tmin && c.
m_t <= tmax);
945 assert(c.
m_t >= tmin && c.
m_t <= tmax);
961 assert(c.
m_t >= tmin && c.
m_t <= tmax);
976 assert(c.
m_t >= tmin && c.
m_t <= tmax);
986 double _t = -std::numeric_limits<double>::max();
991 c = pq.top(); pq.pop();
1033 return (
sizeof(uint32_t) + 2 *
sizeof(
double) + 4 *
m_dimension *
sizeof(
double));
1040 memcpy(&dimension, ptr,
sizeof(uint32_t));
1041 ptr +=
sizeof(uint32_t);
1043 ptr +=
sizeof(double);
1044 memcpy(&
m_endTime, ptr,
sizeof(
double));
1045 ptr +=
sizeof(double);
1061 *data =
new uint8_t[len];
1062 uint8_t* ptr = *data;
1065 ptr +=
sizeof(uint32_t);
1067 ptr +=
sizeof(double);
1068 memcpy(ptr, &
m_endTime,
sizeof(
double));
1069 ptr +=
sizeof(double);
1094 for (uint32_t cDim = 0; cDim <
m_dimension; ++cDim)
1112 double tmin = std::max(ivI.getLowerBound(),
m_startTime);
1113 double tmax = std::min(ivI.getUpperBound(),
m_endTime);
1115 assert(tmin > -std::numeric_limits<double>::max());
1116 assert(tmax < std::numeric_limits<double>::max());
1117 assert(tmin <= tmax);
1119 if (tmin >= tmax - std::numeric_limits<double>::epsilon() &&
1120 tmin <= tmax + std::numeric_limits<double>::epsilon())
1123 double dx1, dx2, dx3;
1124 double dv1, dv2, dv3;
1125 double H = tmax - tmin;
1136 H * dx1 * dx2 * dx3 + H * H * (dx1 * dx2 * dv3 + (dx1 * dv2 + dv1 * dx2) * dx3) / 2.0 +
1137 H * H * H * ((dx1 * dv2 + dv1 * dx2) * dv3 + dv1 * dv2 * dx3) / 3.0 + H * H * H * H * dv1 * dv2 * dv3 / 4.0;
1145 return H * dx1 * dx2 + H * H * (dx1 * dv2 + dv1 * dx2) / 2.0 + H * H * H * dv1 * dv2 / 3.0;
1151 return H * dx1 + H * H * dv1 / 2.0;
1175 for (uint32_t cIndex = 0; cIndex <
m_dimension; ++cIndex)
1177 m_pLow[cIndex] = std::numeric_limits<double>::max();
1178 m_pHigh[cIndex] = -std::numeric_limits<double>::max();
1179 m_pVLow[cIndex] = std::numeric_limits<double>::max();
1180 m_pVHigh[cIndex] = -std::numeric_limits<double>::max();
1183 m_startTime = -std::numeric_limits<double>::max();
1184 m_endTime = std::numeric_limits<double>::max();
1213 os << r.
m_pLow[i] <<
" ";
virtual MovingRegion & operator=(const MovingRegion &r)
virtual bool intersectsRegionAtTime(double t, const MovingRegion &r) const
virtual double getLow(uint32_t index, double t) const
virtual double getExtrapolatedHigh(uint32_t index, double t) const
void makeDimension(uint32_t dimension) override
virtual bool containsRegionInTime(const MovingRegion &r) const
const MovingRegion * m_to
virtual void makeDimension(uint32_t dimension)
virtual double getExtrapolatedLow(uint32_t index, double t) const
void makeInfinite(uint32_t dimension) override
virtual bool intersectsPointInTime(const MovingPoint &p) const
void storeToByteArray(uint8_t **data, uint32_t &len) override
void getMBRAtTime(double t, Region &out) const override
virtual bool containsPointInTime(const MovingPoint &p) const
virtual bool containsRegionAtTime(double t, const MovingRegion &r) const
virtual double getCenterDistanceInTime(const MovingRegion &r) const
void getVMBR(Region &out) const override
virtual double getProjectedSurfaceAreaInTime() const
virtual double getVCoord(uint32_t index) const
virtual double getIntersectingAreaInTime(const MovingRegion &r) const
double getAreaInTime() const override
virtual void getCombinedRegionAfterTime(double t, MovingRegion &out, const MovingRegion &in) const
SIDX_DLL std::ostream & operator<<(std::ostream &os, const Ball &ball)
virtual void combineRegionAfterTime(double t, const MovingRegion &r)
virtual double getProjectedCoord(uint32_t index, double t) const
void loadFromByteArray(const uint8_t *data) override
MovingRegion * clone() override
virtual double getVLow(uint32_t index) const
virtual bool operator==(const MovingRegion &) const
virtual void getCombinedRegionInTime(MovingRegion &out, const MovingRegion &in) const
uint32_t getByteArraySize() override
virtual void combineRegionInTime(const MovingRegion &r)
virtual bool containsRegionAfterTime(double t, const MovingRegion &r) const
virtual double getHigh(uint32_t index, double t) const
virtual double getVHigh(uint32_t index) const
virtual bool intersectsRegionInTime(const MovingRegion &r) const