Cytosim PI Cytoskeleton Simulator

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Friends
Vector2 Class Reference

## Detailed Description

Note: We assume that the coordinates XX and YY are adjacent in memory, which allows us to define an automatic conversion to a C-array. This is not guaranteed by the C-standard, but it usually works though...

## Public Member Functions
| Vector2 ()
| by default, coordinates are not initialized
| Vector2 (const real x, const real y)
| construct from values
| Vector2 (const real x, const real y, const real)
| construct from values
| Vector2 (const real v[])
| construct from address
| Vector2 (const real v[], const int &d)
| construct from array of size d
| ~Vector2 ()
| destructor (is not-virtual: do not derive from this class)
| operator real * ()
| implicit conversion to a modifiable real[] array
| operator const real * () const
| implicit conversion to a const real[] array
real * | addr ()
| conversion to a 'real array'
real & | operator[] (const unsigned ii)
| modifiable access to individual coordinates
void | get (const real b[])
| replace coordinates by the ones provided
void | get (const real v[], const int &d)
| copy coordinates from array of size d
void | put (real b[]) const
| copy coordinates to given array
void | addTo (real b[]) const
| add to given array
void | addFrom (real b[])
| change coordinates by adding given array
void | subTo (real b[]) const
| subtract to given array
void | subFrom (real b[])
| change coordinates by subtracting given array
void | set (const real x, const real y)
| change coordinates
void | set (const real x, const real y, const real)
| change coordinates
void | oppose ()
| change signs of all coordinates
real | normSqr () const
| the square of the standard norm
real | norm () const
| the standard norm = sqrt(x^2+y^2)
real | normXY () const
| the 2D norm = sqrt(x^2+y^2)
real | distanceSqr (Vector2 const &a) const
| square of the distance to other point == (a-this).normSqr()
real | distance (Vector2 const &a) const
| distance to other point == (a-this).norm()
real | minimum () const
| returns min(x, y, z)
real | maximum () const
| returns max(x, y, z)
real | norm_inf () const
| the infinite norm = max(|x|, |y|, |z|)
void | normalize (const real n=1.0)
| normalize to norm=n
const Vector2 | normalized (const real n=1.0) const
| returns the colinear vector of norm=n
const Vector2 | orthogonal () const
| returns a perpendicular vector, of comparable but unspecified norm
const Vector2 | orthogonal (const real n) const
| returns a perpendicular vector, of norm `n`
void | getEulerAngles (real &angle) const
| get the Euler angles
void | setFromEulerAngles (const real angle)
| set from Euler angles
const Vector2 | e_mul (const real b[]) const
| returns the element-by-element product
const Vector2 | e_div (const real b[]) const
| returns the element-by-element division
void | operator+= (Vector2 const &b)
| addition of another vector b
void | operator-= (Vector2 const &b)
| subtraction of another vector b
void | operator*= (const real b)
| multiplication by a scalar
void | operator/= (const real b)
| division by a scalar
std::string | str () const
| conversion to a string
void | print (FILE *out=stdout) const
| print to a file
void | pprint (FILE *out=stdout) const
| print to a file, surrounded by parenthesis
void | println (FILE *out=stdout) const
| print, followed by a new line
void | addRand (real s)
| add a random component in [-s, s] to each coordinate
const Vector2 | randPerp (real n) const
| a vector of norm `n`, orthogonal to *this, chosen randomly and uniformly

## Static Public Member Functions
static unsigned | dimensionality ()
| dimensionality
static Vector2 | make (const real b[])
| create new Vector with coordinates from the given array
static const Vector2 | randBox ()
| random Vector with coordinates set randomly and independently in [-1,+1]
static const Vector2 | randBox (real n)
| set all coordinates randomly and independently in [-n,+n]
static const Vector2 | randUnit ()
| random Vector of norm = 1; sampling is uniform
static const Vector2 | randUnit (real n)
| return a random vector of norm = n; sampling is uniform
static const Vector2 | randBall ()
| return a random vector of norm <= 1; sampling is uniform
static const Vector2 | randBall (real n)
| return a random vector of norm <= n; sampling is uniform
static const Vector2 | randGauss (real n)
| return a random vector with Normally distributed coordinates ~ N(0,n)

## Public Attributes
real | XX
| coordinates are public
real | YY

## Friends
const Vector2 | operator+ (Vector2 const &a, Vector2 const &b)
| addition of two vectors
const Vector2 | operator- (Vector2 const &a, Vector2 const &b)
| subtraction of two vectors
const Vector2 | operator+ (Vector2 const &b)
| unary + operator does nothing
const Vector2 | operator- (Vector2 const &b)
| opposition of a vector
real | vecProd (Vector2 const &a, Vector2 const &b)
| the cross product of two vectors is a Z-Vector More...
const Vector2 | vecProd (Vector2 const &a, const real b)
| cross product of a vector with a Z-Vector
const Vector2 | vecProd (const real a, Vector2 const &b)
| cross product of a Z-vector with a Vector
real | operator* (Vector2 const &a, Vector2 const &b)
| scalar product of two vectors
const Vector2 | operator* (Vector2 const &a, const real s)
| multiplication by scalar s
const Vector2 | operator* (const real s, Vector2 const &a)
| mutiplication by scalar s
const Vector2 | operator/ (Vector2 const &a, const real s)
| division by scalar s
bool | operator== (Vector2 const &a, Vector2 const &b)
| equality test
bool | operator!= (Vector2 const &a, Vector2 const &b)
| non-equality test

## Friends And Related Function Documentation

real vecProd | ( | Vector2 const & | a,
|  | Vector2 const & | b
| ) |  |
| friend

In dimension 2, we define a cross-product operator which returns a real, which in this case represents a Vector aligned with the Z axis. We also define the cross-product with a scalar, also corresponding to a Vector aligned with Z. This is a fair contraction of the 3D vector product.