Library of Assembled Shared Sources
ray_3d.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/** @class lass::prim::Ray3D
46 * @brief 3D Ray
47 * @author Bram de Greve [BdG]
48 * @date 2003
49 */
50
51
52
53#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_H
54#define LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_H
55
56
57
58
59#include "prim_common.h"
60#include "normalizing_policy.h"
61#include "parameter_policy.h"
62#include "point_3d.h"
63
64
65
66namespace lass
67{
68
69namespace prim
70{
71
72template
73<
74 typename T,
75 class NormalizingPolicy = Normalized,
76 class ParameterPolicy = Bounded
77>
78class LASS_SIMD_ALIGN Ray3D
79{
80public:
81
82 typedef Ray3D<T, NormalizingPolicy, ParameterPolicy> TSelf;
83 typedef NormalizingPolicy TNormalizingPolicy;
84 typedef ParameterPolicy TParameterPolicy;
85
86 typedef Point3D<T> TPoint;
87 typedef typename TPoint::TVector TVector;
88
89 typedef typename TPoint::TValue TValue;
90 typedef typename TPoint::TParam TParam;
91 typedef typename TPoint::TReference TReference;
92 typedef typename TPoint::TConstReference TConstReference;
93 typedef typename TPoint::TNumTraits TNumTraits;
94
95 enum { dimension = TPoint::dimension }; /**< number of dimensions */
96
97 template <typename U> struct Rebind
98 {
99 typedef Ray3D<U, NormalizingPolicy, ParameterPolicy> Type;
100 };
101
102 // STRUCTORS
103
104 Ray3D();
105 Ray3D(const TPoint& iSupport, const TVector& iDirection);
106 Ray3D(const TPoint& iSupport, const TVector& iNormalizedDirection, IsAlreadyNormalized);
107 Ray3D(const TPoint& iSupport, const TPoint& iLookAt);
108 template <typename NP2, typename PP2> Ray3D(const Ray3D<T, NP2, PP2>& iOther);
109
110 // METHODS
111
112 const TPoint& support() const;
113 TPoint& support();
114
115 const TVector& direction() const;
116 void setDirection(const TVector& iDirection);
117 void lookAt(const TPoint& iLookAt);
118
119 const TPoint point(TParam a_t) const;
120 const TValue t(const TPoint& iPoint) const;
121
122 const TVector project(const TVector& iVector) const;
123 const TVector reject(const TVector& iVector) const;
124 const TVector reflect(const TVector& iVector) const;
125 const TPoint project(const TPoint& iPoint) const;
126 const TVector reject(const TPoint& iPoint) const;
127 const TPoint reflect(const TPoint& iPoint) const;
128
129 bool isValid() const;
130
131private:
132
133 TPoint support_;
134 TVector direction_;
135};
136
137
138
139template<typename T, class NP, class PP>
140std::ostream& operator<<(std::ostream& oOStream, const Ray3D<T, NP, PP>& iB);
141
142template<typename T, class NP, class PP>
143io::XmlOStream& operator<<(io::XmlOStream& oOStream, const Ray3D<T, NP, PP>& iB);
144
145
146
147}
148
149}
150
151#include "ray_3d.inl"
152
153#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_H
154# include "aabb_3d_ray_3d.h"
155#endif
156
157#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_DISK_3D_H
158# include "disk_3d_ray_3d.h"
159#endif
160
161#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_PARALLELOGRAM_3D_H
163#endif
164
165#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_PLANE_3D_H
166# include "plane_3d_ray_3d.h"
167#endif
168
169#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_POLYGON_3D_H
171#endif
172
173#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_SPHERE_3D_H
174# include "ray_3d_sphere_3d.h"
175#endif
176
177#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_3D_H
179#endif
180
181#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRIANGLE_3D_H
182# include "ray_3d_triangle_3d.h"
183#endif
184
185#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_SEGMENT_3D_H
186# include "line_segment_3d_ray_3d.h"
187#endif
188
189#endif
190
191// EOF
Output stream for writing a selection of geometric primitives to XML files.
TPoint & support()
access origin of ray the origin is also the support point of the ray.
Definition ray_3d.inl:130
const TVector & direction() const
Return direction of ray.
Definition ray_3d.inl:141
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
Definition ray_3d.inl:151
const TPoint & support() const
return origin of ray.
Definition ray_3d.inl:118
void lookAt(const TPoint &iLookAt)
Set direction from origin to look-at point.
Definition ray_3d.inl:162
const TPoint project(const TPoint &iPoint) const
Project point on the axis of the ray.
Definition ray_3d.inl:239
const TVector reject(const TVector &iVector) const
Reject vector against the axis of the ray.
Definition ray_3d.inl:216
bool isValid() const
Return true if ray is valid (direction isn't a zero vector).
Definition ray_3d.inl:271
const TPoint reflect(const TPoint &iPoint) const
Reject point against the axis of the ray.
Definition ray_3d.inl:261
const TVector reflect(const TVector &iVector) const
Reflect vector against the axis of the ray.
Definition ray_3d.inl:227
const TValue t(const TPoint &iPoint) const
Return parameter of point on the ray that is the projection of the given point.
Definition ray_3d.inl:190
const TVector reject(const TPoint &iPoint) const
Reject point against the axis of the ray.
Definition ray_3d.inl:250
const TPoint point(TParam a_t) const
Return point on ray by it's parameter.
Definition ray_3d.inl:177
const TVector project(const TVector &iVector) const
Project vector on the axis of the ray.
Definition ray_3d.inl:205
#define LASS_SIMD_ALIGN
if LASS_SIMD_ALIGNMENT is set, use LASS_SIMD_ALIGN to align some structures on SIMD alignment boundar...
set of geometrical primitives
Definition aabb_2d.h:81
Library for Assembled Shared Sources.
Definition config.h:53
Parameters supplied to functions must be in the range of the primitive.
Policy to auto-normalize normals.