CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Member Functions | Public Attributes | List of all members
Vector2Tpl< Type > Class Template Reference

2D Vector More...

#include <CCGeom.h>

Inheritance diagram for Vector2Tpl< Type >:
Inheritance graph
[legend]

Public Member Functions

 Vector2Tpl (Type s=0)
 Default constructor. More...
 
 Vector2Tpl (Type _x, Type _y)
 Constructor from a couple of coordinates. More...
 
Type norm2 () const
 Returns vector square norm.
 
Type norm () const
 Returns vector norm.
 
void normalize ()
 Sets vector norm to unity.
 
Type dot (const Vector2Tpl &v) const
 Dot product.
 
Type cross (const Vector2Tpl &v) const
 Cross product. More...
 
Vector2Tploperator- ()
 Inverse operator.
 
Vector2Tploperator+= (const Vector2Tpl &v)
 In-place addition operator.
 
Vector2Tploperator-= (const Vector2Tpl &v)
 In-place subtraction operator.
 
Vector2Tploperator*= (Type v)
 In-place multiplication (by a scalar) operator.
 
Vector2Tploperator/= (Type v)
 In-place division (by a scalar) operator.
 
Vector2Tpl operator+ (const Vector2Tpl &v) const
 Addition operator.
 
Vector2Tpl operator- (const Vector2Tpl &v) const
 Subtraction operator.
 
Vector2Tpl operator* (Type s) const
 Multiplication operator.
 
Vector2Tpl operator/ (Type s) const
 Division operator.
 
Type & operator[] (unsigned i)
 Direct coordinate access.
 
const Type & operator[] (unsigned i) const
 Direct coordinate access (const)
 

Public Attributes

union {
   struct {
      Type   x
 
      Type   y
 
   } 
 
   Type   u [2]
 
}; 
 

Detailed Description

template<typename Type>
class Vector2Tpl< Type >

2D Vector

Constructor & Destructor Documentation

◆ Vector2Tpl() [1/2]

template<typename Type >
Vector2Tpl< Type >::Vector2Tpl ( Type  s = 0)
inlineexplicit

Default constructor.

Inits vector to (0,0).

Parameters
sdefault init value for both coordinates

◆ Vector2Tpl() [2/2]

template<typename Type >
Vector2Tpl< Type >::Vector2Tpl ( Type  _x,
Type  _y 
)
inline

Constructor from a couple of coordinates.

Inits vector to (x,y).

Parameters
_xx coordinate
_yy coordinate

Member Function Documentation

◆ cross()

template<typename Type >
Type Vector2Tpl< Type >::cross ( const Vector2Tpl< Type > &  v) const
inline

Cross product.

Returns
a positive value if (u,v) makes a counter-clockwise turn, negative for clockwise turn, and zero if the vectors are parallel

The documentation for this class was generated from the following file: