liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
a_vector2 Struct Reference

instance structure for two-dimensional vector More...

#include <vector2.h>

Public Member Functions

void set (a_point2 const &p, a_point2 const &q)
 set a 2D vector as the difference from point p to point q.
a_real set_dir (a_real x_, a_real y_)
 set the components of a 2D vector and normalize it in place.
void val (a_real &x_, a_real &y_) const
 get the cartesian coordinates of a 2D vector.
void set_val (a_real x_, a_real y_)
 set the cartesian coordinates of a 2D vector.
void pol (a_real &rho, a_real &theta) const
 get the polar coordinates of a 2D vector.
void set_pol (a_real rho, a_real theta)
 set the polar coordinates of a 2D vector.
void add (a_vector2 const &rhs, a_vector2 &res) const
 add a 2D vector to a 2D vector.
void sub (a_vector2 const &rhs, a_vector2 &res) const
 subtract a 2D vector from a 2D vector.
void mul (a_real rhs, a_vector2 &res) const
 multiplie a 2D vector by a scalar.
void div (a_real rhs, a_vector2 &res) const
 divide a 2D vector by a scalar.
void neg (a_vector2 &res) const
 negate a 2D vector.
a_real unit ()
 normalize a 2D vector in-place to unit length.
a_real norm () const
 compute the magnitude of a 2D vector.
a_real norm2 () const
 compute the squared magnitude of a 2D vector.
a_real dot (a_vector2 const &rhs) const
 compute the dot product (scalar product) of two 2D vectors.
a_real dist (a_vector2 const &rhs) const
 compute the distance between two 2D vectors.
a_real dist2 (a_vector2 const &rhs) const
 compute the squared distance between two 2D vectors.
a_real angle (a_vector2 const &rhs) const
 compute the squared distance between two 2D vectors.
a_bool isver (a_vector2 const &rhs) const
 check if two 2D vectors are orthogonal.
a_bool ispar (a_vector2 const &rhs) const
 check if two 2D vectors are parallel or anti-parallel.
a_real cross (a_vector2 const &rhs) const
 compute the cross product (vector product) of two 2D vectors
void outer (a_vector2 const &rhs, a_real res[4]) const
 compute the outer product (tensor product) of two 2D vectors.
int proj (a_vector2 const &dir, a_vector2 &res) const
 project vector onto the direction of vector.
int perp (a_vector2 const &dir, a_vector2 &res) const
 project vector onto the line perpendicular to vector.
int refl (a_vector2 const &dir, a_vector2 &res) const
 reflect vector across the line with direction vector.
void rot (a_real angle, a_vector2 &res) const
 rotate a 2D vector by a specified angle (in radians).
void rot (a_real sin, a_real cos, a_vector2 &res) const
 rotate a 2D vector by a specified angle (in radians).

Data Fields

a_real x
a_real y

Friends

a_real operator^ (a_vector2 const &lhs, a_vector2 const &rhs)
 compute the cross product (vector product) of two 2D vectors
void operator+= (a_vector2 &lhs, a_vector2 const &rhs)
 add a 2D vector to a 2D vector.
a_vector2 operator+ (a_vector2 const &lhs, a_vector2 const &rhs)
 add a 2D vector to a 2D vector.
void operator-= (a_vector2 &lhs, a_vector2 const &rhs)
 subtract a 2D vector from a 2D vector.
a_vector2 operator- (a_vector2 const &lhs, a_vector2 const &rhs)
 subtract a 2D vector from a 2D vector.
a_real operator* (a_vector2 const &lhs, a_vector2 const &rhs)
 compute the dot product (scalar product) of two 2D vectors.
void operator*= (a_vector2 &lhs, a_real rhs)
 multiplie a 2D vector by a scalar.
a_vector2 operator* (a_real lhs, a_vector2 const &rhs)
 multiplie a 2D vector by a scalar.
a_vector2 operator* (a_vector2 const &lhs, a_real rhs)
 multiplie a 2D vector by a scalar.
void operator/= (a_vector2 &lhs, a_real rhs)
 divide a 2D vector by a scalar.
a_vector2 operator/ (a_vector2 const &lhs, a_real rhs)
 divide a 2D vector by a scalar.
a_vector2 operator+ (a_vector2 const &rhs)
a_vector2 operator- (a_vector2 const &rhs)
 negate a 2D vector.

Detailed Description

instance structure for two-dimensional vector

Member Function Documentation

◆ add()

void a_vector2::add ( a_vector2 const & rhs,
a_vector2 & res ) const
inline

add a 2D vector to a 2D vector.

See also
a_vector2_add

◆ angle()

a_real a_vector2::angle ( a_vector2 const & rhs) const
inline

compute the squared distance between two 2D vectors.

See also
a_vector2_dist2

◆ cross()

a_real a_vector2::cross ( a_vector2 const & rhs) const
inline

compute the cross product (vector product) of two 2D vectors

See also
a_vector2_cross

◆ dist()

a_real a_vector2::dist ( a_vector2 const & rhs) const
inline

compute the distance between two 2D vectors.

See also
a_vector2_dist

◆ dist2()

a_real a_vector2::dist2 ( a_vector2 const & rhs) const
inline

compute the squared distance between two 2D vectors.

See also
a_vector2_dist2

◆ div()

void a_vector2::div ( a_real rhs,
a_vector2 & res ) const
inline

divide a 2D vector by a scalar.

See also
a_vector2_div

◆ dot()

a_real a_vector2::dot ( a_vector2 const & rhs) const
inline

compute the dot product (scalar product) of two 2D vectors.

See also
a_vector2_dot

◆ ispar()

a_bool a_vector2::ispar ( a_vector2 const & rhs) const
inline

check if two 2D vectors are parallel or anti-parallel.

See also
a_vector2_ispar

◆ isver()

a_bool a_vector2::isver ( a_vector2 const & rhs) const
inline

check if two 2D vectors are orthogonal.

See also
a_vector2_isver

◆ mul()

void a_vector2::mul ( a_real rhs,
a_vector2 & res ) const
inline

multiplie a 2D vector by a scalar.

See also
a_vector2_mul

◆ neg()

void a_vector2::neg ( a_vector2 & res) const
inline

negate a 2D vector.

See also
a_vector2_neg

◆ norm()

a_real a_vector2::norm ( ) const
inline

compute the magnitude of a 2D vector.

See also
a_vector2_norm

◆ norm2()

a_real a_vector2::norm2 ( ) const
inline

compute the squared magnitude of a 2D vector.

See also
a_vector2_norm2

◆ outer()

void a_vector2::outer ( a_vector2 const & rhs,
a_real res[4] ) const
inline

compute the outer product (tensor product) of two 2D vectors.

See also
a_vector2_outer

◆ perp()

int a_vector2::perp ( a_vector2 const & dir,
a_vector2 & res ) const
inline

project vector onto the line perpendicular to vector.

See also
a_vector2_perp

◆ pol()

void a_vector2::pol ( a_real & rho,
a_real & theta ) const
inline

get the polar coordinates of a 2D vector.

See also
a_vector2_pol

◆ proj()

int a_vector2::proj ( a_vector2 const & dir,
a_vector2 & res ) const
inline

project vector onto the direction of vector.

See also
a_vector2_proj

◆ refl()

int a_vector2::refl ( a_vector2 const & dir,
a_vector2 & res ) const
inline

reflect vector across the line with direction vector.

See also
a_vector2_refl

◆ rot() [1/2]

void a_vector2::rot ( a_real angle,
a_vector2 & res ) const
inline

rotate a 2D vector by a specified angle (in radians).

See also
a_vector2_rot

◆ rot() [2/2]

void a_vector2::rot ( a_real sin,
a_real cos,
a_vector2 & res ) const
inline

rotate a 2D vector by a specified angle (in radians).

See also
a_vector2_rot_

◆ set_dir()

a_real a_vector2::set_dir ( a_real x_,
a_real y_ )
inline

set the components of a 2D vector and normalize it in place.

See also
a_vector2_set_dir

◆ set_pol()

void a_vector2::set_pol ( a_real rho,
a_real theta )
inline

set the polar coordinates of a 2D vector.

See also
a_vector2_set_pol

◆ set_val()

void a_vector2::set_val ( a_real x_,
a_real y_ )
inline

set the cartesian coordinates of a 2D vector.

See also
a_vector2_set_val

◆ sub()

void a_vector2::sub ( a_vector2 const & rhs,
a_vector2 & res ) const
inline

subtract a 2D vector from a 2D vector.

See also
a_vector2_sub

◆ unit()

a_real a_vector2::unit ( )
inline

normalize a 2D vector in-place to unit length.

See also
a_vector2_unit

◆ val()

void a_vector2::val ( a_real & x_,
a_real & y_ ) const
inline

get the cartesian coordinates of a 2D vector.

See also
a_vector2_val

◆ operator* [1/3]

a_vector2 operator* ( a_real lhs,
a_vector2 const & rhs )
friend

multiplie a 2D vector by a scalar.

See also
a_vector2_mul

◆ operator* [2/3]

a_vector2 operator* ( a_vector2 const & lhs,
a_real rhs )
friend

multiplie a 2D vector by a scalar.

See also
a_vector2_mul

◆ operator* [3/3]

a_real operator* ( a_vector2 const & lhs,
a_vector2 const & rhs )
friend

compute the dot product (scalar product) of two 2D vectors.

See also
a_vector2_dot

◆ operator*=

void operator*= ( a_vector2 & lhs,
a_real rhs )
friend

multiplie a 2D vector by a scalar.

See also
a_vector2_mul

◆ operator+

a_vector2 operator+ ( a_vector2 const & lhs,
a_vector2 const & rhs )
friend

add a 2D vector to a 2D vector.

See also
a_vector2_add

◆ operator+=

void operator+= ( a_vector2 & lhs,
a_vector2 const & rhs )
friend

add a 2D vector to a 2D vector.

See also
a_vector2_add

◆ operator- [1/2]

a_vector2 operator- ( a_vector2 const & lhs,
a_vector2 const & rhs )
friend

subtract a 2D vector from a 2D vector.

See also
a_vector2_sub

◆ operator- [2/2]

a_vector2 operator- ( a_vector2 const & rhs)
friend

negate a 2D vector.

See also
a_vector2_neg

◆ operator-=

void operator-= ( a_vector2 & lhs,
a_vector2 const & rhs )
friend

subtract a 2D vector from a 2D vector.

See also
a_vector2_sub

◆ operator/

a_vector2 operator/ ( a_vector2 const & lhs,
a_real rhs )
friend

divide a 2D vector by a scalar.

See also
a_vector2_div

◆ operator/=

void operator/= ( a_vector2 & lhs,
a_real rhs )
friend

divide a 2D vector by a scalar.

See also
a_vector2_div

◆ operator^

a_real operator^ ( a_vector2 const & lhs,
a_vector2 const & rhs )
friend

compute the cross product (vector product) of two 2D vectors

See also
a_vector2_cross

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