Loading...
Searching...
No Matches
GfRange2f Class Reference

Basic type: 2-dimensional floating point range. More...

#include <range2f.h>

Public Types

typedef GfVec2f MinMaxType
 Helper typedef.
 
typedef GfVec2f::ScalarType ScalarType
 

Public Member Functions

void SetEmpty ()
 Sets the range to an empty interval.
 
 GfRange2f ()
 The default constructor creates an empty range.
 
 GfRange2f (const GfVec2f &min, const GfVec2f &max)
 This constructor initializes the minimum and maximum points.
 
GF_API GfRange2f (class GfRange2d const &other)
 Construct from GfRange2d.
 
const GfVec2fGetMin () const
 Returns the minimum value of the range.
 
const GfVec2fGetMax () const
 Returns the maximum value of the range.
 
GfVec2f GetSize () const
 Returns the size of the range.
 
GfVec2f GetMidpoint () const
 Returns the midpoint of the range, that is, 0.5*(min+max).
 
void SetMin (const GfVec2f &min)
 Sets the minimum value of the range.
 
void SetMax (const GfVec2f &max)
 Sets the maximum value of the range.
 
bool IsEmpty () const
 Returns whether the range is empty (max < min).
 
void ExtendBy (const GfVec2f &point)
 Modifies the range if necessary to surround the given value.
 
void ExtendBy (const GfRange2f &range)
 Modifies the range if necessary to surround the given range.
 
bool Contains (const GfVec2f &point) const
 Returns true if the point is located inside the range.
 
bool Contains (const GfRange2f &range) const
 Returns true if the range is located entirely inside the range.
 
bool IsInside (const GfVec2f &point) const
 Returns true if the point is located inside the range.
 
bool IsInside (const GfRange2f &range) const
 Returns true if the range is located entirely inside the range.
 
bool IsOutside (const GfRange2f &range) const
 Returns true if the range is located entirely outside the range.
 
const GfRange2fUnionWith (const GfRange2f &b)
 Extend this to include b.
 
const GfRange2fUnionWith (const GfVec2f &b)
 Extend this to include b.
 
const GfRange2fUnion (const GfRange2f &b)
 Extend this to include b.
 
const GfRange2fUnion (const GfVec2f &b)
 Extend this to include b.
 
const GfRange2fIntersectWith (const GfRange2f &b)
 Modifies this range to hold its intersection with b and returns the result.
 
const GfRange2fIntersection (const GfRange2f &b)
 Modifies this range to hold its intersection with b and returns the result.
 
GfRange2foperator+= (const GfRange2f &b)
 unary sum.
 
GfRange2foperator-= (const GfRange2f &b)
 unary difference.
 
GfRange2foperator*= (double m)
 unary multiply.
 
GfRange2foperator/= (double m)
 unary division.
 
GfRange2f operator+ (const GfRange2f &b) const
 binary sum.
 
GfRange2f operator- (const GfRange2f &b) const
 binary difference.
 
bool operator== (const GfRange2f &b) const
 The min and max points must match exactly for equality.
 
bool operator!= (const GfRange2f &b) const
 
GF_API bool operator== (const GfRange2d &other) const
 Compare this range to a GfRange2d.
 
GF_API bool operator!= (const GfRange2d &other) const
 
GF_API double GetDistanceSquared (const GfVec2f &p) const
 Compute the squared distance from a point to the range.
 
GF_API GfVec2f GetCorner (size_t i) const
 Returns the ith corner of the range, in the following order: SW, SE, NW, NE.
 
GF_API GfRange2f GetQuadrant (size_t i) const
 Returns the ith quadrant of the range, in the following order: SW, SE, NW, NE.
 

Static Public Member Functions

static GfRange2f GetUnion (const GfRange2f &a, const GfRange2f &b)
 Returns the smallest GfRange2f which contains both a and b.
 
static GfRange2f Union (const GfRange2f &a, const GfRange2f &b)
 Returns the smallest GfRange2f which contains both a and b.
 
static GfRange2f GetIntersection (const GfRange2f &a, const GfRange2f &b)
 Returns a GfRange2f that describes the intersection of a and b.
 
static GfRange2f Intersection (const GfRange2f &a, const GfRange2f &b)
 Returns a GfRange2f that describes the intersection of a and b.
 

Static Public Attributes

static const size_t dimension = GfVec2f::dimension
 
static GF_API const GfRange2f UnitSquare
 The unit square.
 

Friends

GfRange2f operator* (double m, const GfRange2f &r)
 scalar multiply.
 
GfRange2f operator* (const GfRange2f &r, double m)
 scalar multiply.
 
GfRange2f operator/ (const GfRange2f &r, double m)
 scalar divide.
 
size_t hash_value (const GfRange2f &r)
 hash.
 

Detailed Description

Basic type: 2-dimensional floating point range.

This class represents a 2-dimensional range (or interval) All operations are component-wise and conform to interval mathematics. An empty range is one where max < min. The default empty is [FLT_MAX,-FLT_MAX]

Definition at line 46 of file range2f.h.

Member Typedef Documentation

◆ MinMaxType

Helper typedef.

Definition at line 51 of file range2f.h.

◆ ScalarType

GfVec2f::ScalarType ScalarType

Definition at line 54 of file range2f.h.

Constructor & Destructor Documentation

◆ GfRange2f() [1/3]

GfRange2f ( )
inline

The default constructor creates an empty range.

Definition at line 64 of file range2f.h.

◆ GfRange2f() [2/3]

GfRange2f ( const GfVec2f & min,
const GfVec2f & max )
inline

This constructor initializes the minimum and maximum points.

Definition at line 69 of file range2f.h.

◆ GfRange2f() [3/3]

GF_API GfRange2f ( class GfRange2d const & other)
explicit

Construct from GfRange2d.

Member Function Documentation

◆ Contains() [1/2]

bool Contains ( const GfRange2f & range) const
inline

Returns true if the range is located entirely inside the range.

As with all operations of this type, the ranges are assumed to include their extrema.

Definition at line 125 of file range2f.h.

◆ Contains() [2/2]

bool Contains ( const GfVec2f & point) const
inline

Returns true if the point is located inside the range.

As with all operations of this type, the range is assumed to include its extrema.

Definition at line 117 of file range2f.h.

◆ ExtendBy() [1/2]

void ExtendBy ( const GfRange2f & range)
inline

Modifies the range if necessary to surround the given range.

Deprecated
Use UnionWith() instead.

Definition at line 113 of file range2f.h.

◆ ExtendBy() [2/2]

void ExtendBy ( const GfVec2f & point)
inline

Modifies the range if necessary to surround the given value.

Deprecated
Use UnionWith() instead.

Definition at line 109 of file range2f.h.

◆ GetCorner()

GF_API GfVec2f GetCorner ( size_t i) const

Returns the ith corner of the range, in the following order: SW, SE, NW, NE.

◆ GetDistanceSquared()

GF_API double GetDistanceSquared ( const GfVec2f & p) const

Compute the squared distance from a point to the range.

◆ GetIntersection()

static GfRange2f GetIntersection ( const GfRange2f & a,
const GfRange2f & b )
inlinestatic

Returns a GfRange2f that describes the intersection of a and b.

Definition at line 193 of file range2f.h.

◆ GetMax()

const GfVec2f & GetMax ( ) const
inline

Returns the maximum value of the range.

Definition at line 83 of file range2f.h.

◆ GetMidpoint()

GfVec2f GetMidpoint ( ) const
inline

Returns the midpoint of the range, that is, 0.5*(min+max).

Note: this returns zero in the case of default-constructed ranges, or ranges set via SetEmpty().

Definition at line 91 of file range2f.h.

◆ GetMin()

const GfVec2f & GetMin ( ) const
inline

Returns the minimum value of the range.

Definition at line 80 of file range2f.h.

◆ GetQuadrant()

GF_API GfRange2f GetQuadrant ( size_t i) const

Returns the ith quadrant of the range, in the following order: SW, SE, NW, NE.

◆ GetSize()

GfVec2f GetSize ( ) const
inline

Returns the size of the range.

Definition at line 86 of file range2f.h.

◆ GetUnion()

static GfRange2f GetUnion ( const GfRange2f & a,
const GfRange2f & b )
inlinestatic

Returns the smallest GfRange2f which contains both a and b.

Definition at line 153 of file range2f.h.

◆ Intersection() [1/2]

static GfRange2f Intersection ( const GfRange2f & a,
const GfRange2f & b )
inlinestatic

Returns a GfRange2f that describes the intersection of a and b.

Deprecated
Use GetIntersection() instead.

Definition at line 202 of file range2f.h.

◆ Intersection() [2/2]

const GfRange2f & Intersection ( const GfRange2f & b)
inline

Modifies this range to hold its intersection with b and returns the result.

Deprecated
Use IntersectWith() instead.

Definition at line 217 of file range2f.h.

◆ IntersectWith()

const GfRange2f & IntersectWith ( const GfRange2f & b)
inline

Modifies this range to hold its intersection with b and returns the result.

Definition at line 208 of file range2f.h.

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Returns whether the range is empty (max < min).

Definition at line 103 of file range2f.h.