33 #ifndef OPENVDB_UTIL_MAPSUTIL_HAS_BEEN_INCLUDED 34 #define OPENVDB_UTIL_MAPSUTIL_HAS_BEEN_INCLUDED 52 template<
typename MapType>
61 corners[0] = in.
min();;
73 out_min = map.applyInverseMap(corners[0]);
75 for (
int i = 1; i < 8; ++i) {
76 pre_image = map.applyInverseMap(corners[i]);
77 for (
int j = 0; j < 3; ++j) {
78 out_min(j) =
std::min( out_min(j), pre_image(j));
79 out_max(j) =
std::max( out_max(j), pre_image(j));
87 template<
typename MapType>
108 Vec3d center_pre_image = map.applyInverseMap(center);
110 std::vector<Vec3d> coordinate_units;
111 coordinate_units.push_back(
Vec3d(1,0,0));
112 coordinate_units.push_back(
Vec3d(0,1,0));
113 coordinate_units.push_back(
Vec3d(0,0,1));
117 for (
int direction = 0; direction < 3; ++direction) {
118 Vec3d temp = map.applyIJT(coordinate_units[direction]);
120 radius * sqrt(temp.x()*temp.x() + temp.y()*temp.y() + temp.z()*temp.z());
121 out_min(direction) = center_pre_image(direction) - offset;
122 out_max(direction) = center_pre_image(direction) + offset;
130 BBoxd bounding_box(center - radius*
Vec3d(1,1,1), center + radius*
Vec3d(1,1,1));
131 calculateBounds<MapType>(map, bounding_box, out);
145 findTangentPoints(
const double g,
const double xo,
const double zo,
146 const double r,
double& xp,
double& zp,
double& xm,
double& zm)
152 double zd = g * zo + 1.;
156 double distA = xd2 + zd2;
157 double distB = distA - rd2;
160 double discriminate = sqrt(distB);
162 xp = xo - xo*rd2/distA + r * zd *discriminate / distA;
163 xm = xo - xo*rd2/distA - r * zd *discriminate / distA;
165 zp = (zo*zd2 + zd*g*(x2 - r2) - xo*xo*g - r*xd*discriminate) / distA;
166 zm = (zo*zd2 + zd*g*(x2 - r2) - xo*xo*g + r*xd*discriminate) / distA;
170 }
if (0 >= distB && distB >= -1e-9) {
173 zp = -1/g; zm = -1/g;
205 BBoxd bounding_box(center - radius*
Vec3d(1,1,1), center + radius*
Vec3d(1,1,1));
206 calculateBounds<math::NonlinearFrustumMap>(frustum, bounding_box, out);
218 double radiusLS = radius / voxelSize(0);
230 const double x_min = bbox.
min().
x();
231 const double y_min = bbox.
min().
y();
232 const double z_min = bbox.
min().
z();
234 const double x_max = bbox.
max().
x();
235 const double y_max = bbox.
max().
y();
236 const double z_max = bbox.
max().
z();
247 soln_number = findTangentPoints(gamma, centerLS.x(), centerLS.z(), radiusLS, xp, zp, xm, zm);
248 if (soln_number == 2) {
250 extreme.y() = centerLS.y();
254 extreme2 = secondMap.
applyMap(extreme);
260 extreme.y() = centerLS.y();
263 extreme2 = secondMap.
applyMap(extreme);
269 }
else if (soln_number == 1) {
271 }
else if (soln_number == 0) {
276 soln_number = findTangentPoints(gamma, centerLS.y(), centerLS.z(), radiusLS, xp, zp, xm, zm);
277 if (soln_number == 2) {
278 extreme.x() = centerLS.x();
283 extreme2 = secondMap.
applyMap(extreme);
288 extreme.x() = centerLS.x();
291 extreme2 = secondMap.
applyMap(extreme);
297 }
else if (soln_number == 1) {
299 }
else if (soln_number == 0) {
305 double near_dist =
std::max(centerLS.z() - radiusLS, 0.);
309 Vec3d near_point(0.f, 0.f, near_dist);
310 Vec3d far_point(0.f, 0.f, far_dist);
321 #endif // OPENVDB_UTIL_MAPSUTIL_HAS_BEEN_INCLUDED Map traits.
Definition: Maps.h:82
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:91
Vec3< double > Vec3d
Definition: Vec3.h:679
This map is composed of three steps. First it will take a box of size (Lx X Ly X Lz) defined by a mem...
Definition: Maps.h:1905
Vec3d voxelSize() const override
Return the lengths of the images of the segments (0,0,0)-(1,0,0), (0,0,0)-(0,1,0) and (0,...
Definition: Maps.h:493
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:445
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:443
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:2117
const BBoxd & getBBox() const
Return the bounding box that defines the frustum in pre-image space.
Definition: Maps.h:2377
void calculateBounds(const MapType &map, const Vec3d ¢er, const Real radius, BBoxd &out)
Calculate an axis-aligned bounding box in the given map's domain from a spherical bounding box in its...
Definition: MapsUtil.h:89
bool hasSimpleAffine() const
Return true if the second map is a uniform scale, Rotation and translation.
Definition: Maps.h:2386
T & z()
Definition: Vec3.h:112
T & y()
Definition: Vec3.h:111
Definition: Exceptions.h:40
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:89
const AffineMap & secondMap() const
Return MapBase::Ptr& to the second map.
Definition: Maps.h:2380
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
double getGamma() const
Definition: Maps.h:2374
A general linear transform using homogeneous coordinates to perform rotation, scaling,...
Definition: Maps.h:327
double Real
Definition: Types.h:67
double getDepth() const
Return the unscaled frustm depth.
Definition: Maps.h:2372
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec3.h:110