gtkmm 4.23.2
Gdk::Graphene::Vec2 Class Reference

A vector with two dimensions, x and y. More...

#include <gdkmm/graphene_vec2.h>

Public Member Functions

 Vec2 ()
 Vec2 (float x, float y)
 Vec2 (const Point & src)
 Vec2 (const graphene_vec2_t * vec2)
std::array< float, 2 > to_float () const
 Stores the components of this vector into an array.
Vec2 add (const Vec2 & other) const
 Adds each component of two vectors.
Vec2 subtract (const Vec2 & other) const
 Subtracts each component of the other vector from this vector.
float dot (const Vec2 & other) const
 Computes the dot product of the two given vectors.
float length () const
 Computes the length of the given vector.
Vec2 normalize () const
 Computes the normalized vector for the given vector.
Vec2 scale (float factor) const
 Multiplies all components of this vector with the given scalar factor.
Vec2 negate () const
 Negates this vector.
bool near (const Vec2 & other, float epsilon) const
 Compares the two given graphene_vec2_t vectors and checks whether their values are within the given epsilon.
bool equal (const Vec2 & other) const
 Checks whether the two given graphene_vec2_t are equal.
Vec2 interpolate (const Vec2 & other, double factor) const
 Linearly interpolates this vector and other using the given factor.
float get_x () const
 Retrieves the X component of the graphene_vec2_t.
float get_y () const
 Retrieves the Y component of the graphene_vec2_t.
graphene_vec2_t * gobj ()
 Provides access to the underlying C GObject.
const graphene_vec2_t * gobj () const
 Provides access to the underlying C GObject.

Protected Attributes

graphene_vec2_t gobject_

Detailed Description

A vector with two dimensions, x and y.

Since gtkmm 4.24

Constructor & Destructor Documentation

◆ Vec2() [1/4]

Gdk::Graphene::Vec2::Vec2 ( )

◆ Vec2() [2/4]

Gdk::Graphene::Vec2::Vec2 ( float x,
float y )

◆ Vec2() [3/4]

Gdk::Graphene::Vec2::Vec2 ( const Point & src)
explicit

◆ Vec2() [4/4]

Gdk::Graphene::Vec2::Vec2 ( const graphene_vec2_t * vec2)
explicit

Member Function Documentation

◆ add()

Vec2 Gdk::Graphene::Vec2::add ( const Vec2 & other) const

Adds each component of two vectors.

Since gtkmm 4.24
Parameters
otherA vector to add to this vector.
Returns
The sum of this vector and the other vector.

◆ dot()

float Gdk::Graphene::Vec2::dot ( const Vec2 & other) const

Computes the dot product of the two given vectors.

Since gtkmm 4.24
Parameters
otherA graphene_vec2_t.
Returns
The dot product of the vectors.

◆ equal()

bool Gdk::Graphene::Vec2::equal ( const Vec2 & other) const

Checks whether the two given graphene_vec2_t are equal.

Since gtkmm 4.24
Parameters
otherA graphene_vec2_t.
Returns
true if the two vectors are equal, and false otherwise.

◆ get_x()

float Gdk::Graphene::Vec2::get_x ( ) const

Retrieves the X component of the graphene_vec2_t.

Since gtkmm 4.24
Returns
The value of the X component.

◆ get_y()

float Gdk::Graphene::Vec2::get_y ( ) const

Retrieves the Y component of the graphene_vec2_t.

Since gtkmm 4.24
Returns
The value of the Y component.

◆ gobj() [1/2]

graphene_vec2_t * Gdk::Graphene::Vec2::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const graphene_vec2_t * Gdk::Graphene::Vec2::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ interpolate()

Vec2 Gdk::Graphene::Vec2::interpolate ( const Vec2 & other,
double factor ) const

Linearly interpolates this vector and other using the given factor.

Since gtkmm 4.24
Parameters
otherThe other vector.
factorThe interpolation factor.
Returns
The interpolated vector.

◆ length()

float Gdk::Graphene::Vec2::length ( ) const

Computes the length of the given vector.

Since gtkmm 4.24
Returns
The length of the vector.

◆ near()

bool Gdk::Graphene::Vec2::near ( const Vec2 & other,
float epsilon ) const

Compares the two given graphene_vec2_t vectors and checks whether their values are within the given epsilon.

Since gtkmm 4.24
Parameters
otherA graphene_vec2_t.
epsilonThe threshold between the two vectors.
Returns
true if the two vectors are near each other.

◆ negate()

Vec2 Gdk::Graphene::Vec2::negate ( ) const

Negates this vector.

Since gtkmm 4.24
Returns
The negated vector.

◆ normalize()

Vec2 Gdk::Graphene::Vec2::normalize ( ) const

Computes the normalized vector for the given vector.

Since gtkmm 4.24
Returns
The normalized vector.

◆ scale()

Vec2 Gdk::Graphene::Vec2::scale ( float factor) const

Multiplies all components of this vector with the given scalar factor.

Since gtkmm 4.24
Parameters
factorThe scalar factor.
Returns
The scaled vector.

◆ subtract()

Vec2 Gdk::Graphene::Vec2::subtract ( const Vec2 & other) const

Subtracts each component of the other vector from this vector.

Since gtkmm 4.24
Parameters
otherA vector to subtract from this vector.
Returns
The difference between this vector and the other vector.

◆ to_float()

std::array< float, 2 > Gdk::Graphene::Vec2::to_float ( ) const

Stores the components of this vector into an array.

Since gtkmm 4.24
Returns
An array of floating point values with 2 elements.

Member Data Documentation

◆ gobject_

graphene_vec2_t Gdk::Graphene::Vec2::gobject_
protected