wykobi_utilities.hpp
Go to the documentation of this file.
1 /*
2 (***********************************************************************)
3 (* *)
4 (* Wykobi Computational Geometry Library *)
5 (* Release Version 0.0.5 *)
6 (* http://www.wykobi.com *)
7 (* Copyright (c) 2005-2017 Arash Partow, All Rights Reserved. *)
8 (* *)
9 (* The Wykobi computational geometry library and its components are *)
10 (* supplied under the terms of the open source MIT License. *)
11 (* The contents of the Wykobi computational geometry library and its *)
12 (* components may not be copied or disclosed except in accordance with *)
13 (* the terms of the MIT License. *)
14 (* *)
15 (* URL: https://opensource.org/licenses/MIT *)
16 (* *)
17 (***********************************************************************)
18 */
19 
20 #ifndef INCLUDE_WYKOBI_UTILTIIES
21 #define INCLUDE_WYKOBI_UTILTIIES
22 
23 #include <iomanip>
24 #include <iostream>
25 #include <vector>
26 
27 #include "wykobi.hpp"
28 #include "wykobi_matrix.hpp"
29 
30 namespace wykobi {
31 template <typename Type>
32 inline std::ostream& operator<<(std::ostream& os, const point2d<Type>& point) {
33  os << std::scientific << std::showpoint << std::setprecision(6) << "("
34  << point.x << "," << point.y << ")";
35 
36  return os;
37 }
38 
39 template <typename Type>
40 inline std::ostream& operator<<(std::ostream& os, const point3d<Type>& point) {
41  os << std::scientific << std::showpoint << std::setprecision(6) << "("
42  << point.x << "," << point.y << "," << point.z << ")";
43 
44  return os;
45 }
46 
47 template <typename Type>
48 inline std::ostream& operator<<(std::ostream& os, const vector2d<Type>& v) {
49  os << std::scientific << std::showpoint << std::setprecision(6) << "(" << v.x
50  << "," << v.y << ")";
51 
52  return os;
53 }
54 
55 template <typename Type>
56 inline std::ostream& operator<<(std::ostream& os, const vector3d<Type>& v) {
57  os << std::scientific << std::showpoint << std::setprecision(6) << "(" << v.x
58  << "," << v.y << "," << v.z << ")";
59 
60  return os;
61 }
62 
63 template <typename Type>
64 inline std::ostream& operator<<(std::ostream& os, const ray<Type, 2>& ray) {
65  os << std::scientific << std::showpoint << std::setprecision(6) << "("
66  << ray.origin.x << "," << ray.origin.y << "," << ray.direction.x << ","
67  << ray.direction.y << ")";
68 
69  return os;
70 }
71 
72 template <typename Type>
73 inline std::ostream& operator<<(std::ostream& os, const ray<Type, 3>& ray) {
74  os << std::scientific << std::showpoint << std::setprecision(6) << "("
75  << ray.origin.x << "," << ray.origin.y << "," << ray.origin.z << ","
76  << ray.direction.x << "," << ray.direction.y << "," << ray.direction.z
77  << ")";
78 
79  return os;
80 }
81 
82 template <typename Type, std::size_t Dimension>
83 inline std::ostream& operator<<(std::ostream& os,
84  const pointnd<Type, Dimension>& point) {
85  os << "(";
86 
87  for (std::size_t i = 0; i < Dimension - 1; ++i) {
88  os << std::scientific << std::showpoint << std::setprecision(6) << point[i]
89  << ",";
90  }
91 
92  os << std::scientific << std::showpoint << std::setprecision(6)
93  << point[Dimension - 1] << ")";
94 
95  return os;
96 }
97 
98 template <typename Type, std::size_t Dimension>
99 inline std::ostream& operator<<(std::ostream& os,
101  for (unsigned int i = 0; i < wykobi::segment<Type, Dimension>::PointCount;
102  ++i) {
103  os << segment[i];
104  }
105 
106  return os;
107 }
108 
109 template <typename Type, std::size_t Dimension>
110 inline std::ostream& operator<<(std::ostream& os,
111  const line<Type, Dimension>& line) {
112  for (unsigned int i = 0; i < wykobi::line<Type, Dimension>::PointCount; ++i) {
113  os << line[i];
114  }
115 
116  return os;
117 }
118 
119 template <typename Type, std::size_t Dimension>
120 inline std::ostream& operator<<(std::ostream& os,
122  for (unsigned int i = 0; i < wykobi::triangle<Type, Dimension>::PointCount;
123  ++i) {
124  os << triangle[i];
125  }
126 
127  return os;
128 }
129 
130 template <typename Type>
131 inline std::ostream& operator<<(std::ostream& os,
132  const rectangle<Type>& rectangle) {
133  for (unsigned int i = 0; i < wykobi::rectangle<Type>::PointCount; ++i) {
134  os << rectangle[i];
135  }
136 
137  return os;
138 }
139 
140 template <typename Type, std::size_t Dimension>
141 inline std::ostream& operator<<(std::ostream& os,
142  const box<Type, Dimension>& box) {
143  for (unsigned int i = 0; i < wykobi::box<Type, Dimension>::PointCount; ++i) {
144  os << box[i];
145  }
146 
147  return os;
148 }
149 
150 template <typename Type, std::size_t Dimension>
151 inline std::ostream& operator<<(std::ostream& os,
153  for (unsigned int i = 0; i < wykobi::quadix<Type, Dimension>::PointCount;
154  ++i) {
155  os << quadix[i];
156  }
157 
158  return os;
159 }
160 
161 template <typename Type>
162 inline std::ostream& operator<<(std::ostream& os, const circle<Type>& circle) {
163  os << std::scientific << std::showpoint << std::setprecision(10) << "("
164  << circle.x << "," << circle.y << "," << circle.radius << ")";
165 
166  return os;
167 }
168 
169 template <typename Type>
170 inline std::ostream& operator<<(std::ostream& os, const sphere<Type>& sphere) {
171  os << std::scientific << std::showpoint << std::setprecision(6) << "("
172  << sphere.x << "," << sphere.y << "," << sphere.z << "," << sphere.radius
173  << ")";
174 
175  return os;
176 }
177 
178 template <typename Type, std::size_t M, std::size_t N>
179 inline std::ostream& operator<<(std::ostream& os,
180  const matrix<Type, M, N>& matrix) {
181  for (std::size_t x = 0; x < M; x++) {
182  for (std::size_t y = 0; y < N; y++) {
183  os << matrix(x, y) << "\t";
184  }
185 
186  os << std::endl;
187  }
188 
189  return os;
190 }
191 
192 } // namespace wykobi
193 
194 #endif
Definition: wykobi.hpp:702
Definition: wykobi.hpp:426
T y
Definition: wykobi.hpp:428
T x
Definition: wykobi.hpp:428
T radius
Definition: wykobi.hpp:428
Definition: wykobi.hpp:287
Definition: wykobi_matrix.hpp:33
Definition: wykobi.hpp:74
T x
Definition: wykobi.hpp:104
T y
Definition: wykobi.hpp:104
Definition: wykobi.hpp:108
T z
Definition: wykobi.hpp:135
T x
Definition: wykobi.hpp:135
T y
Definition: wykobi.hpp:135
Definition: wykobi.hpp:166
Definition: wykobi.hpp:359
Definition: wykobi.hpp:674
VectorType direction
Definition: wykobi.hpp:683
PointType origin
Definition: wykobi.hpp:682
Definition: wykobi.hpp:335
Definition: wykobi.hpp:263
Definition: wykobi.hpp:433
T z
Definition: wykobi.hpp:435
T y
Definition: wykobi.hpp:435
T radius
Definition: wykobi.hpp:435
T x
Definition: wykobi.hpp:435
Definition: wykobi.hpp:311
Definition: wykobi.hpp:582
Definition: wykobi.hpp:597
Definition: wykobi.hpp:32
std::ostream & operator<<(std::ostream &os, const point2d< Type > &point)
Definition: wykobi_utilities.hpp:32