Public Member Functions | Static Public Member Functions | Public Attributes

Tiny2D::Vec2 Struct Reference

2 component vector of floats More...

#include <Tiny2D_Base.h>

List of all members.

Public Member Functions

 Vec2 (float x=0.0f, float y=0.0f)
 Constructs vector.
 Vec2 (const Vec2 &other)
 Copy consructor.
void operator= (const Vec2 &other)
 Copy operator.
void Set (float x, float y)
 Sets x and y components of the vector.
void operator= (float value)
 Assigns single value to both x and y components.
const float operator[] (int index) const
 Gets component at given index.
float & operator[] (int index)
 Gets reference to component at given index.
float Length () const
 Calculates length.
float LengthSqr () const
 Calculates squared length.
Vec2 operator+ (const Vec2 &other) const
 Adds 2 vectors.
void operator+= (const Vec2 &other)
 Adds another vector to itself.
Vec2 operator- () const
 Negates vector.
Vec2 operator- (const Vec2 &other) const
 Subtracts one vector from another.
void operator-= (const Vec2 &other)
 Subtracts vector from itself.
Vec2 operator* (float value) const
 Returns vector whole components are scaled by given scalar.
void operator*= (float value)
 Multiplies all vector components by scalar.
Vec2 operator* (const Vec2 &other) const
 Returns result of multiplication of this vector by other vector component-wise.
void operator*= (const Vec2 &other)
 Multiplies this vector by other vector component-wise.
Vec2 operator/ (float value) const
 Returns this vector divided component-wise by given scalar value.
void operator/= (float value)
 Divides all components of this vector by given scalar value.
Vec2 operator/ (const Vec2 &other) const
 Returns this vector divided component-wise by other vector.
void operator/= (const Vec2 &other)
 Divides all components of this vector by other vector.
float Normalize (float length=1.0f)
 Normalizes vector to given length (defaults to 1); returns previous length.
void Rotate (float angle, const Vec2 &origin=Vec2(0, 0))
 Rotates vector by given angle around given origin.

Static Public Member Functions

static float Dot (const Vec2 &a, const Vec2 &b)
 Calculates dot product of 2 vectors.
static Vec2 Lerp (const Vec2 &a, const Vec2 &b, float scale)
 Lerps between 2 vectors.

Public Attributes

float x
 X coordinate.
float y
 Y coordinate.

Detailed Description

2 component vector of floats


Constructor & Destructor Documentation

Tiny2D::Vec2::Vec2 ( float  x = 0.0f,
float  y = 0.0f 
) [inline]

Constructs vector.

Tiny2D::Vec2::Vec2 ( const Vec2 other ) [inline]

Copy consructor.


Member Function Documentation

static float Tiny2D::Vec2::Dot ( const Vec2 a,
const Vec2 b 
) [inline, static]

Calculates dot product of 2 vectors.

float Tiny2D::Vec2::Length (  ) const [inline]

Calculates length.

float Tiny2D::Vec2::LengthSqr (  ) const [inline]

Calculates squared length.

static Vec2 Tiny2D::Vec2::Lerp ( const Vec2 a,
const Vec2 b,
float  scale 
) [inline, static]

Lerps between 2 vectors.

float Tiny2D::Vec2::Normalize ( float  length = 1.0f ) [inline]

Normalizes vector to given length (defaults to 1); returns previous length.

Vec2 Tiny2D::Vec2::operator* ( float  value ) const [inline]

Returns vector whole components are scaled by given scalar.

Vec2 Tiny2D::Vec2::operator* ( const Vec2 other ) const [inline]

Returns result of multiplication of this vector by other vector component-wise.

void Tiny2D::Vec2::operator*= ( const Vec2 other ) [inline]

Multiplies this vector by other vector component-wise.

void Tiny2D::Vec2::operator*= ( float  value ) [inline]

Multiplies all vector components by scalar.

Vec2 Tiny2D::Vec2::operator+ ( const Vec2 other ) const [inline]

Adds 2 vectors.

void Tiny2D::Vec2::operator+= ( const Vec2 other ) [inline]

Adds another vector to itself.

Vec2 Tiny2D::Vec2::operator- (  ) const [inline]

Negates vector.

Vec2 Tiny2D::Vec2::operator- ( const Vec2 other ) const [inline]

Subtracts one vector from another.

void Tiny2D::Vec2::operator-= ( const Vec2 other ) [inline]

Subtracts vector from itself.

Vec2 Tiny2D::Vec2::operator/ ( float  value ) const [inline]

Returns this vector divided component-wise by given scalar value.

Vec2 Tiny2D::Vec2::operator/ ( const Vec2 other ) const [inline]

Returns this vector divided component-wise by other vector.

void Tiny2D::Vec2::operator/= ( const Vec2 other ) [inline]

Divides all components of this vector by other vector.

void Tiny2D::Vec2::operator/= ( float  value ) [inline]

Divides all components of this vector by given scalar value.

void Tiny2D::Vec2::operator= ( const Vec2 other ) [inline]

Copy operator.

void Tiny2D::Vec2::operator= ( float  value ) [inline]

Assigns single value to both x and y components.

const float Tiny2D::Vec2::operator[] ( int  index ) const [inline]

Gets component at given index.

float& Tiny2D::Vec2::operator[] ( int  index ) [inline]

Gets reference to component at given index.

void Tiny2D::Vec2::Rotate ( float  angle,
const Vec2 origin = Vec2(0, 0) 
) [inline]

Rotates vector by given angle around given origin.

void Tiny2D::Vec2::Set ( float  x,
float  y 
) [inline]

Sets x and y components of the vector.


Member Data Documentation

X coordinate.

Y coordinate.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines