Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
jm::Vertex2 Class Reference

A two dimensional vector. Owns special functions for 2d space. More...

Public Member Functions

 Vertex2 () noexcept=default
 Constructor creates null vector.
 
 Vertex2 (double x, double y) noexcept
 Constructor creates arbitrary vector.
 
 Vertex2 (const Vertex3 &v3) noexcept
 Copy constructor.
 
double abs () const
 This method returns the absolute value of the vector. The absolute value is equal to the length.
 
Vertex2normalize ()
 This method normalizes the vector. A normalized vector has the length 1.
 
Vertex2 normalized () const
 This method returns a normalized vector with the length 1.
 
double crossProduct (const Vertex2 &another) const
 Returns the cross product of this vector multiplied by another.
 
double dotProduct (const Vertex2 &another) const
 Returns the scalar product of this vector with another.
 
bool isCollinear (const Vertex2 &another) const
 This method calculates whether the two vectors are collinear. In other words, whether both vectors are parallel.
 
bool isOrthogonal (const Vertex2 &another) const
 This method calculates whether the two vectors are orthogonal. In other words, whether they are perpendicular to each other.
 
double angleTo (const Vertex2 &another) const
 Returns the signed angle between this vector and another vector.
 
bool isRightTo (const Vertex2 &another) const
 This method calculates whether this vector is "to the right", i.e. clockwise next to the other vector.
 
bool isLeftTo (const Vertex2 &another) const
 This method calculates whether this vector is "left", i.e. counterclockwise, next to the other vector.
 
bool isValid () const
 This method returns true if the vector is defined, i.e. if the numbers are not NAN "Not-a-number".
 
Vertex2rotate (double angle)
 This method rotates the vector around the Z-axis with the specified angle.
 
Vertex2 rotated (double angle) const
 This method returns a rotated vector around the Z-axis with the specified angle.
 
Vertex2 scale (const Vertex2 &another) const
 This method multiplies this vector line by line with the other vector.
 
Vertex2operator+= (const Vertex2 &another)
 
Vertex2operator-= (const Vertex2 &another)
 
Vertex2 operator/ (double b) const
 Implementation of the operator /.
 

Public Attributes

double x = 0.0
 X component of vector.
 
double y = 0.0
 Y component of vector.
 

Friends

DllExport friend std::ostream & operator<< (std::ostream &out, const Vertex2 &vertex)
 

Detailed Description

A two dimensional vector. Owns special functions for 2d space.

Constructor & Destructor Documentation

◆ Vertex2() [1/3]

jm::Vertex2::Vertex2 ( )
defaultnoexcept

Constructor creates null vector.

◆ Vertex2() [2/3]

jm::Vertex2::Vertex2 ( double  x,
double  y 
)
noexcept

Constructor creates arbitrary vector.

Parameters
xX-component of the vector
yy-component of the vector

◆ Vertex2() [3/3]

jm::Vertex2::Vertex2 ( const Vertex3 v3)
explicitnoexcept

Copy constructor.

Parameters
v3The other 3d-vector. The z-component is ignored.

Member Function Documentation

◆ abs()

double jm::Vertex2::abs ( ) const

This method returns the absolute value of the vector. The absolute value is equal to the length.

◆ angleTo()

double jm::Vertex2::angleTo ( const Vertex2 another) const

Returns the signed angle between this vector and another vector.

Note
This method uses as positive direction the clockwise direction with right x-axis as 0° like in SVG.
Parameters
anotherThe vector we want to know the angle to.
Returns
Angle in radians.

◆ crossProduct()

double jm::Vertex2::crossProduct ( const Vertex2 another) const

Returns the cross product of this vector multiplied by another.

Parameters
anotherthe other vector.
Returns
Returns the result of: this × another

◆ dotProduct()

double jm::Vertex2::dotProduct ( const Vertex2 another) const

Returns the scalar product of this vector with another.

Parameters
anotherthe other vector.
Returns
Returns the result of: this dot another

◆ isCollinear()

bool jm::Vertex2::isCollinear ( const Vertex2 another) const

This method calculates whether the two vectors are collinear. In other words, whether both vectors are parallel.

◆ isLeftTo()

bool jm::Vertex2::isLeftTo ( const Vertex2 another) const

This method calculates whether this vector is "left", i.e. counterclockwise, next to the other vector.

◆ isOrthogonal()

bool jm::Vertex2::isOrthogonal ( const Vertex2 another) const

This method calculates whether the two vectors are orthogonal. In other words, whether they are perpendicular to each other.

◆ isRightTo()

bool jm::Vertex2::isRightTo ( const Vertex2 another) const

This method calculates whether this vector is "to the right", i.e. clockwise next to the other vector.

◆ isValid()

bool jm::Vertex2::isValid ( ) const

This method returns true if the vector is defined, i.e. if the numbers are not NAN "Not-a-number".

◆ normalize()

Vertex2 & jm::Vertex2::normalize ( )

This method normalizes the vector. A normalized vector has the length 1.

Note
If this vector has the length (nearly) 0, it is returned unchanged.

◆ normalized()

Vertex2 jm::Vertex2::normalized ( ) const

This method returns a normalized vector with the length 1.

Note
If this vector has the length (nearly) 0, it is returned unchanged.

◆ operator+=()

Vertex2 & jm::Vertex2::operator+= ( const Vertex2 another)

◆ operator-=()

Vertex2 & jm::Vertex2::operator-= ( const Vertex2 another)

◆ operator/()

Vertex2 jm::Vertex2::operator/ ( double  b) const

Implementation of the operator /.

◆ rotate()

Vertex2 & jm::Vertex2::rotate ( double  angle)

This method rotates the vector around the Z-axis with the specified angle.

Parameters
angleThe angle of rotation in the mathematical positive sense in radians.

◆ rotated()

Vertex2 jm::Vertex2::rotated ( double  angle) const

This method returns a rotated vector around the Z-axis with the specified angle.

Parameters
angleThe angle of rotation in the mathematical positive sense in radians.

◆ scale()

Vertex2 jm::Vertex2::scale ( const Vertex2 another) const

This method multiplies this vector line by line with the other vector.

Returns
Returns the result of the calculation. This vector remains unchanged.

Friends And Related Symbol Documentation

◆ operator<<

DllExport friend std::ostream & operator<< ( std::ostream &  out,
const Vertex2 vertex 
)
friend

Member Data Documentation

◆ x

double jm::Vertex2::x = 0.0

X component of vector.

Note
We need fast access to this value and other protection measures are not necessary. So we leave it public.

◆ y

double jm::Vertex2::y = 0.0

Y component of vector.

Note
We need fast access to this value and other protection measures are not necessary. So we leave it public.