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_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_BOX_T< FIELD3D_VEC3_T< T > > &wsBounds, const FIELD3D_VEC3_T< T > &wsVoxelSize, Box3i &extents)
 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_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_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

◆ coordinateSystem() [1/5]

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 128 of file CoordSys.h.

132 {
133  FIELD3D_MTX_T<T> m;
134  m[0][0] = e1.x;
135  m[0][1] = e1.y;
136  m[0][2] = e1.z;
137  m[1][0] = e2.x;
138  m[1][1] = e2.y;
139  m[1][2] = e2.z;
140  m[2][0] = e3.x;
141  m[2][1] = e3.y;
142  m[2][2] = e3.z;
143  m[3][0] = origin.x;
144  m[3][1] = origin.y;
145  m[3][2] = origin.z;
146  return m;
147 }

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

◆ coordinateSystem() [2/5]

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 188 of file CoordSys.h.

190 {
191  FIELD3D_VEC3_T<T> e1(wsBounds.max.x - wsBounds.min.x, 0, 0);
192  FIELD3D_VEC3_T<T> e2(0, wsBounds.max.y - wsBounds.min.y, 0);
193  FIELD3D_VEC3_T<T> e3(0, 0, wsBounds.max.z - wsBounds.min.z);
194  FIELD3D_VEC3_T<T> origin(wsBounds.min);
195  return coordinateSystem(e1, e2, e3, origin);
196 }

References coordinateSystem().

◆ coordinateSystem() [3/5]

template<typename T >
FIELD3D_MTX_T< T > coordinateSystem ( const FIELD3D_BOX_T< FIELD3D_VEC3_T< T > > &  wsBounds,
const FIELD3D_VEC3_T< T > &  wsVoxelSize,
Box3i extents 
)

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 153 of file CoordSys.h.

156 {
157  const FIELD3D_VEC3_T<T> voxelMin =
158  detail::floor<T>(wsBounds.min / wsVoxelSize) * wsVoxelSize;
159  const FIELD3D_VEC3_T<T> voxelMax =
160  detail::ceil<T>(wsBounds.max / wsVoxelSize) * wsVoxelSize;
161 
162  // Resolution
163  extents.min = V3i(detail::floor<T>(voxelMin / wsVoxelSize) + V3f(0.5));
164  extents.max = V3i(detail::floor<T>(voxelMax / wsVoxelSize) + V3f(0.5));
165 
166  // Bounding box
167  const FIELD3D_BOX_T<FIELD3D_VEC3_T<T> > box(voxelMin, voxelMax);
168 
169  return coordinateSystem(box);
170 }

References coordinateSystem().

◆ coordinateSystem() [4/5]

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 176 of file CoordSys.h.

179 {
180  Box3i dummy;
181  return coordinateSystem(wsBounds, wsVoxelSize, dummy);
182 }

References coordinateSystem().

◆ coordinateSystem() [5/5]

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 128 of file CoordSys.h.

132 {
133  FIELD3D_MTX_T<T> m;
134  m[0][0] = e1.x;
135  m[0][1] = e1.y;
136  m[0][2] = e1.z;
137  m[1][0] = e2.x;
138  m[1][1] = e2.y;
139  m[1][2] = e2.z;
140  m[2][0] = e3.x;
141  m[2][1] = e3.y;
142  m[2][2] = e3.z;
143  m[3][0] = origin.x;
144  m[3][1] = origin.y;
145  m[3][2] = origin.z;
146  return m;
147 }

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

V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3f
Imath::V3f V3f
Definition: SpiMathLib.h:73
coordinateSystem
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:128
Box3i
Imath::Box3i Box3i
Definition: SpiMathLib.h:77