Ocean
Loading...
Searching...
No Matches
FiniteLine2.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MATH_FINITE_LINE_2_H
9#define META_OCEAN_MATH_FINITE_LINE_2_H
10
11#include "ocean/math/Math.h"
12#include "ocean/math/Line2.h"
13#include "ocean/math/Vector2.h"
14
15#include <vector>
16
17namespace Ocean
18{
19
20// Forward declaration.
21template <typename T> class FiniteLineT2;
22
23/**
24 * Definition of the FiniteLine2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or double precision float data type.
25 * @see FiniteLineT2
26 * @ingroup math
27 */
29
30/**
31 * Instantiation of the LineT2 template class using a double precision float data type.
32 * @see FiniteLineT2
33 * @ingroup math
34 */
36
37/**
38 * Instantiation of the LineT2 template class using a single precision float data type.
39 * @see FiniteLineT2
40 * @ingroup math
41 */
43
44/**
45 * Definition of a typename alias for vectors with FiniteLineT2 objects.
46 * @see FiniteLineT2
47 * @ingroup math
48 */
49template <typename T>
50using FiniteLinesT2 = std::vector<FiniteLineT2<T>>;
51
52/**
53 * Definition of a vector holding FiniteLine2 objects.
54 * @see FiniteLineF2, Line2
55 * @ingroup math
56 */
57using FiniteLines2 = std::vector<FiniteLine2>;
58
59/**
60 * Definition of a vector holding FiniteLineD2 objects.
61 * @see FiniteLineD2, Line2
62 * @ingroup math
63 */
64using FiniteLinesD2 = std::vector<FiniteLineD2>;
65
66/**
67 * Definition of a vector holding FiniteLineF2 objects.
68 * @see FiniteLineF2, Line2
69 * @ingroup math
70 */
71using FiniteLinesF2 = std::vector<FiniteLineF2>;
72
73/**
74 * This class implements an finite line in 2D space.
75 * The finite line object is invalid if both end points of the line object are identical.<br>
76 * @tparam T Data type used to represent lines
77 * @see FiniteLine2, FiniteLineF2, FiniteLineD2, LineT2, Line2
78 * @ingroup math
79 */
80template <typename T>
82{
83 public:
84
85 /**
86 * Definition of the used data type.
87 */
88 typedef T Type;
89
90 public:
91
92 /**
93 * Creates a finite line with default parameters.
94 */
95 FiniteLineT2() = default;
96
97 /**
98 * Creates a finite line defined by two end points of the line.
99 * @param point0 First end point of the line
100 * @param point1 Second end point of the line, must be different from point0 to create a valid line, otherwise the line is invalid
101 */
103
104 /**
105 * Copies a line with different data type than T.
106 * @param line The line to copy
107 * @tparam U The data type of the second line
108 */
109 template <typename U>
110 explicit inline FiniteLineT2(const FiniteLineT2<U>& line);
111
112 /**
113 * Returns the first end point of the line.
114 * @return First end point of the line
115 */
116 inline const VectorT2<T>& point0() const;
117
118 /**
119 * Returns the second end point of the line.
120 * @return Second end point of the line
121 */
122 inline const VectorT2<T>& point1() const;
123
124 /**
125 * Returns the first or second end point of the line.
126 * @param index The index of the point to be returned, with range [0, 1]
127 * @return First or second end point of the line
128 */
129 inline const VectorT2<T>& point(const unsigned int index) const;
130
131 /**
132 * Returns the midpoint of the line.
133 * @return Midpoint point of the line
134 */
135 inline VectorT2<T> midpoint() const;
136
137 /**
138 * Returns the direction of the line: normalized(point1() - point0())
139 * @return Direction vector with unit length, a zero vector if the line is invalid
140 * @see isValid().
141 */
142 inline const VectorT2<T>& direction() const;
143
144 /**
145 * Returns the normal of the line: -direction().perpendicular()
146 * The 2D cross product between the resulting normal and the direction of this line will be positive
147 * @return Normal vector with unit length
148 * @see isValid().
149 */
150 inline const VectorT2<T> normal() const;
151
152 /**
153 * Returns the squared length of the finite line.
154 * @return Squared distance between the end points of the line
155 */
156 inline T sqrLength() const;
157
158 /**
159 * Returns the length of the finite line.
160 * @return Distance between the end points of the line
161 */
162 inline T length() const;
163
164 /**
165 * Returns whether a given point is part of the finite line.
166 * @param point The point to check
167 * @return True, if so
168 * @see isOnInfiniteLine().
169 */
170 inline bool isOnLine(const VectorT2<T>& point) const;
171
172 /**
173 * Returns whether a given point lies on the infinite line defined by this finite line.
174 * @param point The point to check
175 * @return True, if so
176 * @see isOnLine().
177 */
178 inline bool isOnInfiniteLine(const VectorT2<T>& point) const;
179
180 /**
181 * Check if a point is in the left half-plane of the direction vector of a line
182 * A point @c p is located on the left side of a line, if the cross product of the direction of the line, @c d, and the vector pointing from starting point of the line, @c s, to the point @c p is positive: (d x (p - s)) > 0.
183 * It's on the line the cross product is zero and in the right half-plane it is negative.
184 * @note Keep in mind that if the point is not in the left half-plane, it doesn't necessarily mean that it's in the right half-plane because it could just as well be located on the line.
185 * @sa direction()
186 * @param point The point to check
187 * @return True, if the point is in the left half-plane
188 */
189 inline bool isLeftOfLine(const VectorT2<T>& point) const;
190
191 /**
192 * Returns the distance between the line and a given point.
193 * This function needs a unit vector as direction!
194 * @param point The point to return the distance for
195 * @return Distance between point and line
196 */
197 inline T distance(const VectorT2<T>& point) const;
198
199 /**
200 * Returns the square distance between the line and a given point.
201 * @param point The point to return the distance for
202 * @return The resulting square distance between point and line, with range [0, infinity)
203 */
204 inline T sqrDistance(const VectorT2<T>& point) const;
205
206 /**
207 * Returns the point lying on this finite line nearest to an arbitrary given point.
208 * This function needs a unit vector as direction!
209 * @param point Arbitrary point outside the line
210 * @return Nearest point on the finite line
211 * @see nearestPointOnInfiniteLine().
212 */
214
215 /**
216 * Returns the point on the infinite line (defined by this finite line) to an arbitrary given point.
217 * In addition to providing the projected point on the infinite line, this function can return the distance to the closest end point of the finite line when lying outside of the finite line's boundaries.
218 * A negative distance indicates a projected point close to point0(), a positive distance indicates a projected point close to point1().
219 * This function needs a unit vector as direction!
220 * @param point Arbitrary point outside the line
221 * @param outOfBoundaryDistance Optional resulting distance between the projected point on the infinite line and the closest end point of the finite line, with range (-infinity, infinity)
222 * @param finiteLineLocation Optional resulting location of the projected point in relation to the finite line so that the following holds point() + direction() * finiteLineLocation, with range (-infinity, infinity)
223 * @return Nearest point on the infinite line
224 * @see nearestPoint().
225 */
226 VectorT2<T> nearestPointOnInfiniteLine(const VectorT2<T>& point, T* outOfBoundaryDistance = nullptr, T* finiteLineLocation = nullptr) const;
227
228 /**
229 * Returns the unique intersection point of two finite lines.
230 * Two aligned lines do not have one common intersection point, so that the function will return 'false' in such a case.
231 * @param second The second line for intersection calculation
232 * @param point Resulting intersection point
233 * @return True, if both lines have a common intersection point
234 * @see intersects().
235 */
236 inline bool intersection(const FiniteLineT2<T>& second, VectorT2<T>& point) const;
237
238 /**
239 * Returns the unique intersection point of this finite line with an infinite line.
240 * Two aligned lines do not have one common intersection point, so that the function will return 'false' in such a case.
241 * @param second The second line for intersection calculation
242 * @param point Resulting intersection point
243 * @return True, if both lines have a common intersection point
244 * @see intersects().
245 */
246 inline bool intersection(const LineT2<T>& second, VectorT2<T>& point) const;
247
248 /**
249 * Returns whether two finite lines have a unique intersection point.
250 * @param second The second line to check
251 * @return True, if both lines intersect
252 * @see intersection().
253 */
254 inline bool intersects(const FiniteLineT2<T>& second) const;
255
256 /**
257 * Returns whether two finite lies have an intersection.
258 * @param second The second line to check
259 * @return True, if both lines intersect
260 * @see intersection().
261 */
262 inline bool intersects(const LineT2<T>& second) const;
263
264 /**
265 * Returns whether two lines are parallel up to a small epsilon.
266 * @param right Second line
267 * @return True, if so
268 */
269 inline bool isParallel(const FiniteLineT2<T>& right) const;
270
271 /**
272 * Check for collinearity with other line segment
273 * @param right Line to check for collinearity
274 * @param distanceEpsilon Acceptable distance of the endpoints of one line segment from the infinite line corresponding to the other line, default value: `Numeric::weakEps()`
275 * @param cosAngleEpsilon Cosine of the maximum angle that is allowed in order for the two segments to be considered parallel; default: cos(weakEps()), i.e., approx. one, range: [0, 1]
276 * @return True if the this line and the other one are collinear, otherwise false
277 */
278 inline bool isCollinear(const FiniteLineT2<T>& right, const T& distanceEpsilon = NumericT<T>::weakEps(), const T& cosAngleEpsilon = NumericT<T>::cos(NumericT<T>::weakEps())) const;
279
280 /**
281 * Returns whether this line has valid parameters.
282 * @return True, if so
283 */
284 inline bool isValid() const;
285
286 /**
287 * Returns whether two lines are equal up to a specified epsilon.
288 * Two lines are equal if both lines have the same end points (while the order of the points is not important).
289 * @param line The second line to be used for comparison, must be valid
290 * @param epsilon The maximal distance between two equal end points, with range [0, infinity)
291 * @return True, if so
292 */
293 inline bool isEqual(const FiniteLineT2<T>& line, const T& epsilon) const;
294
295 /**
296 * Returns whether two line are identical up to a small epsilon.
297 * Two finite lines are identical if both lines have the same endpoint (independent of the order of the end points).
298 * @param right The right line
299 * @return True, if so
300 * @see isEqual().
301 */
302 inline bool operator==(const FiniteLineT2<T>& right) const;
303
304 /**
305 * Returns whether two line are identical up to a small epsilon.
306 * @param right The right line
307 * @return True, if so
308 */
309 inline bool operator!=(const FiniteLineT2<T>& right) const;
310
311 /**
312 * Returns whether this line is valid.
313 * @return True, if so
314 */
315 explicit inline operator bool() const;
316
317 protected:
318
319 /// First end point of the line.
321
322 /// Second end point of the line.
324
325 /// Direction of the line with unit length, if the object holds valid parameters.
327};
328
329template <typename T>
331 point0_(point0),
332 point1_(point1),
333 direction_((point1 - point0).normalizedOrZero())
334{
335 // nothing to do here
336}
337
338template <typename T>
339template <typename U>
341{
342 point0_ = VectorT2<T>(line.point0());
343 point1_ = VectorT2<T>(line.point1());
344 direction_ = VectorT2<T>(line.direction());
345}
346
347template <typename T>
349{
350 return point0_;
351}
352
353template <typename T>
355{
356 return point1_;
357}
358
359template <typename T>
360inline const VectorT2<T>& FiniteLineT2<T>::point(const unsigned int index) const
361{
362 ocean_assert(index <= 1u);
363
364 if (index == 0u)
365 {
366 return point0_;
367 }
368 else
369 {
370 return point1_;
371 }
372}
373
374template <typename T>
376{
377 return (point0_ + point1_) * T(0.5);
378}
379
380template <typename T>
382{
383 return direction_;
384}
385
386template <typename T>
388{
389 ocean_assert(isValid());
390 const VectorT2<T> result = -direction_.perpendicular();
391 ocean_assert(Ocean::NumericT<T>::isEqual(result.length(), T(1)));
392 ocean_assert(result.cross(direction_) > 0);
393 return result;
394}
395
396template <typename T>
398{
399 return (point1_ - point0_).sqr();
400}
401
402template <typename T>
404{
405 return (point1_ - point0_).length();
406}
407
408template <typename T>
409inline bool FiniteLineT2<T>::isOnLine(const VectorT2<T>& point) const
410{
411 ocean_assert(isValid());
412
414}
415
416template <typename T>
417inline bool FiniteLineT2<T>::isOnInfiniteLine(const VectorT2<T>& point) const
418{
419 ocean_assert(isValid());
420
421 return NumericT<T>::isEqualEps(nearestPointOnInfiniteLine(point).sqrDistance(point));
422}
423
424template <typename T>
425inline bool FiniteLineT2<T>::isLeftOfLine(const VectorT2<T>& point) const
426{
427 ocean_assert(isValid());
428
429 return LineT2<T>(point0_, direction_).isLeftOfLine(point);
430}
431
432template <typename T>
433inline T FiniteLineT2<T>::distance(const VectorT2<T>& point) const
434{
435 ocean_assert(isValid());
436
437 return NumericT<T>::sqrt(sqrDistance(point));
438}
439
440template <typename T>
441inline T FiniteLineT2<T>::sqrDistance(const VectorT2<T>& point) const
442{
443 ocean_assert(isValid());
444
445 return nearestPoint(point).sqrDistance(point);
446}
447
448template <typename T>
450{
451 ocean_assert(isValid());
452
453 const VectorT2<T> lineOffset(point1_ - point0_);
454 const VectorT2<T> pointOffset(point - point0_);
455
456 const T dotProduct = lineOffset * pointOffset;
457
458 // the projected point does not lie on the finite line (before the first end point)
459 if (dotProduct <= 0)
460 {
461 return point0_;
462 }
463
464 // the projected point does not lie on the finite line (behind the second end point)
465 if (dotProduct >= lineOffset.sqr())
466 {
467 return point1_;
468 }
469
470 // the projected point lies on the finite line
471 return point0_ + direction_ * (pointOffset * direction_);
472}
473
474template <typename T>
475VectorT2<T> FiniteLineT2<T>::nearestPointOnInfiniteLine(const VectorT2<T>& point, T* outOfBoundaryDistance, T* finiteLineLocation) const
476{
477 ocean_assert(isValid());
478
479 const VectorT2<T> lineOffset(point1_ - point0_);
480 const VectorT2<T> pointOffset(point - point0_);
481
482 const T dotProduct = lineOffset * pointOffset;
483
484 if (dotProduct <= 0)
485 {
486 // the projected point does not lie on the finite line (before the first end point)
487
488 if (outOfBoundaryDistance)
489 {
490 // we have a negative distance
491
492 *outOfBoundaryDistance = std::min(pointOffset * direction_, T(0));
493 ocean_assert(*outOfBoundaryDistance <= T(0));
494 }
495 }
496 else if (dotProduct >= lineOffset.sqr())
497 {
498 // the projected point does not lie on the finite line (behind the second end point)
499
500 if (outOfBoundaryDistance)
501 {
502 // we have a positive distance
503
504 *outOfBoundaryDistance = std::max(T(0), pointOffset * direction_ - length());
505 ocean_assert(*outOfBoundaryDistance >= T(0));
506 }
507 }
508 else
509 {
510 // the projected point lies within the finite line
511
512 if (outOfBoundaryDistance)
513 {
514 *outOfBoundaryDistance = T(0);
515 }
516 }
517
518 const T length = pointOffset * direction_;
519
520 if (finiteLineLocation)
521 {
522 // the location in relation to the finite line is just the 1D position
523 // on the line starting at point0 with positive values towards point1
524
525 *finiteLineLocation = length;
526 }
527
528 // the projected point lies on the finite line
529 return point0_ + direction_ * length;
530}
531
532template <typename T>
533inline bool FiniteLineT2<T>::intersection(const FiniteLineT2<T>& second, VectorT2<T>& point) const
534{
535 ocean_assert(isValid() && second.isValid());
536 if (!LineT2<T>(point0_, direction_).intersection(LineT2<T>(second.point0_, second.direction_), point))
537 {
538 // we do not have an intersection on the infinite lines
539 return false;
540 }
541
542 // now we check whether the intersection points lies within the ranges [point0, point1]
543
544 const T lengthOnThisLine = direction_ * (point - point0_);
545 const T lengthOnSecondLine = second.direction_ * (point - second.point0_);
546
547 if (lengthOnThisLine < T(0) || lengthOnSecondLine < T(0) || NumericT<T>::sqr(lengthOnThisLine) > sqrLength() || NumericT<T>::sqr(lengthOnSecondLine) > second.sqrLength())
548 {
549 return false;
550 }
551
552 return true;
553}
554
555template <typename T>
556inline bool FiniteLineT2<T>::intersection(const LineT2<T>& second, VectorT2<T>& point) const
557{
558 ocean_assert(isValid() && second.isValid());
559 if (!LineT2<T>(point0_, direction_).intersection(second, point))
560 {
561 // we do not have an intersection on the infinite lines
562 return false;
563 }
564
565 // now we check whether the intersection points lies within the ranges [point0, point1]
566
567 const T lengthOnThisLine = direction_ * (point - point0_);
568
569 if (lengthOnThisLine < T(0) || NumericT<T>::sqr(lengthOnThisLine) > sqrLength())
570 {
571 return false;
572 }
573
574 return true;
575}
576
577template <typename T>
578inline bool FiniteLineT2<T>::intersects(const FiniteLineT2<T>& second) const
579{
580 ocean_assert(isValid() && second.isValid());
581
582 VectorT2<T> dummyPoint;
583 return intersection(second, dummyPoint);
584}
585
586template <typename T>
587inline bool FiniteLineT2<T>::intersects(const LineT2<T>& second) const
588{
589 ocean_assert(isValid() && second.isValid());
590
591 VectorT2<T> dummyPoint;
592 return intersection(second, dummyPoint);
593}
594
595template <typename T>
596inline bool FiniteLineT2<T>::isParallel(const FiniteLineT2<T>& right) const
597{
598 ocean_assert(isValid() && right.isValid());
599
600 return direction_ == right.direction_ || direction_ == -right.direction_;
601}
602
603template <typename T>
604inline bool FiniteLineT2<T>::isCollinear(const FiniteLineT2<T>& right, const T& distanceEpsilon, const T& cosAngleEpsilon) const
605{
606 ocean_assert(isValid() && right.isValid());
607 ocean_assert(NumericT<T>::isInsideRange((T)0, cosAngleEpsilon, (T)1));
608
609 // Distances of the end-points of one line to the other should be within the band defined by +/- epsilon.
610 const T squareDistanceEpsilon = distanceEpsilon * distanceEpsilon;
611 const bool validDistanceRightToThis = (nearestPointOnInfiniteLine(right.point0()) - right.point0()).sqr() <= squareDistanceEpsilon && (nearestPointOnInfiniteLine(right.point1()) - right.point1()).sqr() <= squareDistanceEpsilon;
612 const bool validDistanceThisToRight = (right.nearestPointOnInfiniteLine(point0()) - point0()).sqr() <= squareDistanceEpsilon && (right.nearestPointOnInfiniteLine(point1()) - point1()).sqr() <= squareDistanceEpsilon;
613
614 // Both normalized lines directions should be parallel and pointing into the same or opposing direction
615 const T cosAngle = normal() * right.normal();
616 const bool validNormalOrientations = NumericT<T>::abs(cosAngle) >= cosAngleEpsilon;
617
618 return validDistanceRightToThis && validDistanceThisToRight && validNormalOrientations;
619}
620
621template <typename T>
622inline bool FiniteLineT2<T>::isValid() const
623{
624 return !direction_.isNull();
625}
626
627template <typename T>
628inline bool FiniteLineT2<T>::isEqual(const FiniteLineT2<T>& line, const T& epsilon) const
629{
630 ocean_assert(isValid() && line.isValid());
631
632 const T sqrDistance = NumericT<T>::sqr(epsilon);
633
634 return (point0_.sqrDistance(line.point0_) <= sqrDistance && point1_.sqrDistance(line.point1_) <= sqrDistance)
635 || (point0_.sqrDistance(line.point1_) <= sqrDistance && point1_.sqrDistance(line.point0_) <= sqrDistance);
636}
637
638template <typename T>
640{
641 return (point0_ == right.point0_ && point1_ == right.point1_)
642 || (point0_ == right.point1_ && point1_ == right.point0_);
643}
644
645template <typename T>
646inline bool FiniteLineT2<T>::operator!=(const FiniteLineT2<T>& right) const
647{
648 return !(*this == right);
649}
650
651template <typename T>
652inline FiniteLineT2<T>::operator bool() const
653{
654 return isValid();
655}
656
657}
658
659#endif // META_OCEAN_MATH_FINITE_LINE_2_H
bool isLeftOfLine(const VectorT2< T > &point) const
Check if a point is in the left half-plane of the direction vector of a line A point p is located on ...
Definition FiniteLine2.h:425
const VectorT2< T > & point(const unsigned int index) const
Returns the first or second end point of the line.
Definition FiniteLine2.h:360
FiniteLineT2(const FiniteLineT2< U > &line)
Copies a line with different data type than T.
Definition FiniteLine2.h:340
bool isValid() const
Returns whether this line has valid parameters.
Definition FiniteLine2.h:622
bool isEqual(const FiniteLineT2< T > &line, const T &epsilon) const
Returns whether two lines are equal up to a specified epsilon.
Definition FiniteLine2.h:628
VectorT2< T > direction_
Direction of the line with unit length, if the object holds valid parameters.
Definition FiniteLine2.h:326
bool intersects(const LineT2< T > &second) const
Returns whether two finite lies have an intersection.
Definition FiniteLine2.h:587
bool intersection(const FiniteLineT2< T > &second, VectorT2< T > &point) const
Returns the unique intersection point of two finite lines.
Definition FiniteLine2.h:533
FiniteLineT2()=default
Creates a finite line with default parameters.
T length() const
Returns the length of the finite line.
Definition FiniteLine2.h:403
bool operator!=(const FiniteLineT2< T > &right) const
Returns whether two line are identical up to a small epsilon.
Definition FiniteLine2.h:646
VectorT2< T > point1_
Second end point of the line.
Definition FiniteLine2.h:323
bool isOnLine(const VectorT2< T > &point) const
Returns whether a given point is part of the finite line.
Definition FiniteLine2.h:409
T Type
Definition of the used data type.
Definition FiniteLine2.h:88
bool isOnInfiniteLine(const VectorT2< T > &point) const
Returns whether a given point lies on the infinite line defined by this finite line.
Definition FiniteLine2.h:417
bool isParallel(const FiniteLineT2< T > &right) const
Returns whether two lines are parallel up to a small epsilon.
Definition FiniteLine2.h:596
const VectorT2< T > & direction() const
Returns the direction of the line: normalized(point1() - point0())
Definition FiniteLine2.h:381
FiniteLineT2(const VectorT2< T > &point0, const VectorT2< T > &point1)
Creates a finite line defined by two end points of the line.
Definition FiniteLine2.h:330
bool intersects(const FiniteLineT2< T > &second) const
Returns whether two finite lines have a unique intersection point.
Definition FiniteLine2.h:578
bool isCollinear(const FiniteLineT2< T > &right, const T &distanceEpsilon=NumericT< T >::weakEps(), const T &cosAngleEpsilon=NumericT< T >::cos(NumericT< T >::weakEps())) const
Check for collinearity with other line segment.
Definition FiniteLine2.h:604
T distance(const VectorT2< T > &point) const
Returns the distance between the line and a given point.
Definition FiniteLine2.h:433
const VectorT2< T > & point0() const
Returns the first end point of the line.
Definition FiniteLine2.h:348
bool operator==(const FiniteLineT2< T > &right) const
Returns whether two line are identical up to a small epsilon.
Definition FiniteLine2.h:639
T sqrDistance(const VectorT2< T > &point) const
Returns the square distance between the line and a given point.
Definition FiniteLine2.h:441
const VectorT2< T > normal() const
Returns the normal of the line: -direction().perpendicular() The 2D cross product between the resulti...
Definition FiniteLine2.h:387
VectorT2< T > nearestPoint(const VectorT2< T > &point) const
Returns the point lying on this finite line nearest to an arbitrary given point.
Definition FiniteLine2.h:449
VectorT2< T > nearestPointOnInfiniteLine(const VectorT2< T > &point, T *outOfBoundaryDistance=nullptr, T *finiteLineLocation=nullptr) const
Returns the point on the infinite line (defined by this finite line) to an arbitrary given point.
Definition FiniteLine2.h:475
VectorT2< T > point0_
First end point of the line.
Definition FiniteLine2.h:320
const VectorT2< T > & point1() const
Returns the second end point of the line.
Definition FiniteLine2.h:354
bool intersection(const LineT2< T > &second, VectorT2< T > &point) const
Returns the unique intersection point of this finite line with an infinite line.
Definition FiniteLine2.h:556
VectorT2< T > midpoint() const
Returns the midpoint of the line.
Definition FiniteLine2.h:375
T sqrLength() const
Returns the squared length of the finite line.
Definition FiniteLine2.h:397
This class implements an infinite line in 2D space.
Definition Line2.h:83
bool isValid() const
Returns whether this line has valid parameters.
Definition Line2.h:405
bool isLeftOfLine(const VectorT2< T > &point) const
Check if a point is in the left half-plane of the direction vector of a line A point p is located on ...
Definition Line2.h:455
This class provides basic numeric functionalities.
Definition Numeric.h:57
static T abs(const T value)
Returns the absolute value of a given value.
Definition Numeric.h:1220
static T sqrt(const T value)
Returns the square root of a given value.
Definition Numeric.h:1533
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition Numeric.h:1495
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2087
This class implements a vector with two elements.
Definition Vector2.h:96
T sqr() const
Returns the square of the vector length.
Definition Vector2.h:633
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition Vector2.h:746
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:645
T length() const
Returns the length of the vector.
Definition Vector2.h:627
T cross(const VectorT2< T > &vector) const
Returns the cross product of two 2D vectors.
Definition Vector2.h:556
VectorT2< T > perpendicular() const
Returns a vector perpendicular to this vectors.
Definition Vector2.h:562
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition base/Utilities.h:1089
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition base/Utilities.h:1029
std::vector< FiniteLineD2 > FiniteLinesD2
Definition of a vector holding FiniteLineD2 objects.
Definition FiniteLine2.h:64
std::vector< FiniteLineT2< T > > FiniteLinesT2
Definition of a typename alias for vectors with FiniteLineT2 objects.
Definition FiniteLine2.h:50
std::vector< FiniteLineF2 > FiniteLinesF2
Definition of a vector holding FiniteLineF2 objects.
Definition FiniteLine2.h:71
std::vector< FiniteLine2 > FiniteLines2
Definition of a vector holding FiniteLine2 objects.
Definition FiniteLine2.h:57
The namespace covering the entire Ocean framework.
Definition Accessor.h:15