KiCad PCB EDA Suite
Loading...
Searching...
No Matches
vector2d.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2010 Virtenio GmbH, Torsten Hueter, torsten.hueter <at> virtenio.de
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 * Copyright (C) 2013 CERN
8 * @author Tomasz Wlostowski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef VECTOR2D_H_
25#define VECTOR2D_H_
26
27#include <algorithm>
28#include <limits>
29#include <iostream>
30#include <sstream>
31#include <type_traits>
32
33#include <math/util.h>
34
38template <class T>
40{
44};
45
46template <>
47struct VECTOR2_TRAITS<int>
48{
49 typedef int64_t extended_type;
50};
51
52// Forward declarations for template friends
53template <class T>
54class VECTOR2;
55template <class T>
56std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector );
57
65template <class T = int>
67{
68public:
70 typedef T coord_type;
71
72 static constexpr extended_type ECOORD_MAX = std::numeric_limits<extended_type>::max();
73 static constexpr extended_type ECOORD_MIN = std::numeric_limits<extended_type>::min();
74
75 T x, y;
76
78 constexpr VECTOR2();
79
81 constexpr VECTOR2( T x, T y );
82
84 template <typename CastingType>
85 constexpr VECTOR2( const VECTOR2<CastingType>& aVec )
86 {
87 if constexpr( std::is_floating_point<T>() )
88 {
89 x = static_cast<T>( aVec.x );
90 y = static_cast<T>( aVec.y );
91 }
92 else if constexpr( std::is_floating_point<CastingType>() )
93 {
94 CastingType minI = static_cast<CastingType>( std::numeric_limits<T>::min() );
95 CastingType maxI = static_cast<CastingType>( std::numeric_limits<T>::max() );
96
97 x = static_cast<T>( std::clamp( aVec.x, minI, maxI ) );
98 y = static_cast<T>( std::clamp( aVec.y, minI, maxI ) );
99 }
100 else if constexpr( std::is_integral<T>() && std::is_integral<CastingType>() )
101 {
102 int64_t minI = static_cast<int64_t>( std::numeric_limits<T>::min() );
103 int64_t maxI = static_cast<int64_t>( std::numeric_limits<T>::max() );
104
105 x = static_cast<T>( std::clamp( static_cast<int64_t>( aVec.x ), minI, maxI ) );
106 y = static_cast<T>( std::clamp( static_cast<int64_t>( aVec.y ), minI, maxI ) );
107 }
108 else
109 {
110 x = static_cast<T>( aVec.x );
111 y = static_cast<T>( aVec.y );
112 }
113 }
114
116 constexpr VECTOR2( const VECTOR2<T>& aVec )
117 {
118 x = aVec.x;
119 y = aVec.y;
120 }
121
123 template <typename U>
124 constexpr VECTOR2<U> operator()() const
125 {
126 if constexpr( std::is_floating_point<U>::value )
127 {
128 return VECTOR2<U>( static_cast<U>( x ), static_cast<U>( y ) );
129 }
130 else if constexpr( std::is_floating_point<T>() )
131 {
132 constexpr T minI = static_cast<T>( std::numeric_limits<U>::min() );
133 constexpr T maxI = static_cast<T>( std::numeric_limits<U>::max() );
134 return VECTOR2<U>( static_cast<U>( std::clamp( x, minI, maxI ) ),
135 static_cast<U>( std::clamp( y, minI, maxI ) ) );
136 }
137 else if constexpr( std::is_integral<T>() && std::is_integral<U>() )
138 {
139 constexpr int64_t minI = static_cast<int64_t>( std::numeric_limits<U>::min() );
140 constexpr int64_t maxI = static_cast<int64_t>( std::numeric_limits<U>::max() );
141 int64_t x64 = static_cast<int64_t>( x );
142 int64_t y64 = static_cast<int64_t>( y );
143
144 return VECTOR2<U>(
145 static_cast<U>( std::clamp( x64, minI, maxI ) ),
146 static_cast<U>( std::clamp( y64, minI, maxI ) ) );
147 }
148 else
149 {
150 return VECTOR2<U>( static_cast<U>( x ), static_cast<U>( y ) );
151 }
152 }
153
162
171
172
178 constexpr VECTOR2<T> Perpendicular() const;
179
186 VECTOR2<T> Resize( T aNewLength ) const;
187
193 const std::string Format() const;
194
198 constexpr extended_type Cross( const VECTOR2<T>& aVector ) const;
199
203 constexpr extended_type Dot( const VECTOR2<T>& aVector ) const;
204
209 double Distance( const VECTOR2<extended_type>& aVector ) const;
210
214 constexpr extended_type SquaredDistance( const VECTOR2<T>& aVector ) const;
215
216 // Operators
217
219 constexpr VECTOR2<T>& operator=( const VECTOR2<T>& aVector );
220
222 constexpr VECTOR2<T>& operator+=( const VECTOR2<T>& aVector );
223
225 constexpr VECTOR2<T>& operator*=( const VECTOR2<T>& aVector );
226
227 constexpr VECTOR2<T>& operator*=( const T& aScalar );
228
230 constexpr VECTOR2<T>& operator+=( const T& aScalar );
231
233 constexpr VECTOR2<T>& operator-=( const VECTOR2<T>& aVector );
234
236 constexpr VECTOR2<T>& operator-=( const T& aScalar );
237
240
242 constexpr VECTOR2<T> operator/( double aFactor ) const;
243
245 constexpr bool operator==( const VECTOR2<T>& aVector ) const;
246
248 constexpr bool operator!=( const VECTOR2<T>& aVector ) const;
249
251 constexpr bool operator<( const VECTOR2<T>& aVector ) const;
252 constexpr bool operator<=( const VECTOR2<T>& aVector ) const;
253
255 constexpr bool operator>( const VECTOR2<T>& aVector ) const;
256 constexpr bool operator>=( const VECTOR2<T>& aVector ) const;
257};
258
259
260// ----------------------
261// --- Implementation ---
262// ----------------------
263
264template <class T>
265constexpr VECTOR2<T>::VECTOR2() : x{}, y{}
266{
267}
268
269
270template <class T>
271constexpr VECTOR2<T>::VECTOR2( T aX, T aY )
272{
273 x = aX;
274 y = aY;
275}
276
277
278template <class T>
280{
281 // 45° are common in KiCad, so we can optimize the calculation
282 if( std::abs( x ) == std::abs( y ) )
283 {
284 if constexpr( std::is_integral<T>::value )
285 return KiROUND<double, T>( std::abs( x ) * M_SQRT2 );
286 else
287 return static_cast<T>( std::abs( x ) * M_SQRT2 );
288 }
289
290 if( x == 0 )
291 return static_cast<T>( std::abs( y ) );
292 if( y == 0 )
293 return static_cast<T>( std::abs( x ) );
294
295 if constexpr( std::is_integral<T>::value )
296 return KiROUND<double, T>( std::hypot( x, y ) );
297 else
298 return static_cast<T>( std::hypot( x, y ) );
299}
300
301
302template <class T>
304{
305 return (extended_type) x * x + (extended_type) y * y;
306}
307
308
309template <class T>
311{
312 VECTOR2<T> perpendicular( -y, x );
313 return perpendicular;
314}
315
316
317template <class T>
318constexpr VECTOR2<T>& VECTOR2<T>::operator=( const VECTOR2<T>& aVector )
319{
320 x = aVector.x;
321 y = aVector.y;
322 return *this;
323}
324
325
326template <class T>
327constexpr VECTOR2<T>& VECTOR2<T>::operator+=( const VECTOR2<T>& aVector )
328{
329 x += aVector.x;
330 y += aVector.y;
331 return *this;
332}
333
334
335template <class T>
336constexpr VECTOR2<T>& VECTOR2<T>::operator*=( const VECTOR2<T>& aVector )
337{
338 x *= aVector.x;
339 y *= aVector.y;
340 return *this;
341}
342
343
344template <class T>
345constexpr VECTOR2<T>& VECTOR2<T>::operator*=( const T& aScalar )
346{
347 x *= aScalar;
348 y *= aScalar;
349 return *this;
350}
351
352
353template <class T>
354constexpr VECTOR2<T>& VECTOR2<T>::operator+=( const T& aScalar )
355{
356 x += aScalar;
357 y += aScalar;
358 return *this;
359}
360
361
362template <class T>
363constexpr VECTOR2<T>& VECTOR2<T>::operator-=( const VECTOR2<T>& aVector )
364{
365 x -= aVector.x;
366 y -= aVector.y;
367 return *this;
368}
369
370
371template <class T>
372constexpr VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar )
373{
374 x -= aScalar;
375 y -= aScalar;
376 return *this;
377}
378
379
380template <class T>
381VECTOR2<T> VECTOR2<T>::Resize( T aNewLength ) const
382{
383 if( x == 0 && y == 0 )
384 return VECTOR2<T> ( 0, 0 );
385
386 double newX;
387 double newY;
388
389 if( std::abs( x ) == std::abs( y ) )
390 {
391 newX = newY = std::abs( aNewLength ) * M_SQRT1_2;
392 }
393 else
394 {
395 extended_type x_sq = (extended_type) x * x;
396 extended_type y_sq = (extended_type) y * y;
397 extended_type l_sq = x_sq + y_sq;
398 extended_type newLength_sq = (extended_type) aNewLength * aNewLength;
399 newX = std::sqrt( rescale( newLength_sq, x_sq, l_sq ) );
400 newY = std::sqrt( rescale( newLength_sq, y_sq, l_sq ) );
401 }
402
403 if constexpr( std::is_integral<T>::value )
404 {
405 return VECTOR2<T>( static_cast<T>( x < 0 ? -KiROUND( newX ) : KiROUND( newX ) ),
406 static_cast<T>( y < 0 ? -KiROUND( newY ) : KiROUND( newY ) ) )
407 * sign( aNewLength );
408 }
409 else
410 {
411 return VECTOR2<T>( static_cast<T>( x < 0 ? -newX : newX ),
412 static_cast<T>( y < 0 ? -newY : newY ) )
413 * sign( aNewLength );
414 }
415}
416
417
418template <class T>
419const std::string VECTOR2<T>::Format() const
420{
421 std::stringstream ss;
422
423 ss << "( xy " << x << " " << y << " )";
424
425 return ss.str();
426}
427
428
429template <class T>
430concept FloatingPoint = std::is_floating_point<T>::value;
431
432template <class T>
433concept Integral = std::is_integral<T>::value;
434
435
436template <class T, class U>
438 const VECTOR2<U>& aRHS )
439{
440 return VECTOR2<std::common_type_t<T, U>>( aLHS.x + aRHS.x, aLHS.y + aRHS.y );
441}
442
443
444template <FloatingPoint T, class U>
445constexpr VECTOR2<T> operator+( const VECTOR2<T>& aLHS, const U& aScalar )
446{
447 return VECTOR2<T>( aLHS.x + aScalar, aLHS.y + aScalar );
448}
449
450
451template <Integral T, Integral U>
452constexpr VECTOR2<T> operator+( const VECTOR2<T>& aLHS, const U& aScalar )
453{
454 return VECTOR2<T>( aLHS.x + aScalar, aLHS.y + aScalar );
455}
456
457
458template <Integral T, FloatingPoint U>
459constexpr VECTOR2<T> operator+( const VECTOR2<T>& aLHS, const U& aScalar )
460{
461 return VECTOR2<T>( KiROUND( aLHS.x + aScalar ), KiROUND( aLHS.y + aScalar ) );
462}
463
464
465template <class T, class U>
467 const VECTOR2<U>& aRHS )
468{
469 return VECTOR2<std::common_type_t<T, U>>( aLHS.x - aRHS.x, aLHS.y - aRHS.y );
470}
471
472
473template <FloatingPoint T, class U>
474constexpr VECTOR2<T> operator-( const VECTOR2<T>& aLHS, U aScalar )
475{
476 return VECTOR2<T>( aLHS.x - aScalar, aLHS.y - aScalar );
477}
478
479
480template <Integral T, Integral U>
481constexpr VECTOR2<T> operator-( const VECTOR2<T>& aLHS, U aScalar )
482{
483 return VECTOR2<T>( aLHS.x - aScalar, aLHS.y - aScalar );
484}
485
486
487template <Integral T, FloatingPoint U>
488constexpr VECTOR2<T> operator-( const VECTOR2<T>& aLHS, const U& aScalar )
489{
490 return VECTOR2<T>( KiROUND( aLHS.x - aScalar ), KiROUND( aLHS.y - aScalar ) );
491}
492
493
494template <class T>
496{
497 return VECTOR2<T> ( -x, -y );
498}
499
500
501template <class T, class U>
502constexpr auto operator*( const VECTOR2<T>& aLHS, const VECTOR2<U>& aRHS )
503{
505 return (extended_type)aLHS.x * aRHS.x + (extended_type)aLHS.y * aRHS.y;
506}
507
508
509template <class T, class U>
510constexpr VECTOR2<std::common_type_t<T, U>> operator*( const VECTOR2<T>& aLHS, const U& aScalar )
511{
512 return VECTOR2<std::common_type_t<T, U>>( aLHS.x * aScalar, aLHS.y * aScalar );
513}
514
515
516template <class T, class U>
517constexpr VECTOR2<std::common_type_t<T, U>> operator*( const T& aScalar, const VECTOR2<U>& aVector )
518{
519 return VECTOR2<std::common_type_t<T, U>>( aScalar * aVector.x, aScalar * aVector.y );
520}
521
522
523template <class T>
524constexpr VECTOR2<T> VECTOR2<T>::operator/( double aFactor ) const
525{
526 if constexpr( std::is_integral<T>::value )
527 return VECTOR2<T>( KiROUND( x / aFactor ), KiROUND( y / aFactor ) );
528 else
529 return VECTOR2<T>( static_cast<T>( x / aFactor ), static_cast<T>( y / aFactor ) );
530}
531
532
533template <class T>
534constexpr typename VECTOR2<T>::extended_type VECTOR2<T>::Cross( const VECTOR2<T>& aVector ) const
535{
536 return (extended_type) x * (extended_type) aVector.y -
537 (extended_type) y * (extended_type) aVector.x;
538}
539
540
541template <class T>
542constexpr typename VECTOR2<T>::extended_type VECTOR2<T>::Dot( const VECTOR2<T>& aVector ) const
543{
544 return (extended_type) x * (extended_type) aVector.x +
545 (extended_type) y * (extended_type) aVector.y;
546}
547
548template <class T>
549double VECTOR2<T>::Distance( const VECTOR2<extended_type>& aVector ) const
550{
551 VECTOR2<double> diff( static_cast<double>( aVector.x - x ), static_cast<double>( aVector.y - y ) );
552 return diff.EuclideanNorm();
553}
554
555template <class T>
556constexpr typename VECTOR2<T>::extended_type
558{
559 const extended_type dx = (extended_type) x - aVector.x;
560 const extended_type dy = (extended_type) y - aVector.y;
561 return dx * dx + dy * dy;
562}
563
564
565template <class T>
566constexpr bool VECTOR2<T>::operator<( const VECTOR2<T>& aVector ) const
567{
568 return ( *this * *this ) < ( aVector * aVector );
569}
570
571
572template <class T>
573constexpr bool VECTOR2<T>::operator<=( const VECTOR2<T>& aVector ) const
574{
575 return ( *this * *this ) <= ( aVector * aVector );
576}
577
578
579template <class T>
580constexpr bool VECTOR2<T>::operator>( const VECTOR2<T>& aVector ) const
581{
582 return ( *this * *this ) > ( aVector * aVector );
583}
584
585
586template <class T>
587constexpr bool VECTOR2<T>::operator>=( const VECTOR2<T>& aVector ) const
588{
589 return ( *this * *this ) >= ( aVector * aVector );
590}
591
592
593template <class T>
594constexpr bool VECTOR2<T>::operator==( VECTOR2<T> const& aVector ) const
595{
596 return ( aVector.x == x ) && ( aVector.y == y );
597}
598
599
600template <class T>
601constexpr bool VECTOR2<T>::operator!=( VECTOR2<T> const& aVector ) const
602{
603 return ( aVector.x != x ) || ( aVector.y != y );
604}
605
606
607template <class T>
608constexpr const VECTOR2<T>& LexicographicalMax( const VECTOR2<T>& aA, const VECTOR2<T>& aB )
609{
610 if( aA.x > aB.x )
611 return aA;
612 else if( aA.x == aB.x && aA.y > aB.y )
613 return aA;
614
615 return aB;
616}
617
618
619template <class T>
620constexpr const VECTOR2<T>& LexicographicalMin( const VECTOR2<T>& aA, const VECTOR2<T>& aB )
621{
622 if( aA.x < aB.x )
623 return aA;
624 else if( aA.x == aB.x && aA.y < aB.y )
625 return aA;
626
627 return aB;
628}
629
630
631template <class T>
632constexpr int LexicographicalCompare( const VECTOR2<T>& aA, const VECTOR2<T>& aB )
633{
634 if( aA.x < aB.x )
635 return -1;
636 else if( aA.x > aB.x )
637 return 1;
638 else // aA.x == aB.x
639 {
640 if( aA.y < aB.y )
641 return -1;
642 else if( aA.y > aB.y )
643 return 1;
644 else
645 return 0;
646 }
647}
648
649
660template <class T>
661typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type
662equals( VECTOR2<T> const& aFirst, VECTOR2<T> const& aSecond,
663 T aEpsilon = std::numeric_limits<T>::epsilon() )
664{
665 if( !equals( aFirst.x, aSecond.x, aEpsilon ) )
666 {
667 return false;
668 }
669
670 return equals( aFirst.y, aSecond.y, aEpsilon );
671}
672
673
674template <class T>
675std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector )
676{
677 aStream << "[ " << aVector.x << " | " << aVector.y << " ]";
678 return aStream;
679}
680
681/* Default specializations */
685
686/* KiROUND specialization for vectors */
687inline constexpr VECTOR2I KiROUND( const VECTOR2D& vec )
688{
689 return VECTOR2I( KiROUND( vec.x ), KiROUND( vec.y ) );
690}
691
692inline constexpr VECTOR2I KiROUND( double x, double y )
693{
694 return VECTOR2I( KiROUND( x ), KiROUND( y ) );
695}
696
697/* STL specializations */
698namespace std
699{
700 // Required to enable correct use in std::map/unordered_map
701 // DO NOT USE hash tables with VECTOR2 elements. It is inefficient
702 // and degenerates to a linear search. Use the std::map/std::set
703 // trees instead that utilize the less operator below
704 // This function is purposely deleted after substantial testing
705 template <>
706 struct hash<VECTOR2I>
707 {
708 size_t operator()( const VECTOR2I& k ) const = delete;
709 };
710
711 // Required to enable use of std::hash with maps.
712 template <>
713 struct less<VECTOR2I>
714 {
715 bool operator()( const VECTOR2I& aA, const VECTOR2I& aB ) const;
716 };
717}
718
719#endif // VECTOR2D_H_
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
Define a general 2D-vector/point.
Definition vector2d.h:67
constexpr bool operator==(const VECTOR2< T > &aVector) const
Equality operator.
Definition vector2d.h:594
constexpr bool operator>=(const VECTOR2< T > &aVector) const
Definition vector2d.h:587
constexpr VECTOR2< U > operator()() const
Cast a vector to another specialized subclass. Beware of rounding issues.
Definition vector2d.h:124
constexpr VECTOR2< T > & operator=(const VECTOR2< T > &aVector)
Assignment operator.
Definition vector2d.h:318
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
Definition vector2d.h:534
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition vector2d.h:549
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition vector2d.h:303
constexpr extended_type SquaredDistance(const VECTOR2< T > &aVector) const
Compute the squared distance between two vectors.
Definition vector2d.h:557
const std::string Format() const
Return the vector formatted as a string.
Definition vector2d.h:419
constexpr VECTOR2< T > & operator*=(const VECTOR2< T > &aVector)
Compound assignment operator.
Definition vector2d.h:336
static constexpr extended_type ECOORD_MAX
Definition vector2d.h:72
constexpr VECTOR2< T > & operator-=(const T &aScalar)
Compound assignment operator.
Definition vector2d.h:372
constexpr VECTOR2< T > & operator+=(const T &aScalar)
Compound assignment operator.
Definition vector2d.h:354
constexpr bool operator!=(const VECTOR2< T > &aVector) const
Not equality operator.
Definition vector2d.h:601
constexpr VECTOR2< T > & operator-=(const VECTOR2< T > &aVector)
Compound assignment operator.
Definition vector2d.h:363
constexpr bool operator<(const VECTOR2< T > &aVector) const
Smaller than operator.
Definition vector2d.h:566
constexpr VECTOR2< T > operator-()
Negate Vector operator.
Definition vector2d.h:495
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition vector2d.h:279
VECTOR2_TRAITS< size_type >::extended_type extended_type
Definition vector2d.h:69
constexpr VECTOR2< T > operator/(double aFactor) const
Division with a factor.
Definition vector2d.h:524
constexpr VECTOR2(const VECTOR2< CastingType > &aVec)
Initializes a vector from another specialization. Beware of rounding issues.
Definition vector2d.h:85
constexpr VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition vector2d.h:310
static constexpr extended_type ECOORD_MIN
Definition vector2d.h:73
constexpr VECTOR2(const VECTOR2< T > &aVec)
Copy a vector.
Definition vector2d.h:116
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
Definition vector2d.h:542
constexpr VECTOR2(T x, T y)
Construct a vector with given components x, y.
Definition vector2d.h:271
constexpr VECTOR2< T > & operator*=(const T &aScalar)
Definition vector2d.h:345
constexpr bool operator<=(const VECTOR2< T > &aVector) const
Definition vector2d.h:573
constexpr VECTOR2()
Construct a 2D-vector with x, y = 0.
Definition vector2d.h:265
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition vector2d.h:381
constexpr VECTOR2< T > & operator+=(const VECTOR2< T > &aVector)
Compound assignment operator.
Definition vector2d.h:327
size_type coord_type
Definition vector2d.h:70
constexpr bool operator>(const VECTOR2< T > &aVector) const
Greater than operator.
Definition vector2d.h:580
STL namespace.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
Traits class for VECTOR2.
Definition vector2d.h:40
T extended_type
extended range/precision types used by operations involving multiple multiplications to prevent overf...
Definition vector2d.h:43
size_t operator()(const VECTOR2I &k) const =delete
bool operator()(const VECTOR2I &aA, const VECTOR2I &aB) const
Definition vector2.cpp:22
constexpr int sign(T val)
Definition util.h:141
T rescale(T aNumerator, T aValue, T aDenominator)
Scale a number (value) by rational (numerator/denominator).
Definition util.h:135
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682
std::ostream & operator<<(std::ostream &aStream, const VECTOR2< T > &aVector)
Definition vector2d.h:675
constexpr const VECTOR2< T > & LexicographicalMax(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition vector2d.h:608
constexpr VECTOR2I KiROUND(const VECTOR2D &vec)
Definition vector2d.h:687
constexpr VECTOR2< std::common_type_t< T, U > > operator+(const VECTOR2< T > &aLHS, const VECTOR2< U > &aRHS)
Definition vector2d.h:437
constexpr VECTOR2< std::common_type_t< T, U > > operator-(const VECTOR2< T > &aLHS, const VECTOR2< U > &aRHS)
Definition vector2d.h:466
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type equals(VECTOR2< T > const &aFirst, VECTOR2< T > const &aSecond, T aEpsilon=std::numeric_limits< T >::epsilon())
Template to compare two VECTOR2<T> values for equality within a required epsilon.
Definition vector2d.h:662
constexpr const VECTOR2< T > & LexicographicalMin(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition vector2d.h:620
VECTOR2< int64_t > VECTOR2L
Definition vector2d.h:684
constexpr auto operator*(const VECTOR2< T > &aLHS, const VECTOR2< U > &aRHS)
Definition vector2d.h:502
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition vector2d.h:632