MeshLib
 
Loading...
Searching...
No Matches
MRIntersectionPrecomputes2.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector2.h"
4
5namespace MR
6{
7
10
18template <typename T>
19void findMaxVectorDim( int& dimX, int& dimY, const Vector2<T>& dir )
20{
21 if( std::abs( dir.x ) >= std::abs( dir.y ) )
22 {
23 dimX = 1; dimY = 0;
24 }
25 else
26 {
27 dimX = 0; dimY = 1;
28 }
29}
30
33template<typename T>
34struct IntersectionPrecomputes2
35{
36 // {1 / dir}
38 // [0]max, [1]next, [2]next-next
39 // f.e. {1,2} => {1,0}
40 int maxDimIdxY = 1;
41 int idxX = 0;
42
44 Vector2i sign;
45
47 T Sx, Sy;
50 {
52
53 sign.x = dir.x >= T( 0 ) ? 1 : 0;
54 sign.y = dir.y >= T( 0 ) ? 1 : 0;
55
56 Sx = dir[idxX] / dir[maxDimIdxY];
57 Sy = T( 1 ) / dir[maxDimIdxY];
58
59 invDir.x = ( dir.x == 0 ) ? std::numeric_limits<T>::max() : T( 1 ) / dir.x;
60 invDir.y = ( dir.y == 0 ) ? std::numeric_limits<T>::max() : T( 1 ) / dir.y;
61 }
62};
63
65
66}
void findMaxVectorDim(int &dimX, int &dimY, int &dimZ, const Vector3< T > &dir)
finds index of maximum axis and stores it into dimZ
Definition MRIntersectionPrecomputes.h:24
Definition MRCameraOrientationPlugin.h:7
int idxX
Definition MRIntersectionPrecomputes2.h:41
T Sy
Definition MRIntersectionPrecomputes2.h:47
IntersectionPrecomputes2(const Vector2< T > &dir)
Definition MRIntersectionPrecomputes2.h:49
T Sx
precomputed factors
Definition MRIntersectionPrecomputes2.h:47
Vector2i sign
stores signs of direction vector;
Definition MRIntersectionPrecomputes2.h:44
int maxDimIdxY
Definition MRIntersectionPrecomputes2.h:40
Vector2< T > invDir
Definition MRIntersectionPrecomputes2.h:37
Definition MRVector2.h:18
T x
Definition MRVector2.h:24
T y
Definition MRVector2.h:24