Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
DRange2d Struct Reference

A 2d low and high corner pair for range boxes. More...

#include <drange2d.h>

Public Member Functions

void Init ()
 Initializes a range cube with (inverted) large positive and negative values. More...
 
void InitFrom (DPoint2dCR point)
 Initializes the range to contain the single given point. More...
 
void Extend (DPoint2dCR point)
 Extends the coordinates of the range cube points in pRange so as to include the single additional point point. More...
 
void Extend (DPoint3dCR point)
 Extends the coordinates of the range cube points in pRange so as to include the single additional point point. More...
 
void InitFrom (double x, double y)
 Initialize the range from a single point given by components. More...
 
void Extend (double x, double y)
 extends the coordinates of the range cube points in pRange so as to include the single additional point at x,y. More...
 
void Extend (DPoint4dCR point4d)
 extends the coordinates of the range cube points in pRange so as to include the (normalized image of) the xy projection of the 4D point. More...
 
void InitFrom (DPoint2dCR point0, DPoint2dCR point1)
 Initializes the range to contain the two given points. More...
 
void InitFrom (double x0, double y0, double x1, double y1)
 Initializes the range to contain two points given as components. More...
 
void InitFrom (DPoint2dCR point0, DPoint2dCR point1, DPoint2dCR point2)
 Initialize the range to contain the three given points. More...
 
void InitFromUnitArcSweep (double theta0, double sweep)
 Initialize the range from an arc of the unit circle. More...
 
void InitFrom (DPoint2dCP point, int n)
 Initializes the range to contain the range of the given array of points. More...
 
void Extend (DPoint2dCP array, int n)
 extends the coordinates of the range cube points in pRange so as to include range of an array of points. More...
 
void InitFrom (DPoint3dCP point, int n)
 Initializes the range to contain the range of the xy parts of the array of 3D points. More...
 
void Extend (double extend)
 Extend each axis by the given distance on both ends of the range. More...
 
void Extend (DRange2dCR rangeB)
 extends the coordinates of the range cube points to include the range cube range1P. More...
 
bool IntersectionOf (DRange2dR range1, DRange2dR range2)
 Compute the intersection of two ranges and test if it is nonempty. More...
 
void UnionOf (DRange2dCR range1, DRange2dCR range2)
 Form the union of two ranges. More...
 
void RestrictToMinMax (DRange2dCR range0, DRange2dCR minMax)
 Returns a range which is the intersection of two ranges. More...
 
bool IsNull () const
 Check if the range is exactly the same as the null ranges returned by bsiDRange2d_init. More...
 
double ExtentSquared () const
 
double IntersectionExtentSquared (DRange2dCR range2) const
 Compute the intersection of given range with another range and return the extentSquared of the intersection range. More...
 
bool IsEmpty () const
 Test if high component is (strictly) less than low in any direction. More...
 
bool IsPoint () const
 
double Area () const
 returns product of axis extents. No test for zero or negative axes. More...
 
double LargestCoordinate () const
 
double XLength () const
 Returns difference of high and low in x direction – 0 if high < low. More...
 
double YLength () const
 Returns difference of high and low in y direction – 0 if high < low. More...
 
void Get4Lines (DPoint2dP originArray, DPoint2dP normalArray) const
 Extract the 4 bounding lines for a range rectangle, in origin normal form. More...
 
void Get4Corners (DPoint2dP box) const
 Generates a 4 point box around around a range cube. More...
 
int IndexOfMaximalAxis () const
 Return the index of the axis with largest absolute range. More...
 
bool IntersectRay (double &param0, double &param1, DPoint2dR point0, DPoint2dR point1, DPoint2dCR start, DPoint2dCR direction) const
 Compute the intersection of a range cube and a ray. More...
 
bool IsEqual (DRange2dCR range1) const
 Test if two ranges are exactly equal. More...
 
bool IsEqual (DRange2dCR range1, double tolerance) const
 Test if two ranges are equal within a tolerance applied componentwise. More...
 
bool TryFractionsToRangePoint (DPoint2dCR fractions, DPoint2dR xy) const
 map a fractional point to the range coordinates. More...
 
bool TryRangePointToFractions (DPoint2dCR xy, DPoint2dR fractions) const
 map a range point to the fractional coordinates. More...
 
bool IsContained (DRange2dCR outerRange) const
 Test if the given range is a (possible improper) subset of outerRange. More...
 
bool Contains (DPoint3dCR point) const
 Test if a point is contained in a range. More...
 
bool Contains (DPoint2dCR point) const
 Test if a point is contained in a range. More...
 
bool Contains (double x, double y) const
 Test if a point given as x,y,z is contained in a range. More...
 
bool IntersectsWith (DRange2dCR range2) const
 Test if two ranges have strictly non-null overlap (intersection) More...
 
bool MoveChangesIntersection (DRange2dCR newRange, DRange2dCR outerRange) const
 Test if a modification of the given (instance) range would have a different touching relationship with outerRange. More...
 

Static Public Member Functions

static DRange2d NullRange ()
 Initializes a range cube with (inverted) large positive and negative values. More...
 
static DRange2d From (DPoint2dCR point)
 Initializes the range to contain the single given point. More...
 
static DRange2d From (DRange3dCR range)
 Remove z part of DRange3d. More...
 
static DRange2d From (bvector< DPoint3d > const &point)
 Return the range of an array. More...
 
static DRange2d From (double x, double y)
 Initialize the range from a single point given by components. More...
 
static DRange2d From (DPoint2dCR point0, DPoint2dCR point1)
 Initializes the range to contain the two given points. More...
 
static DRange2d From (double x0, double y0, double x1, double y1)
 Initializes the range to contain two points given as components. More...
 
static DRange2d From (DPoint2dCR point0, DPoint2dCR point1, DPoint2dCR point2)
 Initialize the range to contain the three given points. More...
 
static DRange2d FromUnitArcSweep (double theta0, double sweep)
 Initialize the range from an arc of the unit circle. More...
 
static DRange2d From (DPoint2dCP point, int n)
 Initializes the range to contain the range of the given array of points. More...
 
static DRange2d From (bvector< DPoint2d > const &points)
 Initializes the range to contain the range of the given array of points. More...
 
static DRange2d From (DPoint3dCP point, int n)
 Initializes the range to contain the range of the xy parts of the array of 3D points. More...
 

Public Attributes

DPoint2d low
 low point of box More...
 
DPoint2d high
 high point of box More...
 

Detailed Description

A 2d low and high corner pair for range boxes.

The low and high members (points) are public, but should only be accessed for reading.

Member Function Documentation

double Area ( ) const

returns product of axis extents. No test for zero or negative axes.

bool Contains ( DPoint3dCR  point) const

Test if a point is contained in a range.

Parameters
[in]pointpoint to test. (z is ignored)
Returns
true if the point is in (or on boundary of)
bool Contains ( DPoint2dCR  point) const

Test if a point is contained in a range.

Parameters
[in]pointpoint to test. (z is ignored)
Returns
true if the point is in (or on boundary of)
bool Contains ( double  x,
double  y 
) const

Test if a point given as x,y,z is contained in a range.

Parameters
[in]xx coordinate
[in]yy coordinate
Returns
true if the point is in (or on boundary of)
void Extend ( DPoint2dCR  point)

Extends the coordinates of the range cube points in pRange so as to include the single additional point point.

Parameters
[in]pointnew point to be included in the range.
void Extend ( DPoint3dCR  point)

Extends the coordinates of the range cube points in pRange so as to include the single additional point point.

Parameters
[in]pointnew point to be included in the range.
void Extend ( double  x,
double  y 
)

extends the coordinates of the range cube points in pRange so as to include the single additional point at x,y.

Parameters
[in]xextended range coordinate
[in]yextended range coordinate
void Extend ( DPoint4dCR  point4d)

extends the coordinates of the range cube points in pRange so as to include the (normalized image of) the xy projection of the 4D point.

Parameters
[in]point4dnew point to be included in minmax ranges
void Extend ( DPoint2dCP  array,
int  n 
)

extends the coordinates of the range cube points in pRange so as to include range of an array of points.

Parameters
[in]arraynew points to be included in minmax ranges
[in]nnumber of points
void Extend ( double  extend)

Extend each axis by the given distance on both ends of the range.

Parameters
[in]extenddistance to extend
void Extend ( DRange2dCR  rangeB)

extends the coordinates of the range cube points to include the range cube range1P.

Parameters
[in]rangeBsecond range
double ExtentSquared ( ) const
Returns
0 if null range (as decided by IsNull ()), otherwise sum of squared axis extents.
static DRange2d From ( DPoint2dCR  point)
static

Initializes the range to contain the single given point.

static DRange2d From ( DRange3dCR  range)
static

Remove z part of DRange3d.

static DRange2d From ( bvector< DPoint3d > const &  point)
static

Return the range of an array.

static DRange2d From ( double  x,
double  y 
)
static

Initialize the range from a single point given by components.

Parameters
[in]xx coordinate
[in]yy coordinate
static DRange2d From ( DPoint2dCR  point0,
DPoint2dCR  point1 
)
static

Initializes the range to contain the two given points.

Parameters
[in]point0first point
[in]point1second point
static DRange2d From ( double  x0,
double  y0,
double  x1,
double  y1 
)
static

Initializes the range to contain two points given as components.

Minmax logic is applied to the given points.

Parameters
[in]x0first x
[in]y0first y
[in]x1second x
[in]y1second y
static DRange2d From ( DPoint2dCR  point0,
DPoint2dCR  point1,
DPoint2dCR  point2 
)
static

Initialize the range to contain the three given points.

Parameters
[in]point0first point
[in]point1second point
[in]point2third point
static DRange2d From ( DPoint2dCP  point,
int  n 
)
static

Initializes the range to contain the range of the given array of points.

If there are no points in the array, the range is initialized by

Parameters
[in]pointarray of points to search
[in]nnumber of points in array
static DRange2d From ( bvector< DPoint2d > const &  points)
static

Initializes the range to contain the range of the given array of points.

If there are no points in the array, the range is initialized by DRange2d.init()

Parameters
[in]pointscoordinates
static DRange2d From ( DPoint3dCP  point,
int  n 
)
static

Initializes the range to contain the range of the xy parts of the array of 3D points.

Parameters
[in]pointarray of points to search
[in]nnumber of points in array
static DRange2d FromUnitArcSweep ( double  theta0,
double  sweep 
)
static

Initialize the range from an arc of the unit circle.

Parameters
[in]theta0start angle
[in]sweepangular sweep
void Get4Corners ( DPoint2dP  box) const

Generates a 4 point box around around a range cube.

Point ordering is by "x varies fastest" — 00, 10, 01, 11 for the unit range.

Parameters
[out]boxarray of 4 points of the box
void Get4Lines ( DPoint2dP  originArray,
DPoint2dP  normalArray 
) const

Extract the 4 bounding lines for a range rectangle, in origin normal form.

Parameters
[out]originArrayarray of line origins
[out]normalArrayarray of plane normals. Directions down, left, right, up.
int IndexOfMaximalAxis ( ) const

Return the index of the axis with largest absolute range.

void Init ( )

Initializes a range cube with (inverted) large positive and negative values.

void InitFrom ( DPoint2dCR  point)

Initializes the range to contain the single given point.

void InitFrom ( double  x,
double  y 
)

Initialize the range from a single point given by components.

Parameters
[in]xx coordinate
[in]yy coordinate
void InitFrom ( DPoint2dCR  point0,
DPoint2dCR  point1 
)

Initializes the range to contain the two given points.

Parameters
[in]point0first point
[in]point1second point
void InitFrom ( double  x0,
double  y0,
double  x1,
double  y1 
)

Initializes the range to contain two points given as components.

Minmax logic is applied to the given points.

Parameters
[in]x0first x
[in]y0first y
[in]x1second x
[in]y1second y
void InitFrom ( DPoint2dCR  point0,
DPoint2dCR  point1,
DPoint2dCR  point2 
)

Initialize the range to contain the three given points.

Parameters
[in]point0first point
[in]point1second point
[in]point2third point
void InitFrom ( DPoint2dCP  point,
int  n 
)

Initializes the range to contain the range of the given array of points.

If there are no points in the array, the range is initialized by

Parameters
[in]pointarray of points to search
[in]nnumber of points in array
void InitFrom ( DPoint3dCP  point,
int  n 
)

Initializes the range to contain the range of the xy parts of the array of 3D points.

Parameters
[in]pointarray of points to search
[in]nnumber of points in array
void InitFromUnitArcSweep ( double  theta0,
double  sweep 
)

Initialize the range from an arc of the unit circle.

Parameters
[in]theta0start angle
[in]sweepangular sweep
double IntersectionExtentSquared ( DRange2dCR  range2) const

Compute the intersection of given range with another range and return the extentSquared of the intersection range.

Parameters
[in]range2second range
Returns
extentSquared() for the intersection range.
bool IntersectionOf ( DRange2dR  range1,
DRange2dR  range2 
)

Compute the intersection of two ranges and test if it is nonempty.

If empty (non overlap), result range null range.

Remarks
In earlier API (bsiDRange2d_intersect, DRange2d::intersectionOf (DRange2dCP, DRange2dCP) the result was uninitialized in the no-intersection case)
Parameters
[in]range1first range
[in]range2second range
Returns
same result as checkOverlap(range1,range2).
bool IntersectRay ( double &  param0,
double &  param1,
DPoint2dR  point0,
DPoint2dR  point1,
DPoint2dCR  start,
DPoint2dCR  direction 
) const

Compute the intersection of a range cube and a ray.

If there is not a finite intersection, both params are set to 0 and and both points to point0.

Parameters
[out]param0ray parameter where cube is entered
[out]param1ray parameter where cube is left
[out]point0entry point
[out]point1exit point
[in]startstart point of ray
[in]directiondirection of ray
Returns
true if non-empty intersection.
bool IntersectsWith ( DRange2dCR  range2) const

Test if two ranges have strictly non-null overlap (intersection)

Parameters
[in]range2second range
Returns
true if ranges overlap, false if not.
bool IsContained ( DRange2dCR  outerRange) const

Test if the given range is a (possible improper) subset of outerRange.

Parameters
[in]outerRangeouter range
Returns
true if the given range is a (possibly improper) subset of outerRange.
bool IsEmpty ( ) const

Test if high component is (strictly) less than low in any direction.

Note that equal components do not indicate empty. returns true if any low component is less than the corresponding high component

bool IsEqual ( DRange2dCR  range1) const

Test if two ranges are exactly equal.

Parameters
[in]range1second range
Returns
true if ranges are identical in all components.
bool IsEqual ( DRange2dCR  range1,
double  tolerance 
) const

Test if two ranges are equal within a tolerance applied componentwise.

Parameters
[in]range1second range
[in]tolerancetoleranc to be applied to each component
Returns
true if ranges are within tolerance in all components.
bool IsNull ( ) const

Check if the range is exactly the same as the null ranges returned by bsiDRange2d_init.

(Note that ranges with other values with low > high are not necessarily null by this condition.)

bool IsPoint ( ) const
Returns
true if high is less than or equal to low in every direction.
double LargestCoordinate ( ) const
Returns
the largest individual coordinate value among (a) range min point, (b) range max point, and (c) range diagonal vector.
bool MoveChangesIntersection ( DRange2dCR  newRange,
DRange2dCR  outerRange 
) const

Test if a modification of the given (instance) range would have a different touching relationship with outerRange.

Remarks
This may only be meaningful in context of range tree tests where some prior relationship among ranges is known to apply.
Parameters
[in]newRangecandidate for modified range relationship.
[in]outerRangecontaining range
Returns
true if touching condition occurs.
static DRange2d NullRange ( )
static

Initializes a range cube with (inverted) large positive and negative values.

void RestrictToMinMax ( DRange2dCR  range0,
DRange2dCR  minMax 
)

Returns a range which is the intersection of two ranges.

The first range is treated as a signed range, i.e. decreasing values from low to high are a nonempty range, and the output will maintain the direction. In a direction where there is no overlap, pRange high and low values are identical and are at the limit of pRange1 that is nearer to the values in range0. (Intended use: range0 is the 'actual' stroking range of a surface i.e. may go 'backwards'. pRange1 is the nominal full surface range, i.e. is known a priori to be 'forwards'. The clipping restricts unreliable range0 to the nominal surface range pRange1. range0 and pRange may be the same address. minMax must be different.

Parameters
[in]range0range to be restricted
[in]minMaxallowable minmax range. Assumed to have low < high
bool TryFractionsToRangePoint ( DPoint2dCR  fractions,
DPoint2dR  xy 
) const

map a fractional point to the range coordinates.

(0,0) is low point, (1,1) is high point.

Parameters
[in]fractionsfractional coordinates
[out]xycomputed coordinates.
Returns
false if range is null range.
bool TryRangePointToFractions ( DPoint2dCR  xy,
DPoint2dR  fractions 
) const

map a range point to the fractional coordinates.

(0,0) is low point, (1,1) is high point.

Parameters
[out]fractionsfractional coordinates
[in]xycomputed coordinates.
Returns
false if range is null range or single point.
void UnionOf ( DRange2dCR  range1,
DRange2dCR  range2 
)

Form the union of two ranges.

Parameters
[in]range1first range.
[in]range2second range.
double XLength ( ) const

Returns difference of high and low in x direction – 0 if high < low.

double YLength ( ) const

Returns difference of high and low in y direction – 0 if high < low.

Member Data Documentation

DPoint2d high

high point of box

Referenced by RTree2dVal::ToRange().

DPoint2d low

low point of box

Referenced by RTree2dVal::ToRange().


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

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.