Library of Assembled Shared Sources
point_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/** @struct lass::prim::Point3D
46 * @brief 3D Point
47 * @author BdG
48 * @date 2003
49 */
50
51
52
53#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_POINT_3D_H
54#define LASS_GUARDIAN_OF_INCLUSION_PRIM_POINT_3D_H
55
56
57
58
59#include "prim_common.h"
60#include "vector_3d.h"
61
62
63namespace lass
64{
65
66namespace prim
67{
68
69template<typename T>
70struct LASS_SIMD_ALIGN Point3D
71{
72public:
73
74 typedef Point3D<T> TSelf;
75
76 typedef Vector3D<T> TVector;
77
78 typedef typename TVector::TValue TValue;
79 typedef typename TVector::TParam TParam;
80 typedef typename TVector::TReference TReference;
81 typedef typename TVector::TConstReference TConstReference;
82 typedef typename TVector::TNumTraits TNumTraits;
83
84 enum { dimension = TVector::dimension }; /**< number of dimensions */
85
86 template <typename U> struct Rebind
87 {
88 typedef Point3D<U> Type;
89 };
90
91 TValue x;
92 TValue y;
93 TValue z;
94
95 Point3D();
96 Point3D(TParam x, TParam y, TParam z);
97 template <typename U> explicit Point3D(const Point3D<U>& other);
98 template <typename U> explicit Point3D(const Vector3D<U>& position);
99 template <typename U> explicit Point3D(const U& x, const U& y, const U& z);
100
101 const TVector position() const;
102 TConstReference operator[](size_t index) const;
103 TReference operator[](size_t index);
104 TConstReference at(signed index) const;
105 TReference at(signed index);
106
107 Point3D<T>& operator+=(const Vector3D<T>& offset);
108 Point3D<T>& operator-=(const Vector3D<T>& offset);
109
110 bool isZero() const;
111 bool isNaN() const;
112};
113
114template<typename T> bool operator==(const Point3D<T>& a, const Point3D<T>& b);
115template<typename T> bool operator!=(const Point3D<T>& a, const Point3D<T>& b);
116
117template<typename T> Point3D<T> operator+(const Point3D<T>& a, const Vector3D<T>& b);
118template<typename T> Point3D<T> operator+(const Vector3D<T>& a, const Point3D<T>& b);
119template<typename T> Point3D<T> operator-(const Point3D<T>& a, const Vector3D<T>& b);
120template<typename T> Vector3D<T> operator-(const Point3D<T>& a, const Point3D<T>& b);
121
122template<typename T> typename Point3D<T>::TValue distance(const Point3D<T>& a, const Point3D<T>& b);
123template<typename T> typename Point3D<T>::TValue squaredDistance(const Point3D<T>& a, const Point3D<T>& b);
124template<typename T> Point3D<T> pointwiseMin(const Point3D<T>& a, const Point3D<T>& b);
125template<typename T> Point3D<T> pointwiseMax(const Point3D<T>& a, const Point3D<T>& b);
126template<typename T> Point3D<T> lerp(const Point3D<T>& a, const Point3D<T>& b, typename Point3D<T>::TParam t);
127
128template<typename T> std::ostream& operator<<(std::ostream& stream, const Point3D<T>& b);
129template<typename T> io::XmlOStream& operator<<(io::XmlOStream& stream, const Point3D<T>& b);
130template<typename T> std::istream& operator>>(std::istream& stream, Point3D<T>& b);
131
132
133
134}
135
136}
137
138#include "point_3d.inl"
139
140#define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_POINT_3D
141#ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
143#endif
144
145#endif
Output stream for writing a selection of geometric primitives to XML files.
#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
TReference at(signed index)
Wrap index around range.
Definition point_3d.inl:159
bool isNaN() const
Return true if at least one of the components is NaN.
Definition point_3d.inl:200
TConstReference at(signed index) const
Wrap index around range.
Definition point_3d.inl:148