Library of Assembled Shared Sources
ray_2d.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/** @class lass::prim::Ray2D
45 * @brief 2D Ray
46 * @author Bram de Greve [BdG]
47 * @date 2003
48 */
49
50
51
52#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_2D_H
53#define LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_2D_H
54
55
56
57
58#include "prim_common.h"
59#include "normalizing_policy.h"
60#include "parameter_policy.h"
61#include "point_2d.h"
62
63
64
65namespace lass
66{
67
68namespace prim
69{
70
71template
72<
73 typename T,
74 class NormalizingPolicy = Normalized,
75 class ParameterPolicy = Bounded
76>
77class LASS_SIMD_ALIGN Ray2D
78{
79public:
80
81 typedef Ray2D<T, NormalizingPolicy, ParameterPolicy> TSelf;
82 typedef NormalizingPolicy TNormalizingPolicy;
83 typedef ParameterPolicy TParameterPolicy;
84
85 typedef Point2D<T> TPoint;
86 typedef typename TPoint::TVector TVector;
87
88 typedef typename TPoint::TValue TValue;
89 typedef typename TPoint::TParam TParam;
90 typedef typename TPoint::TReference TReference;
91 typedef typename TPoint::TConstReference TConstReference;
92 typedef typename TPoint::TNumTraits TNumTraits;
93
94 enum { dimension = TPoint::dimension }; /**< number of dimensions */
95
96 template <typename U> struct Rebind
97 {
98 typedef Ray2D<U, NormalizingPolicy, ParameterPolicy> Type;
99 };
100
101 // STRUCTORS
102
103 Ray2D();
104 Ray2D(const TPoint& iSupport, const TVector& iDirection);
105 Ray2D(const TPoint& iSupport, const TPoint& iLookAt);
106
107 // METHODS
108
109 const TPoint& support() const;
110 TPoint& support();
111
112 const TVector& direction() const;
113 void setDirection(const TVector& iDirection);
114 void lookAt(const TPoint& iLookAt);
115
116 const TPoint point(TParam a_t) const;
117 const TValue t(const TPoint& iPoint) const;
118 const TVector project(const TVector& iVector) const;
119 const TVector reject(const TVector& iVector) const;
120 const TVector reflect(const TVector& iVector) const;
121 const TPoint project(const TPoint& iPoint) const;
122 const TVector reject(const TPoint& iPoint) const;
123 const TPoint reflect(const TPoint& iPoint) const;
124
125 Side classify(const TPoint& iPoint) const;
126
127 bool isValid() const;
128
129private:
130
131 TPoint support_;
132 TVector direction_;
133};
134
135
136
137template<typename T, class NP, class PP>
138std::ostream& operator<<(std::ostream& oOStream, const Ray2D<T, NP, PP>& iB);
139
140template<typename T, class NP, class PP>
141io::XmlOStream& operator<<(io::XmlOStream& oOStream, const Ray2D<T, NP, PP>& iB);
142
143
144
145}
146
147}
148
149#include "ray_2d.inl"
150
151#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_2D_H
152# include "aabb_2d_ray_2d.h"
153#endif
154
155#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_2D_H
156# include "line_2d_ray_2d.h"
157#endif
158
159#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_SEGMENT_2D_H
160# include "line_segment_2d_ray_2d.h"
161#endif
162
163#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_POLYGON_2D_H
165#endif
166
167#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRIANGLE_2D_H
168# include "ray_2d_triangle_2d.h"
169#endif
170
171#endif
Output stream for writing a selection of geometric primitives to XML files.
const TPoint point(TParam a_t) const
Return point on ray by it's parameter.
Definition ray_2d.inl:156
const TVector reflect(const TVector &iVector) const
Reflect vector against the axis of the ray.
Definition ray_2d.inl:202
bool isValid() const
Return true if ray is valid (direction isn't a zero vector).
Definition ray_2d.inl:260
const TVector reject(const TPoint &iPoint) const
Reject point against the axis of the ray.
Definition ray_2d.inl:225
TPoint & support()
access origin of ray the origin is also the support point of the ray.
Definition ray_2d.inl:109
const TVector project(const TVector &iVector) const
Project vector on the axis of the ray.
Definition ray_2d.inl:180
const TPoint project(const TPoint &iPoint) const
Project point on the axis of the ray.
Definition ray_2d.inl:214
void lookAt(const TPoint &iLookAt)
Set direction from origin to look-at point.
Definition ray_2d.inl:141
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
Definition ray_2d.inl:130
const TVector & direction() const
Return direction of ray.
Definition ray_2d.inl:120
const TPoint reflect(const TPoint &iPoint) const
Reject point against the axis of the ray.
Definition ray_2d.inl:236
const TValue t(const TPoint &iPoint) const
Return parameter of point on the ray that is the projection of the given point.
Definition ray_2d.inl:169
const TPoint & support() const
return origin of ray.
Definition ray_2d.inl:97
Side classify(const TPoint &iPoint) const
Return on what side a point is located.
Definition ray_2d.inl:246
const TVector reject(const TVector &iVector) const
Reject vector against the axis of the ray.
Definition ray_2d.inl:191
#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
Side
Different sides of a surface.
Definition side.h:79
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.