VIGRA - Diff2D class Reference

[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| Diff2D Class Reference |
--- | --- | ---

Two dimensional difference vector. More...

`#include "vigra/diff2d.hxx"`

Inheritance diagram for Diff2D:

## Public Types
typedef Diff2D | PixelType
typedef Diff2D | value_type
typedef Diff2D const & | reference
typedef Diff2D | index_reference
typedef Diff2D const * | pointer
typedef Diff2D | difference_type
typedef image_traverser_tag | iterator_category
typedef IteratorAdaptor< Diff2DConstRowIteratorPolicy< Diff2D > > | row_iterator
typedef IteratorAdaptor< Diff2DConstColumnIteratorPolicy< Diff2D > > | column_iterator
typedef int | MoveX
typedef int | MoveY
## Public Methods
| Diff2D ()
| Diff2D (int ax, int ay)
| Diff2D (Diff2D const &v)
Diff2D & | operator= (Diff2D const &v)
Diff2D | operator- () const
Diff2D & | operator+= (Diff2D const &offset)
Diff2D & | operator-= (Diff2D const &offset)
Diff2D & | operator *= (int factor)
Diff2D & | operator *= (double factor)
Diff2D & | operator/= (int factor)
Diff2D & | operator/= (double factor)
Diff2D | operator * (int factor) const
Diff2D | operator * (double factor) const
Diff2D | operator/ (int factor) const
Diff2D | operator/ (double factor) const
int | squaredMagnitude () const
double | magnitude () const
bool | operator== (Diff2D const &r) const
bool | operator!= (Diff2D const &r) const
reference | operator * () const
index_reference | operator() (int const &dx, int const &dy) const
index_reference | operator[] (Diff2D const &offset) const
int | operator[] (int index) const
pointer | operator-> () const
row_iterator | rowIterator () const
column_iterator | columnIterator () const
## Public Attributes
int | x
int | y

## Detailed Description

Two dimensional difference vector.

This class acts primarily as a difference vector for specifying pixel coordinates and region sizes. In addition, Diff2D fulfills the requirements of an ImageIterator, so that it can be used to simulate an image whose pixels' values equal their coordinates. This secondary usage is explained on page CoordinateIterator.

Standard usage as a difference vector is mainly needed in the context of images. For example, Diff2D may be used as an index for `operator[]`:

        vigra::Diff2D location(...);

        value = image[location];

This is especially important in connection with accessors, where the offset variant of `operator()` takes only one offset object:

        // accessor(iterator, dx, dy); is not allowed
        value = accessor(iterator, vigra::Diff2D(dx, dy));

Diff2D is also returned by `image.size()`, so that we can create new images by calculating their size using Diff2D's arithmetic functions:

        // create an image that is 10 pixels smaller in each direction
        Image new_image(old_image.size() - Diff2D(10,10));

#include "vigra/utilities.hxx"
Namespace: vigra

Examples:

  profile.cxx, and subimage.cxx.

## Member Typedef Documentation

typedef IteratorAdaptor<Diff2DConstColumnIteratorPolicy<Diff2D> > column_iterator

| The associated column iterator.

typedef Diff2D difference_type

| the iterator's difference type (argument type of `iter[diff]`)

typedef Diff2D index_reference

| the iterator's index reference type (return type of `iter[diff]`) Reimplemented in Point2D.

typedef image_traverser_tag iterator_category

| the iterator tag (image traverser)

typedef int MoveX

| type of the iterator's x-navigator

typedef int MoveY

| type of the iterator's y-navigator

typedef Diff2D PixelType

| The iterator's value type: a coordinate. Reimplemented in Point2D.

typedef Diff2D const* pointer

| the iterator's pointer type (return type of `iter.operator->()`) Reimplemented in Point2D.

typedef Diff2D const& reference

| the iterator's reference type (return type of `*iter`) Reimplemented in Point2D.

typedef IteratorAdaptor<Diff2DConstRowIteratorPolicy<Diff2D> > row_iterator

| The associated row iterator.

typedef Diff2D value_type

| The iterator's value type: a coordinate. Reimplemented in Point2D.

## Constructor & Destructor Documentation

Diff2D | ( |  | ) | `[inline]`

| Default Constructor. Init iterator at position (0,0)

Diff2D | ( | int | ax,
|  | int | ay
| ) | `[inline]`

| Construct at given position.

Diff2D | ( | Diff2D const & | v | ) | `[inline]`

| Copy Constructor.

## Member Function Documentation

column_iterator columnIterator | ( |  | ) | const`[inline]`

| Get a column iterator at the current position.

double magnitude | ( |  | ) | const`[inline]`

| Calculate length of difference vector.

reference operator * | ( |  | ) | const`[inline]`

| Access current coordinate. Reimplemented in Point2D.

Diff2D operator * | ( | double | factor | ) | const`[inline]`

| Create vector by scaling by factor.

Diff2D operator * | ( | int | factor | ) | const`[inline]`

| Create vector by scaling by factor.

Diff2D& operator *= | ( | double | factor | ) | `[inline]`

| Create vector by scaling by factor.

Diff2D& operator *= | ( | int | factor | ) | `[inline]`

| Create vector by scaling by factor.

bool operator!= | ( | Diff2D const & | r | ) | const`[inline]`

| Inequality.

index_reference operator() | ( | int const & | dx,
|  | int const & | dy
| ) | const`[inline]`

| Read coordinate at an offset. Reimplemented in Point2D.

Diff2D& operator+= | ( | Diff2D const & | offset | ) | `[inline]`

| Increase coordinate by specified offset. Reimplemented in Size2D, and Point2D.

Diff2D operator- | ( |  | ) | const`[inline]`

| Unary negation. Reimplemented in Size2D, and Point2D.

Diff2D& operator-= | ( | Diff2D const & | offset | ) | `[inline]`

| Decrease coordinate by specified vector. Reimplemented in Size2D, and Point2D.

pointer operator-> | ( |  | ) | const`[inline]`

| Access current coordinate. Reimplemented in Point2D.

Diff2D operator/ | ( | double | factor | ) | const`[inline]`

| Create vector by scaling by 1/factor.

Diff2D operator/ | ( | int | factor | ) | const`[inline]`

| Create vector by scaling by 1/factor.

Diff2D& operator/= | ( | double | factor | ) | `[inline]`

| Create vector by scaling by 1/factor.

Diff2D& operator/= | ( | int | factor | ) | `[inline]`

| Create vector by scaling by 1/factor.

Diff2D& operator= | ( | Diff2D const & | v | ) | `[inline]`

| Copy Assigment. Reimplemented in Size2D, and Point2D.

bool operator== | ( | Diff2D const & | r | ) | const`[inline]`

| Equality.

int operator[] | ( | int | index | ) | const`[inline]`

| Read vector components.

index_reference operator[] | ( | Diff2D const & | offset | ) | const`[inline]`

| Read coordinate at an offset. Reimplemented in Point2D.

row_iterator rowIterator | ( |  | ) | const`[inline]`

| Get a row iterator at the current position.

int squaredMagnitude | ( |  | ) | const`[inline]`

| Calculate length of difference vector.

## Member Data Documentation

int x

| Used for both access to the current x-coordinate and to specify that an iterator navigation command is to be applied in x-direction. usage: `x = diff2d.x` (use `Diff2D::x` as component of difference vector) or `++diff.x` (use Diff2D as iterator, move right)

int y

| Used for both access to the current y-coordinate and to specify that an iterator navigation command is to be applied in y-direction. usage: `y = diff2d.y` (use `Diff2D::y` as component of difference vector) or `++diff.y` (use Diff2D as iterator, move right)

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

- vigra/diff2d.hxx

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.5.0 (7 Dec 2006)