Loading...
Searching...
No Matches
Box.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef IGNITION_MATH_BOX_HH_
18#define IGNITION_MATH_BOX_HH_
19
20#include <iostream>
21#include <tuple>
25#include <ignition/math/config.hh>
26
27namespace ignition
28{
29 namespace math
30 {
31 inline namespace IGNITION_MATH_VERSION_NAMESPACE
32 {
33 // Forward declaration of private data
34 class BoxPrivate;
35
38 class IGNITION_MATH_VISIBLE Box
39 {
46 public: Box();
47
52 public: Box(const Vector3d &_vec1, const Vector3d &_vec2);
53
62 public: Box(double _vec1X, double _vec1Y, double _vec1Z,
63 double _vec2X, double _vec2Y, double _vec2Z);
64
67 public: Box(const Box &_b);
68
70 public: virtual ~Box();
71
74 public: double XLength() const;
75
78 public: double YLength() const;
79
82 public: double ZLength() const;
83
86 public: math::Vector3d Size() const;
87
90 public: math::Vector3d Center() const;
91
94 public: void Merge(const Box &_box);
95
99 public: Box &operator=(const Box &_b);
100
104 public: Box operator+(const Box &_b) const;
105
109 public: const Box &operator+=(const Box &_b);
110
114 public: bool operator==(const Box &_b) const;
115
119 public: bool operator!=(const Box &_b) const;
120
124 public: Box operator-(const Vector3d &_v);
125
130 public: friend std::ostream &operator<<(std::ostream &_out,
131 const ignition::math::Box &_b)
132 {
133 _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
134 return _out;
135 }
136
139 public: const Vector3d &Min() const;
140
143 public: const Vector3d &Max() const;
144
147 public: Vector3d &Min();
148
151 public: Vector3d &Max();
152
158 public: bool Intersects(const Box &_box) const;
159
163 public: bool Contains(const Vector3d &_p) const;
164
171 public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
172 const double _min, const double _max) const;
173
189 public: std::tuple<bool, double> IntersectDist(
190 const Vector3d &_origin, const Vector3d &_dir,
191 const double _min, const double _max) const;
192
210 public: std::tuple<bool, double, Vector3d> Intersect(
211 const Vector3d &_origin, const Vector3d &_dir,
212 const double _min, const double _max) const;
213
222 public: std::tuple<bool, double, Vector3d> Intersect(
223 const Line3d &_line) const;
224
231 private: bool ClipLine(const int _d, const Line3d &_line,
232 double &_low, double &_high) const;
233
235 private: BoxPrivate *dataPtr;
236 };
237 }
238 }
239}
240#endif
Mathematical representation of a box and related functions.
Definition Box.hh:39
Box operator+(const Box &_b) const
Addition operator.
const Vector3d & Min() const
Get the minimum corner.
bool Contains(const Vector3d &_p) const
Check if a point lies inside the box.
friend std::ostream & operator<<(std::ostream &_out, const ignition::math::Box &_b)
Output operator.
Definition Box.hh:130
bool operator!=(const Box &_b) const
Inequality test operator.
std::tuple< bool, double, Vector3d > Intersect(const Line3d &_line) const
Check if a line intersects the box.
const Box & operator+=(const Box &_b)
Addition set operator.
bool operator==(const Box &_b) const
Equality test operator.
Vector3d & Max()
Get a mutable version of the maximum corner.
const Vector3d & Max() const
Get the maximum corner.
math::Vector3d Size() const
Get the size of the box.
Box & operator=(const Box &_b)
Assignment operator.
Box operator-(const Vector3d &_v)
Subtract a vector from the min and max values.
void Merge(const Box &_box)
Merge a box with this box.
bool Intersects(const Box &_box) const
Test box intersection.
double ZLength() const
Get the length along the z dimension.
math::Vector3d Center() const
Get the box center.
Vector3d & Min()
Get a mutable version of the minimum corner.
std::tuple< bool, double, Vector3d > Intersect(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
double YLength() const
Get the length along the y dimension.
Box(const Vector3d &_vec1, const Vector3d &_vec2)
Constructor.
double XLength() const
Get the length along the x dimension.
bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
std::tuple< bool, double > IntersectDist(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
Box(double _vec1X, double _vec1Y, double _vec1Z, double _vec2X, double _vec2Y, double _vec2Z)
Constructor.
A three dimensional line segment.
Definition Line3.hh:35
The Vector3 class represents the generic vector containing 3 elements.
Definition Vector3.hh:40
Definition Angle.hh:40