KiCad PCB EDA Suite
mortoncodes.h File Reference

Implementes Morton Codes https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ http://www.forceflow.be/2013/10/07/morton-encodingdecoding-through-bit-interleaving-implementations/. More...

#include <stdint.h>

Go to the source code of this file.

Functions

uint32_t EncodeMorton2 (uint32_t x, uint32_t y)
 
uint32_t EncodeMorton3 (uint32_t x, uint32_t y, uint32_t z)
 
uint32_t DecodeMorton2X (uint32_t code)
 
uint32_t DecodeMorton2Y (uint32_t code)
 
uint32_t DecodeMorton3X (uint32_t code)
 
uint32_t DecodeMorton3Y (uint32_t code)
 
uint32_t DecodeMorton3Z (uint32_t code)
 

Detailed Description

Function Documentation

uint32_t DecodeMorton2X ( uint32_t  code)

Definition at line 98 of file mortoncodes.cpp.

References Compact1By1().

Referenced by C3D_RENDER_RAYTRACING::initialize_block_positions().

99 {
100  return Compact1By1( code >> 0 );
101 }
uint32_t Compact1By1(uint32_t x)
Definition: mortoncodes.cpp:61
uint32_t DecodeMorton2Y ( uint32_t  code)

Definition at line 104 of file mortoncodes.cpp.

References Compact1By1().

Referenced by C3D_RENDER_RAYTRACING::initialize_block_positions().

105 {
106  return Compact1By1( code >> 1 );
107 }
uint32_t Compact1By1(uint32_t x)
Definition: mortoncodes.cpp:61
uint32_t DecodeMorton3X ( uint32_t  code)

Definition at line 110 of file mortoncodes.cpp.

References Compact1By2().

111 {
112  return Compact1By2( code >> 0 );
113 }
uint32_t Compact1By2(uint32_t x)
Definition: mortoncodes.cpp:74
uint32_t DecodeMorton3Y ( uint32_t  code)

Definition at line 116 of file mortoncodes.cpp.

References Compact1By2().

117 {
118  return Compact1By2( code >> 1 );
119 }
uint32_t Compact1By2(uint32_t x)
Definition: mortoncodes.cpp:74
uint32_t DecodeMorton3Z ( uint32_t  code)

Definition at line 122 of file mortoncodes.cpp.

References Compact1By2().

123 {
124  return Compact1By2( code >> 2 );
125 }
uint32_t Compact1By2(uint32_t x)
Definition: mortoncodes.cpp:74
uint32_t EncodeMorton2 ( uint32_t  x,
uint32_t  y 
)

Definition at line 86 of file mortoncodes.cpp.

References Part1By1().

87 {
88  return ( Part1By1( y ) << 1 ) + Part1By1( x );
89 }
uint32_t Part1By1(uint32_t x)
Definition: mortoncodes.cpp:35
uint32_t EncodeMorton3 ( uint32_t  x,
uint32_t  y,
uint32_t  z 
)

Definition at line 92 of file mortoncodes.cpp.

References Part1By2().

93 {
94  return ( Part1By2( z ) << 2 ) + ( Part1By2( y ) << 1 ) + Part1By2( x );
95 }
uint32_t Part1By2(uint32_t x)
Definition: mortoncodes.cpp:48