API Documentation
Loading...
Searching...
No Matches
Line.hpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: Line
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/BaseValues.h>
34#include <NDEVR/Vertex.h>
35namespace NDEVR
36{
37
38 /**
39 Class: LineSegment
40
41 \brief A line segment represented by two vertices, a start and end
42
43 Author: Tyler Parke
44
45 Date: 2017-11-19
46 **/
47 template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
48 class LineSegment : public Vector<2, t_vertex>
49 {
50 public:
51 constexpr LineSegment()
52 {}
53 constexpr LineSegment(const t_vertex& p1, const t_vertex& p2)
54 : Vector<2, t_vertex>(p1, p2)
55 {}
56 explicit constexpr LineSegment(const Vector<2, t_vertex>& line)
57 : Vector<2, t_vertex>(line)
58 {}
59
60 /**
61 Gets as.
62
63 Author: Tyler Parke
64
65 Date: 2017-11-19
66
67 \returns A LineSegment&lt;t_new_dims,t_new_type,t_new_vertex&gt;
68 **/
69 template<uint01 t_new_dims, class t_new_type, class t_new_vertex = Vertex<t_new_dims, t_new_type>>
74
75 /**
76 Point at.
77
78 Author: Tyler Parke
79
80 Date: 2017-11-19
81
82 Parameters:
83 index - Zero-based index of the.
84
85 \returns A t_vertex.
86 **/
87 template<class t_inter_type>
88 constexpr inline t_vertex pointAt(t_inter_type index) const
89 {
90 return vertex(A) + (ray().template as<t_dims, t_inter_type>() * index).template as<t_dims, t_type>();
91 }
92
93 /**
94 Gets the midpoint.
95
96 Author: Tyler Parke
97
98 Date: 2017-11-19
99
100 \returns A t_vertex.
101 **/
102
103 constexpr inline t_vertex midpoint() const
104 {
105 t_vertex avg = (vertex(A) + vertex(B)) / cast<t_type>(2);
106 avg = clip(avg, getMin(vertex(A), vertex(B)), getMax(vertex(A), vertex(B)));
107 return avg;
108 }
109
110 /**
111 Gets the ray.
112
113 Author: Tyler Parke
114
115 Date: 2017-11-19
116
117 \returns A t_vertex.
118 **/
119
120 constexpr inline t_vertex ray() const
121 {
122 return vertex(B) - vertex(A);
123 }
124
125 /**
126 Gets the center.
127
128 Author: Tyler Parke
129
130 Date: 2017-11-19
131
132 \returns A t_vertex.
133 **/
134
135 constexpr inline t_vertex center() const
136 {
137 return midpoint();
138 }
139
140 /**
141 Vertices the given index.
142
143 Author: Tyler Parke
144
145 Date: 2017-11-19
146
147 Parameters:
148 index - Zero-based index of the.
149
150 \returns A reference to a const t_vertex.
151 **/
152 constexpr inline const t_vertex& vertex(uint01 index) const
153 {
155 }
156
157 /**
158 Vertices the given index.
159
160 Author: Tyler Parke
161
162 Date: 2017-11-19
163
164 Parameters:
165 index - Zero-based index of the.
166
167 \returns A reference to a t_vertex.
168 **/
169 constexpr inline t_vertex& vertex(uint01 index)
170 {
172 }
173
174 /**
175
176 Query if 'line' is parallel.
177
178 Author: Tyler Parke
179
180 Date: 2017-11-19
181
182 Parameters:
183 line - The line.
184 epsilon - (Optional) The epsilon.
185
186 \returns True if parallel, false if not.
187 **/
188 template<class t_precision = t_type>
189 constexpr bool isParallel(const LineSegment<t_dims, t_type, t_vertex>& line, t_precision epsilon = 0) const
190 {
192 const Vector<t_dims, t_precision> ray_2(line.ray().template as<t_dims, t_type>().template normalized<t_precision>());
193 return (equals(ray_1, ray_2, epsilon) || equals(ray_1, -ray_2, epsilon));
194 }
195
196 /**
197
198 Query if 'line' is collinear.
199
200 Author: Tyler Parke
201
202 Date: 2017-11-19
203
204 Parameters:
205 line - The line.
206 epsilon - (Optional) The epsilon.
207
208 \returns True if collinear, false if not.
209 **/
210 template<class t_precision = t_type>
211 constexpr bool isCollinear(const LineSegment<t_dims, t_type>& line, t_precision epsilon = 0) const
212 {
213 return isParallel<t_precision>(line, epsilon) && distanceSquared<t_precision>(line, epsilon) <= epsilon * epsilon;
214 }
215
216 /**
217 Query if 'vert' is collinear.
218
219 Author: Tyler Parke
220
221 Date: 2017-11-19
222
223 Parameters:
224 vert - The vertical.
225 epsilon - (Optional) The epsilon.
226
227 \returns True if collinear, false if not.
228 **/
229 template<class t_precision = t_type>
230 constexpr bool isCollinear(const t_vertex& vert, t_precision epsilon = 0) const
231 {
233 const Vector<t_dims, t_precision> ray_2((vert - vertex(A)).template normalized<t_precision>());
234 return (equals(ray_1, ray_2, epsilon) || equals(ray_1, -ray_2, epsilon));
235 }
236
237
238 /**
239
240 Closest vertices.
241
242 Author: Tyler Parke
243
244 Date: 2017-11-19
245
246 Parameters:
247 l2 - The second LineSegment&lt;t_dims,t_type&gt;
248 epsilon - (Optional) The epsilon.
249
250 \returns A LineSegment&lt;t_dims,t_precision&gt;
251 **/
252 template<class t_precision, class t_other_vertex>
254 {
256 const Vector<t_dims, t_precision> v(l2.ray());
258
259 const t_precision a(dot(u, u));
260 const t_precision b(dot(u, v));
261 const t_precision c(dot(v, v));
262
263 const t_precision d(dot(u, w));
264 const t_precision e(dot(v, w));
265
266 const t_precision D((a * c) - (b * b));
267 t_precision sD = D;
268 t_precision tD = D;
269
270 t_precision sN;
271 t_precision tN;
272 // compute the line parameters of the two closest points
273 if (D > epsilon) // the lines are almost parallel
274 {
275 sN = (b*e - c*d);
276 tN = (a*e - b*d);
277 if (sN < static_cast<t_precision>(0)) // sc < 0 => the s=0 edge is visible
278 {
279 sN = static_cast<t_precision>(0);
280 tN = e;
281 tD = c;
282 }
283 else if (sN > sD) // sc > 1 => the s=1 edge is visible
284 {
285 sN = sD;
286 tN = e + b;
287 tD = c;
288 }
289 }
290 else//Consider the lines parallel
291 {
292 sN = static_cast<t_precision>(0); // force using point P0 on segment S1
293 sD = static_cast<t_precision>(1); // to prevent possible division by 0.0 later
294 tN = e;
295 tD = c;
296 }
297
298 if (tN < static_cast<t_precision>(0)) // tc < 0 => the t=0 edge is visible
299 {
300 tN = static_cast<t_precision>(0);
301 //recompute sc for this edge
302 if (-d < 0)
303 sN = static_cast<t_precision>(0);
304 else if (-d > a)
305 sN = sD;
306 else
307 {
308 sN = -d;
309 sD = a;
310 }
311 }
312 else if (tN > tD) //tc > 1 => the t=1 edge is visible
313 {
314 tN = tD;
315 // recompute sc for this edge
316 if ((-d + b) < static_cast<t_precision>(0))
317 sN = static_cast<t_precision>(0);
318 else if ((-d + b) > a)
319 sN = sD;
320 else
321 {
322 sN = (-d + b);
323 sD = a;
324 }
325 }
326
327 //finally do the division to get sc and tc
328 t_precision sc = abs(sN) <= epsilon ? static_cast<t_precision>(0) : sN / sD;
329 t_precision tc = abs(sN) <= epsilon ? static_cast<t_precision>(0) : tN / tD;
330
331 //get the difference of the two closest points
332 //Vector<t_dims, t_type>dP = w + (u * sc) - (v * tc);
333 //get the difference of the two closest points
335 (u * sc) + vertex(A).template as<t_dims, t_precision>()
336 , (v * tc) + l2.vertex(A).template as<t_dims, t_precision>());
337 }
338
339 /**
340 Closest position.
341
342 Author: Tyler Parke
343
344 Date: 2017-11-19
345
346 Parameters:
347 p - A t_vertex to process.
348
349 \returns A t_type.
350 **/
351
352 constexpr t_type closestPos(const t_vertex& p) const
353 {
354 const Vector<t_dims, t_type> ray_1 = ray();
355 const Vector<t_dims, t_type> ray_2 = p - vertex(A);
356
357 t_type sum = (ray_1 * ray_2).sum();
358
359 const t_type mag_squared = ray_1.magnitudeSquared();
360 if (mag_squared != 0)
361 sum /= mag_squared;
362 return clip(sum, cast<t_type>(0), cast<t_type>(1));
363 }
364
365 /**
366 Closest value.
367
368 Author: Tyler Parke
369
370 Date: 2017-11-19
371
372 Parameters:
373 p - A t_vertex to process.
374
375 \returns A t_vertex.
376 **/
377
378 constexpr t_vertex closestValue(const t_vertex& p) const
379 {
380 return pointAt(closestPos(p));
381 }
382 template<class t_precision = t_type>
383 t_precision distanceSquared(const LineSegment<t_dims, t_type, t_vertex>& right, const t_precision& epsilon = cast<t_precision>(0)) const
384 {
385 return closestPoints<t_precision>(right, epsilon).lengthSquared();
386 }
387
388 /**
389
390 Scales.
391
392 Author: Tyler Parke
393
394 Date: 2017-11-19
395
396 Parameters:
397 scale - The scale.
398 center - The center.
399
400 \returns A LineSegment&lt;t_dims,t_type&gt;
401 **/
402
403 /**
404
405 Scales.
406
407 Author: Tyler Parke
408
409 Date: 2017-11-19
410
411 Parameters:
412 scale - The scale.
413 center - The center.
414
415 \returns A LineSegment&lt;t_dims,t_type&gt;
416 **/
417 template<class t_inter_type>
422 template<class t_inter_type>
423 constexpr LineSegment<t_dims, t_type> scale(const t_inter_type& a_scale, const t_inter_type& b_scale) const
424 {
425 return LineSegment<t_dims, t_type>(pointAt(-a_scale), pointAt(b_scale + cast<t_inter_type>(1)));
426 }
427
428 constexpr LineSegment<t_dims, t_type> extend(const t_type& extension) const
429 {
430 t_vertex dx = (extension / cast<t_type>(2)) * ray().template normalized<t_type>();
431 return LineSegment<t_dims, t_type>(vertex(A) - dx, vertex(B) + dx);
432 }
433 constexpr LineSegment<t_dims, t_type> extend(const t_type& a_extension, const t_type& b_extension) const
434 {
435 t_vertex dx = ray().template normalized<t_type>();
436 return LineSegment<t_dims, t_type>(vertex(A) - (dx * a_extension), vertex(B) + (dx * b_extension));
437 }
438 /**
439 Gets the length.
440
441 Author: Tyler Parke
442
443 Date: 2017-11-19
444
445 \returns A t_precision.
446 **/
447 template<class t_precision = t_type>
448 constexpr t_precision length() const
449 {
450 return ray().template magnitude<t_precision>();
451 }
452
453 /**
454 Length squared.
455
456 Author: Tyler Parke
457
458 Date: 2017-11-19
459
460 \returns A t_type.
461 **/
462
463 constexpr t_type lengthSquared() const
464 {
465 return ray().magnitudeSquared();
466 }
467
468
469
470 /**
471
472 Intersections.
473
474 Author: Tyler Parke
475
476 Date: 2017-11-19
477
478 Parameters:
479 r - A LineSegment to process.
480 epsilon - (Optional) The epsilon.
481
482 \returns A Vector&lt;t_dims,t_precision&gt;
483 **/
484 template<class t_precision = t_type>
485 constexpr Vector<t_dims, t_precision> intersection(const LineSegment& r, t_precision epsilon = 0) const
486 {
488 if(abs(line.vertex(B) - line.vertex(A)) <= epsilon)
489 return line.vertex(B);
490 else
492 }
493
494 /**
495 Intersection position.
496
497 Author: Tyler Parke
498
499 Date: 2017-11-19
500
501 Parameters:
502 segment - The segment.
503
504 \returns A t_precision.
505 **/
506 template<class t_precision = t_type>
507 constexpr t_precision intersectionPosition(const LineSegment<t_dims, t_type>& segment) const
508 {
509 Vector<t_dims, t_precision> intersection_location(intersection<t_precision>(segment));
510 if(!IsInvalid(intersection_location))
511 return closestPos(intersection_location);
513 }
514
515 /**
516
517 Query if this object intersects the given segment.
518
519 Author: Tyler Parke
520
521 Date: 2017-11-19
522
523 Parameters:
524 segment - The segment.
525 epsilon - (Optional) The epsilon.
526
527 \returns True if it succeeds, false if it fails.
528 **/
529 template<class t_precision = t_type>
530 constexpr bool intersects(const LineSegment& segment, t_precision epsilon = cast<t_precision>(0.001)) const
531 {
532 return closestPoints<t_precision>(segment).lengthSquared() <= epsilon;
533 }
534
535 /**
536 Gets location at.
537
538 Author: Tyler Parke
539
540 Date: 2017-11-19
541
542 Parameters:
543 value - The value.
544 dim - The dim.
545
546 \returns The location at.
547 **/
548 template<bool t_clip, class t_precision>
549 constexpr t_precision getLocationAt(t_precision value, uint01 dim) const
550 {
551 if (vertex(A)[dim] == vertex(B)[dim])
553 if (t_clip)
554 {
555 if (vertex(A)[dim] > vertex(B)[dim])
556 {
557 if (value >= vertex(A)[dim])
558 return cast<t_precision>(0);
559 else if (value <= vertex(B)[dim])
560 return cast<t_precision>(1);
561 }
562 else
563 {
564 if (value >= vertex(B)[dim])
565 return cast<t_precision>(1);
566 else if (value <= vertex(A)[dim])
567 return cast<t_precision>(0);
568 }
569 }
570 return (vertex(A)[dim] - value) / ((value - vertex(B)[dim]) + (vertex(A)[dim] - value));
571 }
572
573
574 /**
575
576 Point at.
577
578 Author: Tyler Parke
579
580 Date: 2017-11-19
581
582 Parameters:
583 value - The value.
584 dim - The dim.
585 nan_return - (Optional) The Invalid return.
586
587 \returns A t_vertex.
588 **/
589 template<bool t_clip, class t_precision>
590 constexpr t_vertex pointAt(t_precision value, uint01 dim, const t_vertex& nan_return = Constant<t_vertex>::Invalid) const
591 {
592 if (vertex(A)[dim] == vertex(B)[dim])
593 return nan_return;
594 if (t_clip)
595 {
596 if (vertex(A)[dim] > vertex(B)[dim])
597 {
598 if (value >= vertex(A)[dim])
599 return vertex(A);
600 else if (value <= vertex(B)[dim])
601 return vertex(B);
602 }
603 else
604 {
605 if (value >= vertex(B)[dim])
606 return vertex(B);
607 else if (value <= vertex(A)[dim])
608 return vertex(A);
609 }
610 }
611 const t_precision dt = vertex(A)[dim] - value;
612 const t_precision dy = value - vertex(B)[dim];
613 return (vertex(B) * dt + vertex(A) * dy) / (dt + dy);
614 }
615
616
617
618 /**
619
620 Creates best fit line.
621
622 Author: Tyler Parke
623
624 Date: 2017-11-19
625
626 Parameters:
627 vertices - The vertices.
628 dim_0 - The dim 0.
629 dim_1 - The first dim.
630
631 \returns The new best fit line.
632 **/
633 template<class t_buffer_type>
634 constexpr static LineSegment createBestFitLine(const t_buffer_type& vertices, uint01 dim_0, uint01 dim_1)
635 {
636 if(vertices.size() < 2)
638 if(vertices.size() == 2)
639 return LineSegment(vertices[0], vertices[1]);
640
641 t_vertex total_vector(0);
642 t_type total_volume = 0;
643 t_type total_x_sqr = 0;
644 for(uint04 i = 0; i < vertices.size(); i++)
645 {
646 total_vector += vertices[i];
647 total_x_sqr += vertices[i][dim_0] * vertices[i][dim_0];
648 total_volume += vertices[i][dim_0] * vertices[i][dim_1];
649 }
650
651 const t_type x_sqr = total_vector[dim_0] * total_vector[dim_0];
652 const t_type a = (total_vector[dim_1] * total_x_sqr - total_vector[dim_0] * total_volume) / (vertices.size() * total_x_sqr - x_sqr);
653
654 const t_type b = (vertices.size() * total_volume - total_vector[dim_0] * total_vector[dim_1]) / (vertices.size() * total_x_sqr - x_sqr);
655
656 const t_vertex p1(vertices[0]);
657 const t_vertex p2 = vertices.getLast();
658 p1[dim_1] = a + b * p1[dim_0];
659 p2[dim_1] = a + b * p2[dim_0];
660
661 return LineSegment(p1, p2);
662 }
663 };
664
665 /**
666
667 Distance squared optimized.
668
669 Author: Tyler Parke
670
671 Date: 2017-11-19
672
673 Parameters:
674 line - The line.
675 vertex - The vertex.
676 ray - The ray.
677 dot_ray - The dot ray.
678
679 \returns A t_type.
680 **/
681 template<uint01 t_dims, class t_type, class t_vertex>
682 constexpr t_type distanceSquaredOptimized(const LineSegment<t_dims, t_type, t_vertex>& line, const t_vertex& vertex, const t_vertex& ray, const t_type& dot_ray)
683 {
684 const t_vertex v_t(vertex - line.vertex(A));
685 const t_type t = dot(v_t, ray);
686 if (t <= 0)
687 return v_t.magnitudeSquared();
688 else if (t >= dot_ray)
689 return distanceSquared(vertex, line.vertex(B));
690 else
691 {
692 t_vertex vc = (ray * t) / dot_ray + line.vertex(A);
693 return distanceSquared(vertex, vc);
694 }
695 }
696 /**
697
698 Distance squared.
699
700 Author: Tyler Parke
701
702 Date: 2017-11-19
703
704 Parameters:
705 line - The line.
706 vertex - The vertex.
707
708 \returns A t_type.
709 **/
710 template<uint01 t_dims, class t_type, class t_vertex>
711 t_type distanceSquared(const LineSegment<t_dims, t_type, t_vertex>& line, const t_vertex& vertex)
712 {
713 const t_vertex ray_value(line.ray());
714 const t_type dot_ray = dot(ray_value, ray_value);
715 return distanceSquaredOptimized(line, vertex, ray_value, dot_ray);
716 }
717
718
719 /**
720
721 Distance squared.
722
723 Author: Tyler Parke
724
725 Date: 2017-11-19
726
727 Parameters:
728 vertex - The vertex.
729 line - The line.
730
731 \returns A t_type.
732 **/
733 template<uint01 t_dims, class t_type, class t_vertex>
734 constexpr t_type distanceSquared(const t_vertex& vertex, const LineSegment<t_dims, t_type, t_vertex>& line)
735 {
736 return distanceSquared(line, vertex);
737 }
738
739
740
741 /**
742
743 Tests if objects are considered equal.
744
745 Author: Tyler Parke
746
747 Date: 2017-11-19
748
749 Parameters:
750 left - Constant line segment&lt;t dims,t type,t vertex&gt;&amp; to be compared.
751 right - Constant line segment&lt;t dims,t type,t vertex&gt;&amp; to be compared.
752 epsilon - (Optional) Constant type&amp; to be compared.
753
754 \returns True if the objects are considered equal, false if they are not.
755 **/
756 template<uint01 t_dims, class t_type, class t_vertex>
757 constexpr bool equals(const LineSegment<t_dims, t_type, t_vertex>& left, const LineSegment<t_dims, t_type, t_vertex>& right, const t_type& epsilon = cast<t_type>(0))
758 {
759 if (equals(left[A], right[A], epsilon))
760 {
761 return (equals(left[B], right[B], epsilon));
762 }
763 if (equals(left[B], right[A], epsilon))
764 {
765 return (equals(left[A], right[B], epsilon));
766 }
767 return false;
768 }
769
770
771
772
773
774 template<uint01 t_dims, class t_type>
775 static constexpr bool IsInvalid(const LineSegment<t_dims, t_type>& value)
776 {
777 for (uint01 dim = 0; dim < 2; ++dim)
778 {
779 if (IsInvalid(value[dim]))
780 return true;
781 }
782 return false;
783 }
784
785 template<uint01 t_dims, class t_type, class t_vector>
786 struct Constant<LineSegment<t_dims, t_type, t_vector>>
787 {
788 constexpr const static LineSegment<t_dims, t_type> Invalid{ Constant<t_vector>::Invalid, Constant<t_vector>::Invalid };
789 constexpr const static LineSegment<t_dims, t_type> Min{ Constant<t_vector>::Min, Constant<t_vector>::Min };
790 constexpr const static LineSegment<t_dims, t_type> Max{ Constant<t_vector>::Max, Constant<t_vector>::Max };
791 };
792
793};
794
A line segment represented by two vertices, a start and end.
Definition Line.hpp:49
constexpr LineSegment< t_dims, t_type > extend(const t_type &a_extension, const t_type &b_extension) const
Definition Line.hpp:433
constexpr Vector< t_dims, t_precision > intersection(const LineSegment &r, t_precision epsilon=0) const
Definition Line.hpp:485
constexpr t_vertex ray() const
Definition Line.hpp:120
constexpr LineSegment()
Definition Line.hpp:51
constexpr t_vertex pointAt(t_precision value, uint01 dim, const t_vertex &nan_return=Constant< t_vertex >::Invalid) const
Definition Line.hpp:590
constexpr t_precision length() const
Definition Line.hpp:448
constexpr LineSegment(const t_vertex &p1, const t_vertex &p2)
Definition Line.hpp:53
constexpr LineSegment< t_dims, t_type > scale(const t_inter_type &scale) const
Definition Line.hpp:418
constexpr bool isCollinear(const LineSegment< t_dims, t_type > &line, t_precision epsilon=0) const
Definition Line.hpp:211
constexpr t_vertex midpoint() const
Definition Line.hpp:103
constexpr t_precision intersectionPosition(const LineSegment< t_dims, t_type > &segment) const
Definition Line.hpp:507
constexpr t_precision getLocationAt(t_precision value, uint01 dim) const
Definition Line.hpp:549
static constexpr LineSegment createBestFitLine(const t_buffer_type &vertices, uint01 dim_0, uint01 dim_1)
Definition Line.hpp:634
constexpr bool isCollinear(const t_vertex &vert, t_precision epsilon=0) const
Definition Line.hpp:230
constexpr LineSegment(const Vector< 2, t_vertex > &line)
Definition Line.hpp:56
constexpr const t_vertex & vertex(uint01 index) const
Definition Line.hpp:152
constexpr t_vertex & vertex(uint01 index)
Definition Line.hpp:169
constexpr LineSegment< t_dims, t_type > extend(const t_type &extension) const
Definition Line.hpp:428
t_precision distanceSquared(const LineSegment< t_dims, t_type, t_vertex > &right, const t_precision &epsilon=cast< t_precision >(0)) const
Definition Line.hpp:383
constexpr t_type lengthSquared() const
Definition Line.hpp:463
constexpr t_vertex center() const
Definition Line.hpp:135
constexpr t_vertex closestValue(const t_vertex &p) const
Definition Line.hpp:378
constexpr t_vertex pointAt(t_inter_type index) const
Definition Line.hpp:88
constexpr bool isParallel(const LineSegment< t_dims, t_type, t_vertex > &line, t_precision epsilon=0) const
Definition Line.hpp:189
constexpr LineSegment< t_dims, t_type > scale(const t_inter_type &a_scale, const t_inter_type &b_scale) const
Definition Line.hpp:423
constexpr t_type closestPos(const t_vertex &p) const
Definition Line.hpp:352
constexpr LineSegment< t_new_dims, t_new_type, t_new_vertex > as() const
Definition Line.hpp:70
constexpr bool intersects(const LineSegment &segment, t_precision epsilon=cast< t_precision >(0.001)) const
Definition Line.hpp:530
constexpr LineSegment< t_dims, t_precision > closestPoints(const LineSegment< t_dims, t_type, t_other_vertex > &l2, t_precision epsilon=0) const
Definition Line.hpp:253
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
constexpr t_magnitude_type magnitude() const
Definition Vector.hpp:448
constexpr Vector() noexcept
Definition Vector.hpp:62
constexpr t_type sum() const
Definition Vector.hpp:505
constexpr Vector< t_dims, t_norm_type > normalized(Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::Invalid) const
Definition Vector.hpp:464
constexpr t_type & operator[](uint01 dimension_index)
Definition Vector.hpp:526
constexpr t_type magnitudeSquared() const
Definition Vector.hpp:426
Definition ACIColor.h:37
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
Definition BaseFunctions.hpp:94
constexpr t_type clip(const t_type &value, const t_type &lower_bound, const t_type &upper_bound)
Clips the value given so that that the returned value falls between upper and lower bound.
Definition BaseFunctions.hpp:207
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1030
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
t_type distanceSquared(const Bounds< t_dims, t_type, t_vertex > &bounds, const Vector< t_dims, t_type > &vertex)
Definition Distance.hpp:46
constexpr t_type distanceSquaredOptimized(const LineSegment< t_dims, t_type, t_vertex > &line, const t_vertex &vertex, const t_vertex &ray, const t_type &dot_ray)
Definition Line.hpp:682
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
constexpr bool equals(const LineSegment< t_dims, t_type, t_vertex > &left, const LineSegment< t_dims, t_type, t_vertex > &right, const t_type &epsilon=cast< t_type >(0))
Definition Line.hpp:757
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Changes an input with a negative sign, to a positive sign.
Definition AngleFunctions.h:645
@ B
Definition BaseValues.hpp:170
@ A
Definition BaseValues.hpp:168
@ D
Definition BaseValues.hpp:174
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
Definition BaseFunctions.hpp:56
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
static const t_type Invalid
Definition BaseValues.hpp:234
static const t_type Min
Definition BaseValues.hpp:235
static const t_type Max
Definition BaseValues.hpp:236