Vector2dF

Two dimensions vector.

Header#include "nativeui/gfx/geometry/vector2d_f.h"
Namespacenamespace nu
Typeclass

This class is used to indicate a distance in two dimensions between two points. Subtracting two points should produce a vector, and adding a vector to a point produces the point at the vector's distance from the original point.

nu::PointF view_point(100, 100);
nu::PointF window_point = view_point + view->OffsetFromWindow();
window_point == nu::PointF(200, 200);

Constructors

Vector2dF()

Create an empty vector.

Vector2dF(float x, float y)

Create a vector with dimensions of x and y.

Parameters

Methods

float x() const

Return X component.

Return

float

void set_x(float x)

Set X component.

Parameters

float y() const

Return Y component.

Return

float

void set_y(float y)

Set Y component.

Parameters

bool IsZero() const

Return whether the vector is empty.

Return

bool

void Add(const Vector2dF& other)

Add the components of the other vector to the current vector.

Parameters

void Subtract(const Vector2dF& other)

Subtract the components of the other vector from the current vector.

Parameters

float Length() const

Return the diagonal length of the vector.

Return

float

void Scale(float scale)

Scale the x and y components of the vector by scale|.

Parameters

std::string ToString() const;

Return string representation of the vector.

Return

std::string