Library of Assembled Shared Sources
prim_common.h
Go to the documentation of this file.
1/** @file
2 * @author Bram de Greve (bram@cocamware.com)
3 * @author Tom De Muer (tom@cocamware.com)
4 *
5 * *** BEGIN LICENSE INFORMATION ***
6 *
7 * The contents of this file are subject to the Common Public Attribution License
8 * Version 1.0 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://lass.sourceforge.net/cpal-license. The License is based on the
11 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
12 * use of software over a computer network and provide for limited attribution for
13 * the Original Developer. In addition, Exhibit A has been modified to be consistent
14 * with Exhibit B.
15 *
16 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
17 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
18 * language governing rights and limitations under the License.
19 *
20 * The Original Code is LASS - Library of Assembled Shared Sources.
21 *
22 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
23 * The Original Developer is the Initial Developer.
24 *
25 * All portions of the code written by the Initial Developer are:
26 * Copyright (C) 2004-2011 the Initial Developer.
27 * All Rights Reserved.
28 *
29 * Contributor(s):
30 *
31 * Alternatively, the contents of this file may be used under the terms of the
32 * GNU General Public License Version 2 or later (the GPL), in which case the
33 * provisions of GPL are applicable instead of those above. If you wish to allow use
34 * of your version of this file only under the terms of the GPL and not to allow
35 * others to use your version of this file under the CPAL, indicate your decision by
36 * deleting the provisions above and replace them with the notice and other
37 * provisions required by the GPL License. If you do not delete the provisions above,
38 * a recipient may use your version of this file under either the CPAL or the GPL.
39 *
40 * *** END LICENSE INFORMATION ***
41 */
42
43
44
45/** @namespace lass::prim
46 * @brief set of geometrical primitives
47 * @author Bram de Greve [BdG]
48 * @date 2003
49 *
50 * lass::prim is the library for geometrical primitives and related constructions. It
51 * consists of structures and classes to represent primitives as vectors, points, lines,
52 * planes, polygons etc., some policy classes that can modify the implementation of some of
53 * these primitives, and a few related enumerations.
54 *
55 * All primitives are templated with an underlying value type (think of floats, doubles,
56 * fixed point, ...). This value type can be set as by the template parameter @a T, and is
57 * typedef'ed in all primitives as @c TValue (convenient, isn't it? :). It's the subatomic unit
58 * (proton if you like) on which more complex types are built.
59 *
60 * @section overview
61 *
62 * I think the best way to explore this library, is to give an overview of its components.
63 * Here we go ...
64 *
65 * @subsection primitives
66 *
67 * If @c TValue is the proton, then vectors are the smallest atomic units in lass::prim you
68 * can build. Vectors represent a direction, a translation, and we have three of them
69 * in our library (with 2, 3 and 4 protons respective :):
70 *
71 * - Vector2D: a two dimensional vector.
72 * - Vector3D: a three dimensional vector.
73 * - Vector4D: a four dimensional vector.
74 *
75 * The above vectors are free vectors and have no position. To express the position of
76 * a location in space, we need points. we have two of these thingies. It's a little
77 * unusual to distinguish between vectors and points. Usually, only one is used for both
78 * concepts, whether they uses @e point or @e vector. Yet, these are totally different
79 * mathematical entities. You can add two vectors together, but you can't add two points
80 * (what would it mean?). Transforming a vector is different that a point (a vector will
81 * only be rotated, a point will also be translated). Points and vectors are clearly to
82 * be traited differently. This cries for different classes or structures. In C however, it has
83 * little use to do that, because of the lack of function overloading and strong type checking.
84 * However, here we are in C++ and the good news is: C++ does have overloading and strong
85 * type checking, so we can clearly distinguish between points and vectors in our code.
86 * And that's what we do here. For more info on this subject, I gladly refer to [1, 2, 3].
87 * You can see the points as ions: vectors with some extra (or lacking) electrons:
88 * same number of protons (same dimension), but not completely the same thing.
89 *
90 * - Point2D: a two dimensional point.
91 * - Point3D: a three dimensional point.
92 *
93 * One problem of not being able to add and scale points is not being able to use barycentric
94 * combinations. This is a linear combination of points in which the sum of all weight is
95 * equal to 1. The result of such a combination is a point and is mathematical sensefull.
96 * In [1], I didn't find a satisfying solution to this problem, because I wanted to limit
97 * myself to eucledian entities. To do barycentric combinations, I had to convert the points
98 * to vectors, do the combination, and the convert back to a point. Not only this is a bit
99 * clumsy, it didn't guarantee that the sum of the weights would be 1. In [2], I introduced
100 * homogenous points to solve this question. And they are also introduced in here.
101 * Homogenous points are with the sole capability to do barycentric combinations on points.
102 * You can see the homogenous points as points with some extra neutrons: pretty compatible.
103 *
104 * - Point2DH: a homogenous representation of a two dimensional point.
105 * - Point3DH: a homogenous representation of a three dimensional point.
106 *
107 * So far for the essential building blocks of the more complex primitives. Until now we had
108 * the atoms, now we'll build moleculs. The simplest thing we can construct from it are
109 * axis-aligned-bounding-boxes.
110 *
111 * - Aabb2D: a two dimensional axis aligned boundig box ... or a rectangle :)
112 * - Aabb3D: a three dimensional axis aligned bounding box.
113 *
114 * Objects of infinite size are lines and planes. We have them in parametric and cartesian
115 * versions.
116 *
117 * - Line2D: a two dimensional line with different implementation policies, or a half plane.
118 * - Line3D: a three dimensional parametric line.
119 * - Plane3D: a three dimensional plane with different implementation policies, or a half space.
120 *
121 * For the circular guys:
122 *
123 * - Sphere3D: a sphere!
124 *
125 * Objects of not so infinite size: line segments and rays.
126 *
127 * - LineSegment2D: a two dimensional line segment
128 * - LineSegment3D: a three dimensional line segment
129 * - Ray2D: a two dimensional ray (or a half line)
130 * - Ray3D: a three dimensional ray (or a half line in 3D)
131 *
132 * Polygons and stuff:
133 *
134 * - SimplePolygon2D: a two dimensional convex/concave polygon
135 * - SimplePolygon3D: a three dimensional convex/concave polygon
136 * - Triangle2D: a two dimensional polygon with three vertices
137 * - Triangle3D: a three dimensional polygon with three vertices
138 *
139 * @subsection policies
140 *
141 * - @ref NormalizingPolicy: Normalized, Unnormalized
142 * - @ref ParameterPolicy: Bounded, Unbounded
143 * - @ref MinMaxPolicy: StrictMinMax, AutoMinMax
144 * - @ref EquationPolicy: Cartesian, Parametric, Combined
145 *
146 * @subsection enumerations
147 *
148 * - @ref Result
149 * - @ref Side
150 * - @ref Orientation
151 *
152 * @subsection colors
153 *
154 * - ColorRGBA: a four dimensional color with floating point channels red, green, blue and alpha.
155 *
156 * @subsection iterators
157 *
158 * These three classes are iterators over the different axes (components). You can use
159 * this instead of directly calling the @c .x or @c .y members of a vector. With
160 * these iterators, you can access those components through the @c operator[] .
161 *
162 * - XY
163 * - XYZ
164 * - XYZW
165 */
166
167
168
169
170/** @namespace lass::prim::impl
171 * @brief implementation details of lass::prim
172 * @author BdG
173 * @date 2003
174 *
175 * @warning nothing for the faint hearted :)
176 */
177
178
179
180#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PRIM_COMMON_H
181#define LASS_GUARDIAN_OF_INCLUSION_PRIM_PRIM_COMMON_H
182
183
184
185#include "../lass_common.h"
186
187#include "../num/num_traits.h"
188#include "../util/call_traits.h"
189
190#include "result.h"
191#include "side.h"
192
193namespace lass
194{
195namespace prim
196{
197
198}
199}
200
201#endif
set of geometrical primitives
Definition aabb_2d.h:81
Library for Assembled Shared Sources.
Definition config.h:53