Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shapes.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2015: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG_shapes__
34#define __H__UG_shapes__
35
36#include "math_util.h"
37#include <iostream>
38
39namespace ug{
40
41template <class vector_t>
42class Sphere{
43 public:
44 Sphere() {}
45 Sphere(const vector_t& nCenter, number nRadius) :
46 center(nCenter), radius(nRadius) {}
47
49 bool contains_point(const vector_t& point) const;
50
52 bool intersects(const Sphere& sphere) const;
53
54 vector_t center;
56};
57
58
59template <class vector_t>
60struct AABox{
61 AABox() {}
62 AABox(const vector_t& nMin, const vector_t& nMax) : min(nMin), max(nMax) {}
63
65 AABox(const vector_t* points, size_t numPoints);
66
68 AABox(const AABox& b1, const AABox& b2);
69
71 AABox(const Sphere<vector_t>& s);
72
74 AABox(const AABox& b, const vector_t& v);
75
77 vector_t center() const;
78
80 vector_t extension() const;
81
83 bool contains_point(const vector_t& point) const;
84
86 bool overlaps_line(const vector_t& point1, const vector_t& point2) const;
87
88 vector_t min;
89 vector_t max;
90};
91
92
93template <class vector_t>
94std::ostream& operator << (std::ostream& out, const AABox<vector_t>& box) {
95 out << box.min << "-" << box.max;
96 return out;
97}
98
99}// end of namespace
100
101
102#include "shapes_impl.h"
103
104#endif
Definition shapes.h:42
bool intersects(const Sphere &sphere) const
returns true if the specified sphere touches or intersects this sphere.
Definition shapes_impl.h:47
Sphere()
Definition shapes.h:44
vector_t center
Definition shapes.h:54
Sphere(const vector_t &nCenter, number nRadius)
Definition shapes.h:45
number radius
Definition shapes.h:55
bool contains_point(const vector_t &point) const
returns true if the point lies inside or on the bounds of the rectangle
Definition shapes_impl.h:41
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition math_matrix.cpp:38
double number
Definition types.h:124
the ug namespace
Definition shapes.h:60
AABox()
Definition shapes.h:61
vector_t min
Definition shapes.h:88
vector_t max
Definition shapes.h:89
AABox(const vector_t &nMin, const vector_t &nMax)
Definition shapes.h:62
vector_t center() const
returns the center of the box
Definition shapes_impl.h:103
bool overlaps_line(const vector_t &point1, const vector_t &point2) const
return true if the given line (segment) and the box overlap
Definition shapes_impl.h:126
vector_t extension() const
returns the extension (width/height/depth) of the box
Definition shapes_impl.h:112
bool contains_point(const vector_t &point) const
returns true if the given point lies in the box or on its boundary
Definition shapes_impl.h:120