Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
gfx::Vector2d Class Reference

#include <vector2d.h>

Public Member Functions

constexpr Vector2d ()
 
constexpr Vector2d (int x, int y)
 
constexpr int x () const
 
void set_x (int x)
 
constexpr int y () const
 
void set_y (int y)
 
bool IsZero () const
 
void Add (const Vector2d &other)
 
void Subtract (const Vector2d &other)
 
constexpr bool operator== (const Vector2d &other) const
 
void operator+= (const Vector2d &other)
 
void operator-= (const Vector2d &other)
 
void SetToMin (const Vector2d &other)
 
void SetToMax (const Vector2d &other)
 
int64_t LengthSquared () const
 
float Length () const
 
std::string ToString () const
 
 operator Vector2dF () const
 

Detailed Description

Definition at line 22 of file vector2d.h.

Constructor & Destructor Documentation

◆ Vector2d() [1/2]

constexpr gfx::Vector2d::Vector2d ( )
inlineconstexpr

Definition at line 24 of file vector2d.h.

24: x_(0), y_(0) {}

◆ Vector2d() [2/2]

constexpr gfx::Vector2d::Vector2d ( int  x,
int  y 
)
inlineconstexpr

Definition at line 25 of file vector2d.h.

25: x_(x), y_(y) {}
constexpr int x() const
Definition: vector2d.h:27
constexpr int y() const
Definition: vector2d.h:30

Member Function Documentation

◆ Add()

void gfx::Vector2d::Add ( const Vector2d other)

Definition at line 18 of file vector2d.cc.

18 {
19 x_ = base::ClampAdd(other.x_, x_);
20 y_ = base::ClampAdd(other.y_, y_);
21}

◆ IsZero()

bool gfx::Vector2d::IsZero ( ) const

Definition at line 14 of file vector2d.cc.

14 {
15 return x_ == 0 && y_ == 0;
16}

◆ Length()

float gfx::Vector2d::Length ( ) const

Definition at line 32 of file vector2d.cc.

32 {
33 return static_cast<float>(std::sqrt(static_cast<double>(LengthSquared())));
34}
int64_t LengthSquared() const
Definition: vector2d.cc:28
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706

◆ LengthSquared()

int64_t gfx::Vector2d::LengthSquared ( ) const

Definition at line 28 of file vector2d.cc.

28 {
29 return static_cast<int64_t>(x_) * x_ + static_cast<int64_t>(y_) * y_;
30}

◆ operator Vector2dF()

gfx::Vector2d::operator Vector2dF ( ) const
inline

Definition at line 66 of file vector2d.h.

66 {
67 return Vector2dF(static_cast<float>(x()), static_cast<float>(y()));
68 }

◆ operator+=()

void gfx::Vector2d::operator+= ( const Vector2d other)
inline

Definition at line 44 of file vector2d.h.

44{ Add(other); }
void Add(const Vector2d &other)
Definition: vector2d.cc:18

◆ operator-=()

void gfx::Vector2d::operator-= ( const Vector2d other)
inline

Definition at line 45 of file vector2d.h.

45{ Subtract(other); }
void Subtract(const Vector2d &other)
Definition: vector2d.cc:23

◆ operator==()

constexpr bool gfx::Vector2d::operator== ( const Vector2d other) const
inlineconstexpr

Definition at line 41 of file vector2d.h.

41 {
42 return x_ == other.x_ && y_ == other.y_;
43 }

◆ set_x()

void gfx::Vector2d::set_x ( int  x)
inline

Definition at line 28 of file vector2d.h.

28{ x_ = x; }

◆ set_y()

void gfx::Vector2d::set_y ( int  y)
inline

Definition at line 31 of file vector2d.h.

31{ y_ = y; }

◆ SetToMax()

void gfx::Vector2d::SetToMax ( const Vector2d other)
inline

Definition at line 52 of file vector2d.h.

52 {
53 x_ = x_ >= other.x_ ? x_ : other.x_;
54 y_ = y_ >= other.y_ ? y_ : other.y_;
55 }

◆ SetToMin()

void gfx::Vector2d::SetToMin ( const Vector2d other)
inline

Definition at line 47 of file vector2d.h.

47 {
48 x_ = x_ <= other.x_ ? x_ : other.x_;
49 y_ = y_ <= other.y_ ? y_ : other.y_;
50 }

◆ Subtract()

void gfx::Vector2d::Subtract ( const Vector2d other)

Definition at line 23 of file vector2d.cc.

23 {
24 x_ = base::ClampSub(x_, other.x_);
25 y_ = base::ClampSub(y_, other.y_);
26}

◆ ToString()

std::string gfx::Vector2d::ToString ( ) const

Definition at line 36 of file vector2d.cc.

36 {
37 return base::StringPrintf("[%d %d]", x_, y_);
38}
std::string StringPrintf(const std::string &format, Args... args)
Definition: string_utils.h:18

◆ x()

constexpr int gfx::Vector2d::x ( ) const
inlineconstexpr

Definition at line 27 of file vector2d.h.

27{ return x_; }

◆ y()

constexpr int gfx::Vector2d::y ( ) const
inlineconstexpr

Definition at line 30 of file vector2d.h.

30{ return y_; }

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