Hermes
point.h File Reference

Geometric point classes. More...

Go to the source code of this file.

Classes

class  hermes::Point2< T >
 Geometric 2-dimensional point (x, y) More...
 
class  hermes::Point3< T >
 Geometric 3-dimensional vector (x, y, z) More...
 
struct  std::hash< hermes::Point2< T > >
 
struct  std::hash< hermes::Point3< T > >
 

Macros

#define ARITHMETIC_OP(OP)
 
#define RELATIONAL_OP(OP, CO)
 
#define ARITHMETIC_OP(OP)
 
#define RELATIONAL_OP(OP, CO)
 
#define MATH_OP(NAME, OP)
 

Typedefs

using hermes::point2 = Point2< real_t >
 
using hermes::point2f = Point2< float >
 
using hermes::point2d = Point2< double >
 
using hermes::point3 = Point3< real_t >
 
using hermes::point3f = Point3< float >
 
using hermes::point3d = Point3< double >
 
using hermes::point2i = Point2< Interval< real_t > >
 
using hermes::point3i = Point3< Interval< real_t > >
 

Functions

template<typename T >
HERMES_DEVICE_CALLABLE Point2< T > hermes::operator* (real_t f, const Point2< T > &a)
 Scalar multiplication operator. More...
 
template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance (const Point2< T > &a, const Point2< T > &b)
 Computes the Euclidean distance between two points. More...
 
template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance2 (const Point2< T > &a, const Point2< T > &b)
 Computes the squared Euclidean distance between two points. More...
 
template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance (const Point3< T > &a, const Point3< T > &b)
 Computes the Euclidean distance between two points. More...
 
template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance2 (const Point3< T > &a, const Point3< T > &b)
 Computes the squared Euclidean distance between two points. More...
 
template<typename T >
std::ostream & hermes::operator<< (std::ostream &os, const Point2< T > &p)
 
template<typename T >
std::ostream & hermes::operator<< (std::ostream &os, const Point3< T > &p)
 

Detailed Description

Geometric point classes.

Copyright (c) 2017, FilipeCN.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
FilipeCN (filip.nosp@m.edec.nosp@m.n@gma.nosp@m.il.c.nosp@m.om)
Date
2017-08-18

Macro Definition Documentation

◆ ARITHMETIC_OP [1/2]

#define ARITHMETIC_OP (   OP)
Value:
HERMES_DEVICE_CALLABLE Point2 &operator OP##= (const Vector2 <T> &v) { \
x OP##= v.x; y OP##= v.y; return *this; } \
HERMES_DEVICE_CALLABLE Point2 &operator OP##= (real_t f) { \
x OP##= f; y OP##= f; return *this; } \
HERMES_DEVICE_CALLABLE Point2 operator OP (const Vector2 <T> &v) const { \
return {x OP v.x, y OP v.y}; } \
HERMES_DEVICE_CALLABLE Point2 operator OP (real_t f) const { \
return {x OP f, y OP f}; }
float real_t
default floating point type
Definition: defs.h:75
#define HERMES_DEVICE_CALLABLE
Specifies that the function can be called from both host and device sides.
Definition: defs.h:45

◆ ARITHMETIC_OP [2/2]

#define ARITHMETIC_OP (   OP)
Value:
HERMES_DEVICE_CALLABLE Point3 &operator OP##= (const Vector3 <T> &v) { \
x OP##= v.x; y OP##= v.y; z OP##= v.z; return *this; } \
HERMES_DEVICE_CALLABLE Point3 &operator OP##= (real_t f) { \
x OP##= f; y OP##= f; z OP##= f; return *this; } \
HERMES_DEVICE_CALLABLE Point3 operator OP (const Vector3 <T> &v) const { \
return {x OP v.x, y OP v.y, z OP v.z}; } \
HERMES_DEVICE_CALLABLE Point3 operator OP (T f) const { \
return {x OP f, y OP f, z OP f}; }

◆ MATH_OP

#define MATH_OP (   NAME,
  OP 
)
Value:
template<typename T> \
HERMES_DEVICE_CALLABLE Point2<T> NAME(const Point2<T>& p) { \
return Point2<T>(OP(p.x), OP(p.y)); }

◆ RELATIONAL_OP [1/2]

#define RELATIONAL_OP (   OP,
  CO 
)
Value:
HERMES_DEVICE_CALLABLE bool operator OP (const Point2<T> &b) const { \
return x OP b.x CO y OP b.y; }

◆ RELATIONAL_OP [2/2]

#define RELATIONAL_OP (   OP,
  CO 
)
Value:
HERMES_DEVICE_CALLABLE bool operator OP (const Point3<T> &b) const { \
return x OP b.x CO y OP b.y CO z OP b.z; }

Function Documentation

◆ distance() [1/2]

template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance ( const Point2< T > &  a,
const Point2< T > &  b 
)

Computes the Euclidean distance between two points.

Template Parameters
T
Parameters
a
b
Returns

◆ distance() [2/2]

template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance ( const Point3< T > &  a,
const Point3< T > &  b 
)

Computes the Euclidean distance between two points.

Template Parameters
T
Parameters
a
b
Returns

◆ distance2() [1/2]

template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance2 ( const Point2< T > &  a,
const Point2< T > &  b 
)

Computes the squared Euclidean distance between two points.

Template Parameters
T
Parameters
a
b
Returns

◆ distance2() [2/2]

template<typename T >
HERMES_DEVICE_CALLABLE real_t hermes::distance2 ( const Point3< T > &  a,
const Point3< T > &  b 
)

Computes the squared Euclidean distance between two points.

Template Parameters
T
Parameters
a
b
Returns

◆ operator*()

template<typename T >
HERMES_DEVICE_CALLABLE Point2<T> hermes::operator* ( real_t  f,
const Point2< T > &  a 
)

Scalar multiplication operator.

Template Parameters
T
Parameters
f
a
Returns