Boost Polygon Library: Isotropy

### Contents Boost.Polygon Main Page Design Overview Isotropy Coordinate Concept Interval Concept Point Concept Segment Concept Rectangle Concept Polygon 90 Concept Polygon 90 With Holes Concept Polygon 45 Concept Polygon 45 With Holes Concept Polygon Concept Polygon With Holes Concept Polygon 90 Set Concept Polygon 45 Set Concept Polygon Set Concept Connectivity Extraction 90 Connectivity Extraction 45 Connectivity Extraction Property Merge 90 Property Merge 45 Property Merge Voronoi Main Page Voronoi Benchmark Voronoi Builder Voronoi Diagram ### Other Resources GTL Boostcon 2009 Paper GTL Boostcon 2009 Presentation Performance Analysis Layout Versus Schematic Tutorial Minkowski Sum Tutorial Voronoi Basic Tutorial Voronoi Advanced Tutorial ### Polygon Sponsor | # Isotropy What is isotropy? Isotropy - Function: adjective Etymology: International Scientific Vocabulary : exhibiting properties (as velocity of light transmission) with the same values when measured along axes in all directions <an isotropic crystal> In computational geometry things are often symmetric and invariant to direction and orientation. This invariance to direction is called isotropy. In such situations it is convenient to parameterize direction or orientation and write code that is invariant to the direction or orientation in which it is applied. To do this effectively we provide an internally consistent set of isotropic data types to represent program data that describes orientations and directions. These data types are: direction_1d - has one of the following 2 states: LOW, HIGH orientation_2d - has one of the following 2 states: HORIZONTAL, VERTICAL direction_2d - has one of the following 4 states: WEST, EAST, SOUTH, NORTH orientation_3d - has one of the following 3 states: HORIZONTAL, VERTICAL, PROXIMAL direction_3d - has one of the following 6 states: WEST, EAST, SOUTH, NORTH, DOWN, UP The isotropic types create a system and interact with each other in various ways, such as casting. Together they create a language for describing isotropic situations programmatically. For instance, to get the positive direction_2d from an orientation_2d you would call a member function of orientation_2d and pass a direction_1d: orientation_2d orient = HORIZONTAL; direction_2d dir = orient.get_direction(direction_1d(HIGH)); assert(dir == EAST); The motivation for providing isotropic data types is to encourage programming at a higher level of abstraction where program behavior is controlled by program data passed into function calls rather than flow control syntax. Isotropic programming style is particularly applicable to working with points, intervals and rectangles. Often times the implementation of such logic is identical when implemented for the x or y coordinates, except that the names of functions and data members are changed in a mechanical way leading to code duplication and bloat that results in copy-paste programming errors and maintenance problems where changes made to a given code block relating to x coordiantes are not duplicated to the code block that refers to y. Isotropy therefore represents an opportunity to refactor and improve the quality of low level geometry code especially in regard to inter-relating coordinates, points, intervals and rectangles. ## direction_1d The direction_1d data type has two possible states. These are the positive and negative directions on a continuum such as the number line. These states can be described by one of several direction_1d_enum values: We make clockwise and counterclockwise winding orientation of polygons a direction 1d value instead of providing a separate winding_orientation data type. This is because winding orientation can be thought of as positive and negative directions in a 1d (although cyclic) space. We assign counterclockwise to be the positive direction of travel in the 1d cyclic space to conform with the mathematical convention frequently described as the "right hand rule" which assigns positive normal value to counterclockwise and negative normal value to clockwise as well as the common convention that counterclockwise polygon winding corresponds to positive polygonal regions where as clockwise polygon winding corresponds to hole (negative) polygonal regions. enum direction_1d_enum {LOW = 0, HIGH = 1, LEFT = 0, RIGHT = 1, CLOCKWISE = 0, COUNTERCLOCKWISE = 1, REVERSE = 0, FORWARD = 1, NEGATIVE = 0, POSITIVE = 1 }; ## Member Functions
direction_1d(direction_1d_enum val = LOW) | Constructor defaults to LOW.
direction_1d(const direction_1d& that) | Copy construct.
direction_1d(const direction_2d& that) | Down cast direction_2d, extracting out whether positive or negative
direction_1d(const direction_3d& that) | Down cast direction_3d, extracting out whether positive or negative
direction_1d& operator=(const direction_1d dir) | Assignment
direction_1d& operator==(const direction_1d dir) const | Equivalence
direction_1d& operator!=(const direction_1d dir) const | Inequivalence
unsigned int to_int() const | Convert to the integer enum value of current state to use as index. Auto-cast to int is disallowed for type safety reasons.
direction_1d& backward() | Inverts direction.
int get_sign() const | Returns positive 1 if positive direction and negative one if negative direction.
## orientation_2d The orientation_2d data type has two possible states. These are the horizontal and vertical axis of a 2d Cartesian coordinate system. These states can be described by one of the two orientation_2d_enum values: enum orientation_2d_enum { HORIZONTAL = 0, VERTICAL = 1 }; ## Member Functions
orientation_2d(orientation_2d_enum val = HORIZONTAL) | Constructor defaults to HORIZONTAL.
orientation_2d(const orientation_2d& that) | Copy construct.
explicit orientation_2d(const direction_2d& that) | Down cast direction_2d, extracting out whether horizontal or vertical direction type
orientation_2d& operator=(const orientation_2d o) | Assignment
orientation_2d& operator==(const orientation_2d o) const | Equivalence
orientation_2d& operator!=(const orientation_2d o) const | Inequivalence
unsigned int to_int() const | Convert to the integer enum value of current state to use as index. Auto-cast to int is disallowed for type safety reasons
orientation_2d& turn_90() | Change to orthogonal orientation
int get_perpendicular() const | Returns orthogonal orientation
int get_direction(direction_1d dir) const | Returns the positive or negative direction_2d depending on the value of dir
## direction_2d The direction_2d data type has four possible states. These are the cardinal directions of the 2D Cartesian coordinate system. These states can be described by one of several direction_2d_enum values: enum direction_2d_enum { WEST = 0, EAST = 1, SOUTH = 2, NORTH = 3 }; ## Member Functions
direction_2d(direction_2d_enum val = WEST) | Constructor defaults to WEST.
direction_2d(const direction_2d& that) | Copy construct.
direction_1d& operator=(const direction_2d dir) | Assignment
direction_1d& operator==(const direction_2d dir) const | Equivalence
direction_1d& operator!=(const direction_2d dir) const | Inequivalence
unsigned int to_int() const | Convert to the integer enum value of current state to use as index. Auto-cast to int is disallowed for type safety reasons.
direction_2d& backward() | Inverts direction.
direction_2d& turn(direction_1d dir) | Changes to direction_2d to the left if dir is LOW, to the right if dir is HIGH
direction_2d& left() | Changes to the direction_2d to the left
direction_2d& right() | Changes to the direction_2d to the right
int is_positive() const | Returns true if EAST or NORTH
int is_negative() const | Returns true if WEST or SOUTH
int get_sign() const | Returns positive 1 if positive direction and negative one if negative direction.
## orientation_3d The orientation_3d data type has three possible states. These are the horizontal, vertical and proximal (x, y, z) axis of a 3d Cartesian coordinate system. These states can be described by one of the orientation_2d_enum values or by the orientation_3d_enum value: enum orientation_3d_enum { PROXIMAL = 2 }; ## Member Functions
orientation_3d(orientation_2d_enum val = HORIZONTAL) | Constructor defaults to HORIZONTAL.
orientation_3d(const orientation_3d& that) | Copy construct.
explicit orientation_3d(const direction_2d& that) | Extract out the orientation of the direction
explicit orientation_3d(const direction_3d& that) | Extract out the orientation of the direction
orientation_3d(const orientation_2d& that) | Up cast orientation_2d to orientation_3d.
orientation_3d(const orientation_3d_enum& that) | Construct from constant value
orientation_3d& operator=(const orientation_3d o) | Assignment
orientation_3d& operator==(const orientation_3d o) const | Equivalence
orientation_3d& operator!=(const orientation_3d o) const | Inequivalence
unsigned int to_int() const | Convert to the integer enum value of current state to use as index. Auto-cast to int is disallowed for type safety reasons
int get_direction(direction_1d dir) const | Returns the positive or negative direction_2d depending on the value of dir
## direction_3d The direction_3d data type has six possible states. These are the cardinal directions of the 3D Cartesian coordinate system. These states can be described by one of the direction_2d_enum values or the direction_3d_enum values: enum direction_3d_enum { DOWN = 4, UP = 5 }; ## Member Functions
direction_3d(direction_2d_enum val = WEST) | Constructor defaults to LOW.
direction_3d(direction_3d_enum that) | Construct from constant value
direction_3d(const direction_3d& that) | Copy construct
direction_3d(direction_2d that) | Up cast direction_2d to direction_3d
direction_3d& operator=(const direction_3d dir) | Assignment
direction_3d& operator==(const direction_3d dir) const | Equivalence
direction_2d& operator!=(const direction_3d dir) const | Inequivalence
unsigned int to_int() const | Convert to the integer enum value of current state to use as index. Auto-cast to int is disallowed for type safety reasons.
direction_1d& backward() | Inverts direction.
int is_positive() const | Returns true if direction is EAST, NORTH or UP.
int is_negative() const | Returns true if direction is WEST, SOUTH or DOWN
int get_sign() const | Returns positive 1 if positive direction and negative one if negative direction.
Copyright: | Copyright © Intel Corporation 2008-2010.
License: | Distributed under the Boost Software License, Version 1.0. (See accompanying file `LICENSE_1_0.txt` or copy at http://www.boost.org/LICENSE_1_0.txt)