Field3D
CoordSys.h File Reference

Contains utility functions for constructing coordinate systems. More...

#include <cmath>
#include "Types.h"
#include "ns.h"

Go to the source code of this file.

Namespaces

 detail
 

Functions

template<typename T >
FIELD3D_VEC3_T< T > detail::ceil (const FIELD3D_VEC3_T< T > &v)
 Ceil function for Vec3. More...
 
template<typename T >
FIELD3D_NAMESPACE_OPEN FIELD3D_MTX_T< T > coordinateSystem (const FIELD3D_VEC3_T< T > &e1, const FIELD3D_VEC3_T< T > &e2, const FIELD3D_VEC3_T< T > &e3, const FIELD3D_VEC3_T< T > &origin)
 Constructs a coordinate systems given a set of basis vectors and an origin. More...
 
template<typename T >
FIELD3D_MTX_T< T > coordinateSystem (const FIELD3D_BOX_T< FIELD3D_VEC3_T< T > > &wsBounds)
 Constructs a coordinate system given a bounding box. More...
 
template<typename T >
FIELD3D_MTX_T< T > coordinateSystem (const FIELD3D_BOX_T< FIELD3D_VEC3_T< T > > &wsBounds, const FIELD3D_VEC3_T< T > &wsVoxelSize)
 Constructs a coordinate system that has its lower left corner at an even multiplier of the voxel-size, to ensure that voxel centers don't shift as the domain grows. More...
 
template<typename T >
FIELD3D_MTX_T< T > coordinateSystem (const FIELD3D_VEC3_T< T > &e1, const FIELD3D_VEC3_T< T > &e2, const FIELD3D_VEC3_T< T > &e3, const FIELD3D_VEC3_T< T > &origin)
 Constructs a coordinate systems given a set of basis vectors and an origin. More...
 
template<typename T >
FIELD3D_VEC3_T< T > detail::floor (const FIELD3D_VEC3_T< T > &v)
 Floor function for Vec3. More...
 

Detailed Description

Contains utility functions for constructing coordinate systems.

Definition in file CoordSys.h.

Function Documentation

template<typename T >
FIELD3D_NAMESPACE_OPEN FIELD3D_MTX_T<T> coordinateSystem ( const FIELD3D_VEC3_T< T > &  e1,
const FIELD3D_VEC3_T< T > &  e2,
const FIELD3D_VEC3_T< T > &  e3,
const FIELD3D_VEC3_T< T > &  origin 
)

Constructs a coordinate systems given a set of basis vectors and an origin.

Definition at line 119 of file CoordSys.h.

References coordinateSystem().

Referenced by detail::adjustedMIPFieldMapping(), and coordinateSystem().

123 {
124  FIELD3D_MTX_T<T> m;
125  m[0][0] = e1.x;
126  m[0][1] = e1.y;
127  m[0][2] = e1.z;
128  m[1][0] = e2.x;
129  m[1][1] = e2.y;
130  m[1][2] = e2.z;
131  m[2][0] = e3.x;
132  m[2][1] = e3.y;
133  m[2][2] = e3.z;
134  m[3][0] = origin.x;
135  m[3][1] = origin.y;
136  m[3][2] = origin.z;
137  return m;
138 }
template<typename T >
FIELD3D_MTX_T< T > coordinateSystem ( const FIELD3D_BOX_T< FIELD3D_VEC3_T< T > > &  wsBounds)

Constructs a coordinate system given a bounding box.

Definition at line 163 of file CoordSys.h.

References coordinateSystem(), and FIELD3D_NAMESPACE_HEADER_CLOSE.

164 {
165  FIELD3D_VEC3_T<T> e1(wsBounds.max.x - wsBounds.min.x, 0, 0);
166  FIELD3D_VEC3_T<T> e2(0, wsBounds.max.y - wsBounds.min.y, 0);
167  FIELD3D_VEC3_T<T> e3(0, 0, wsBounds.max.z - wsBounds.min.z);
168  FIELD3D_VEC3_T<T> origin(wsBounds.min);
169  return coordinateSystem(e1, e2, e3, origin);
170 }
FIELD3D_NAMESPACE_OPEN FIELD3D_MTX_T< T > coordinateSystem(const FIELD3D_VEC3_T< T > &e1, const FIELD3D_VEC3_T< T > &e2, const FIELD3D_VEC3_T< T > &e3, const FIELD3D_VEC3_T< T > &origin)
Constructs a coordinate systems given a set of basis vectors and an origin.
Definition: CoordSys.h:119
template<typename T >
FIELD3D_MTX_T< T > coordinateSystem ( const FIELD3D_BOX_T< FIELD3D_VEC3_T< T > > &  wsBounds,
const FIELD3D_VEC3_T< T > &  wsVoxelSize 
)

Constructs a coordinate system that has its lower left corner at an even multiplier of the voxel-size, to ensure that voxel centers don't shift as the domain grows.

Definition at line 145 of file CoordSys.h.

References coordinateSystem().

147 {
148  const FIELD3D_VEC3_T<T> voxelMin =
149  detail::floor<T>(wsBounds.min / wsVoxelSize) * wsVoxelSize;
150  const FIELD3D_VEC3_T<T> voxelMax =
151  detail::ceil<T>(wsBounds.max / wsVoxelSize) * wsVoxelSize;
152 
153  const FIELD3D_BOX_T<FIELD3D_VEC3_T<T> > box(voxelMin, voxelMax);
154 
155  return coordinateSystem(box);
156 }
FIELD3D_NAMESPACE_OPEN FIELD3D_MTX_T< T > coordinateSystem(const FIELD3D_VEC3_T< T > &e1, const FIELD3D_VEC3_T< T > &e2, const FIELD3D_VEC3_T< T > &e3, const FIELD3D_VEC3_T< T > &origin)
Constructs a coordinate systems given a set of basis vectors and an origin.
Definition: CoordSys.h:119
template<typename T >
FIELD3D_MTX_T<T> coordinateSystem ( const FIELD3D_VEC3_T< T > &  e1,
const FIELD3D_VEC3_T< T > &  e2,
const FIELD3D_VEC3_T< T > &  e3,
const FIELD3D_VEC3_T< T > &  origin 
)

Constructs a coordinate systems given a set of basis vectors and an origin.

Definition at line 119 of file CoordSys.h.

References coordinateSystem().

Referenced by detail::adjustedMIPFieldMapping(), and coordinateSystem().

123 {
124  FIELD3D_MTX_T<T> m;
125  m[0][0] = e1.x;
126  m[0][1] = e1.y;
127  m[0][2] = e1.z;
128  m[1][0] = e2.x;
129  m[1][1] = e2.y;
130  m[1][2] = e2.z;
131  m[2][0] = e3.x;
132  m[2][1] = e3.y;
133  m[2][2] = e3.z;
134  m[3][0] = origin.x;
135  m[3][1] = origin.y;
136  m[3][2] = origin.z;
137  return m;
138 }