Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::math::Range< Dimension, T > Class Template Reference

The Range class defines an N-dimensional interval defined by minimum and maximum N-dimensional endpoints. More...

#include "range.h"

Inheritance diagram for ion::math::Range< Dimension, T >:
Collaboration diagram for ion::math::Range< Dimension, T >:

Public Types

typedef RangeBase< Dimension, TBaseType
 
typedef BaseType::Endpoint Endpoint
 
typedef BaseType::Size Size
 
enum  { kDimension = Dimension }
 The dimension of the Range. More...
 

Public Member Functions

 Range ()
 The default constructor defines an empty Range. More...
 
 Range (const Endpoint &min_point, const Endpoint &max_point)
 Constructor that takes the minimum and maximum points. More...
 
void MakeEmpty ()
 Sets the Range to be empty. More...
 
bool IsEmpty () const
 Returns true if the Range is empty, meaning that the minimum value is strictly greater than the maximum value in some dimension. More...
 
const EndpointGetMinPoint () const
 Returns the minimum or maximum endpoint. More...
 
const EndpointGetMaxPoint () const
 
void SetMinPoint (const Endpoint &p)
 Modifies the minimum or maximum endpoint, or both. More...
 
void SetMaxPoint (const Endpoint &p)
 
void Set (const Endpoint &min_point, const Endpoint &max_point)
 
void SetMinComponent (int i, T value)
 Modifies a single element for the minimum or maximum endpoint. More...
 
void SetMaxComponent (int i, T value)
 
void SetWithSize (const Endpoint &min_point, const Size &size)
 Sets the Range from the minimum point and Range size. More...
 
const Size GetSize () const
 Returns the size of the range, or the zero vector if the Range is empty. More...
 
const Endpoint GetCenter () const
 Returns the point at the center of the range, or the origin if the range is empty. More...
 
void ExtendByPoint (const Endpoint &p)
 Extends the Range if necessary to contain the given point. More...
 
void ExtendByRange (const Range &r)
 Extends the Range if necessary to contain the given Range. More...
 
bool ContainsPoint (const Endpoint &p) const
 Returns true if the Range contains the given point. More...
 
bool ContainsRange (const Range &r) const
 Returns true if this Range fully contains the given Range by testing both min/max points of input Range. More...
 
bool IntersectsRange (const Range &r) const
 Returns true if this Range overlaps the given Range, i.e., there exists at least one point contained in both ranges. More...
 

Static Public Member Functions

static const Range BuildWithSize (const Endpoint &min_point, const Size &size)
 Convenience function that returns a Range from a minimum point and the Range size. More...
 

Friends

bool operator== (const Range &m0, const Range &m1)
 Exact equality and inequality comparisons. More...
 
bool operator!= (const Range &m0, const Range &m1)
 

Detailed Description

template<int Dimension, typename T>
class ion::math::Range< Dimension, T >

The Range class defines an N-dimensional interval defined by minimum and maximum N-dimensional endpoints.

The geometric interpretation of a Range is: 1D: A segment of the number line. 2D: An axis-aligned rectangle. 3D: An axis-aligned box.

A Range is considered to be empty if the minimum value is strictly greater than the maximum value in any dimension.

Definition at line 100 of file range.h.

Member Typedef Documentation

template<int Dimension, typename T>
typedef RangeBase<Dimension, T> ion::math::Range< Dimension, T >::BaseType

Definition at line 102 of file range.h.

template<int Dimension, typename T>
typedef BaseType::Endpoint ion::math::Range< Dimension, T >::Endpoint

Definition at line 103 of file range.h.

template<int Dimension, typename T>
typedef BaseType::Size ion::math::Range< Dimension, T >::Size

Definition at line 104 of file range.h.

Member Enumeration Documentation

template<int Dimension, typename T >
anonymous enum
inherited

The dimension of the Range.

Enumerator
kDimension 

Definition at line 73 of file range.h.

Constructor & Destructor Documentation

template<int Dimension, typename T>
ion::math::Range< Dimension, T >::Range ( )
inline

The default constructor defines an empty Range.

Definition at line 107 of file range.h.

References ion::math::Range< Dimension, T >::MakeEmpty().

template<int Dimension, typename T>
ion::math::Range< Dimension, T >::Range ( const Endpoint min_point,
const Endpoint max_point 
)
inline

Constructor that takes the minimum and maximum points.

This does not check that the values form a valid Range, so the resulting instance might be considered empty.

Definition at line 112 of file range.h.

References ion::math::Range< Dimension, T >::Set().

Member Function Documentation

template<int Dimension, typename T>
static const Range ion::math::Range< Dimension, T >::BuildWithSize ( const Endpoint min_point,
const Size size 
)
inlinestatic

Convenience function that returns a Range from a minimum point and the Range size.

This does not check that the values form a valid Range, so the resulting instance might be considered empty.

Definition at line 119 of file range.h.

References ion::math::Range< Dimension, T >::SetWithSize().

template<int Dimension, typename T >
bool ion::math::Range< Dimension, T >::ContainsPoint ( const Endpoint p) const

Returns true if the Range contains the given point.

Default implementation; faster specialized versions are found below.

This is true if the point lies between or on the Range extents.

Definition at line 313 of file range.h.

template<int Dimension, typename T >
bool ion::math::Range< Dimension, T >::ContainsRange ( const Range< Dimension, T > &  r) const

Returns true if this Range fully contains the given Range by testing both min/max points of input Range.

Definition at line 322 of file range.h.

References ion::math::Range< Dimension, T >::GetMaxPoint(), and ion::math::Range< Dimension, T >::GetMinPoint().

template<int Dimension, typename T >
void ion::math::Range< Dimension, T >::ExtendByPoint ( const Endpoint p)

Extends the Range if necessary to contain the given point.

If the Range is empty, it will be modified to contain just the point.

Definition at line 289 of file range.h.

template<int Dimension, typename T >
void ion::math::Range< Dimension, T >::ExtendByRange ( const Range< Dimension, T > &  r)

Extends the Range if necessary to contain the given Range.

If this Range is empty, it becomes r. If r is empty, the Range is untouched.

Definition at line 299 of file range.h.

References ion::math::Range< Dimension, T >::GetMaxPoint(), ion::math::Range< Dimension, T >::GetMinPoint(), and ion::math::Range< Dimension, T >::IsEmpty().

Referenced by ion::math::RangeUnion().

template<int Dimension, typename T>
const Endpoint ion::math::Range< Dimension, T >::GetCenter ( ) const
inline

Returns the point at the center of the range, or the origin if the range is empty.

Definition at line 167 of file range.h.

References ion::math::Range< Dimension, T >::IsEmpty(), and ion::math::Point< Dimension, T >::Zero().

Referenced by ion::math::ScaleRange(), and ion::math::ScaleRangeNonUniformly().

template<int Dimension, typename T>
const Endpoint& ion::math::Range< Dimension, T >::GetMinPoint ( ) const
inline
template<int Dimension, typename T>
const Size ion::math::Range< Dimension, T >::GetSize ( ) const
inline

Returns the size of the range, or the zero vector if the Range is empty.

Definition at line 161 of file range.h.

References ion::math::Range< Dimension, T >::IsEmpty(), and ion::math::Vector< Dimension, T >::Zero().

Referenced by ion::math::NVolume().

template<int Dimension, typename T >
bool ion::math::Range< Dimension, T >::IntersectsRange ( const Range< Dimension, T > &  r) const

Returns true if this Range overlaps the given Range, i.e., there exists at least one point contained in both ranges.

Definition at line 327 of file range.h.

References ion::math::Range< Dimension, T >::GetMaxPoint(), and ion::math::Range< Dimension, T >::GetMinPoint().

bool ion::math::Range3d::IsEmpty ( ) const
inline

Returns true if the Range is empty, meaning that the minimum value is strictly greater than the maximum value in some dimension.

Default implementation; faster specialized versions are found below.

Definition at line 264 of file range.h.

Referenced by ion::math::Range< Dimension, T >::ExtendByRange(), ion::math::Range< Dimension, T >::GetCenter(), ion::math::Range< Dimension, T >::GetSize(), ion::math::ModulateRange(), ion::math::NVolume(), ion::math::RangeIntersection(), ion::math::RangesAlmostEqual(), ion::math::ScaleRange(), and ion::math::ScaleRangeNonUniformly().

void ion::math::Range3d::MakeEmpty ( )
inline

Sets the Range to be empty.

Specializations for higher performance.

Implementation.

Default implementation; faster specialized versions are found below.

Definition at line 254 of file range.h.

Referenced by ion::math::Range< Dimension, T >::Range().

template<int Dimension, typename T>
void ion::math::Range< Dimension, T >::Set ( const Endpoint min_point,
const Endpoint max_point 
)
inline

Definition at line 143 of file range.h.

Referenced by ion::math::operator>>(), and ion::math::Range< Dimension, T >::Range().

template<int Dimension, typename T >
void ion::math::Range< Dimension, T >::SetMaxComponent ( int  i,
T  value 
)

Definition at line 281 of file range.h.

References DCHECK_GT, DCHECK_LE, and value.

template<int Dimension, typename T>
void ion::math::Range< Dimension, T >::SetMaxPoint ( const Endpoint p)
inline

Definition at line 142 of file range.h.

template<int Dimension, typename T >
void ion::math::Range< Dimension, T >::SetMinComponent ( int  i,
T  value 
)

Modifies a single element for the minimum or maximum endpoint.

Definition at line 273 of file range.h.

References DCHECK_GT, DCHECK_LE, and value.

template<int Dimension, typename T>
void ion::math::Range< Dimension, T >::SetMinPoint ( const Endpoint p)
inline

Modifies the minimum or maximum endpoint, or both.

This does not check that the values form a valid Range, so the resulting instance might be considered empty.

Definition at line 141 of file range.h.

template<int Dimension, typename T>
void ion::math::Range< Dimension, T >::SetWithSize ( const Endpoint min_point,
const Size size 
)
inline

Sets the Range from the minimum point and Range size.

This does not check that the values form a valid Range, so the resulting instance might be considered empty.

Definition at line 155 of file range.h.

Referenced by ion::math::Range< Dimension, T >::BuildWithSize().

Friends And Related Function Documentation

template<int Dimension, typename T>
bool operator!= ( const Range< Dimension, T > &  m0,
const Range< Dimension, T > &  m1 
)
friend

Definition at line 202 of file range.h.

template<int Dimension, typename T>
bool operator== ( const Range< Dimension, T > &  m0,
const Range< Dimension, T > &  m1 
)
friend

Exact equality and inequality comparisons.

Definition at line 193 of file range.h.


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