Library of Assembled Shared Sources
line_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::Line3D
46 * @brief 3D Line
47 * @author Bram de Greve [BdG]
48 * @date 3003
49 */
50
51
52
53#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_3D_H
54#define LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_3D_H
55
56#include "prim_common.h"
57#include "normalizing_policy.h"
58#include "point_3d.h"
59
60
61
62namespace lass
63{
64
65namespace prim
66{
67
68template
69<
70 typename T,
71 class NormalizingPolicy = Normalized
72>
73class LASS_SIMD_ALIGN Line3D
74{
75public:
76
77 typedef Line3D<T, NormalizingPolicy> TSelf;
78 typedef NormalizingPolicy TNormalizingPolicy;
79
80 typedef Point3D<T> TPoint;
81 typedef typename TPoint::TVector TVector;
82
83 typedef typename TPoint::TValue TValue;
84 typedef typename TPoint::TParam TParam;
85 typedef typename TPoint::TReference TReference;
86 typedef typename TPoint::TConstReference TConstReference;
87 typedef typename TPoint::TNumTraits TNumTraits;
88
89 enum { dimension = TPoint::dimension }; /**< number of dimensions of vector */
90
91 /** rebind to other value type
92 */
93 template <typename U>
94 struct Rebind
95 {
96 typedef Line3D<U, NormalizingPolicy> Type;
97 };
98
99 Line3D();
100 Line3D(const TPoint& iSupport, const TPoint& iPoint);
101 Line3D(const TPoint& iSupport, const TVector& iDirection);
102
103 const TPoint& support() const;
104 TPoint& support();
105 const TVector& direction() const;
106 void setDirection(const TVector& iDirection);
107 void lookAt(const TPoint& iLookAt);
108
109 const TVector reject(const TPoint& iPoint) const;
110 const TVector reject(const TVector& iVector) const;
111 const TPoint project(const TPoint& iPoint) const;
112 const TVector project(const TVector& iVector) const;
113 const TPoint reflect(const TPoint& iPoint) const;
114 const TVector reflect(const TVector& iVector) const;
115
116 const TPoint point(TParam iT) const;
117 const TValue t(const TPoint& iPoint) const;
118
119 void flip();
120 bool isValid() const;
121
122private:
123
124 TPoint support_;
125 TVector direction_;
126};
127
128
129
130template<typename T, class NP>
131std::ostream& operator<<(std::ostream& oOStream, const Line3D<T, NP>& iB);
132
133template<typename T, class NP>
134io::XmlOStream& operator<<(io::XmlOStream& oOStream, const Line3D<T, NP>& iB);
135
136
137}
138
139}
140
141#include "line_3d.inl"
142
143#endif
Output stream for writing a selection of geometric primitives to XML files.
const TPoint reflect(const TPoint &iPoint) const
reflect a point orthogonally into the line.
Definition line_3d.inl:195
const TVector project(const TVector &iVector) const
project a vector orthogonally onto the line
Definition line_3d.inl:184
const TPoint point(TParam iT) const
Return point on line by it's parameter.
Definition line_3d.inl:218
const TVector & direction() const
Return direction of line.
Definition line_3d.inl:114
const TValue t(const TPoint &iPoint) const
Return parameter of point on the line that is the projection of the given point.
Definition line_3d.inl:229
const TVector reflect(const TVector &iVector) const
reflect a vector orthogonally to the line
Definition line_3d.inl:206
void lookAt(const TPoint &iLookAt)
Set direction from support to look-at point.
Definition line_3d.inl:135
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
Definition line_3d.inl:124
const TPoint project(const TPoint &iPoint) const
project a point orthogonally onto the line
Definition line_3d.inl:173
const TVector reject(const TPoint &iPoint) const
return the vector that, if added to the projection of iPoint, you get iPoint again.
Definition line_3d.inl:148
bool isValid() const
Return true if line is valid (direction isn't a zero vector).
Definition line_3d.inl:239
const TVector reject(const TVector &iVector) const
return the part of iVector that is orthogonal to the line.
Definition line_3d.inl:161
#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
rebind to other value type
Definition line_3d.h:95
Policy to auto-normalize normals.