Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80293309
morton.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 30, 23:50
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Sep 1, 23:50 (2 d)
Engine
blob
Format
Raw Data
Handle
20336867
Attached To
R10977 RADIANCE Photon Map
morton.c
View Options
#ifndef lint
static const char RCSid[] = "$Id$";
#endif
/*
=========================================================================
Routines to generate and compare Morton Codes, i.e. indices on space
filling Z-curves.
Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
(c) Lucerne University of Applied Sciences and Arts,
supported by the Swiss National Science Foundation
(SNSF #147053, "Daylight Redirecting Components",
SNSF #179067, "Light Fields for Spatio-Temporal Glare Assessment")
=========================================================================
$Id$
*/
#if !defined(_WIN32) && !defined(_WIN64) || defined(PMAP_OOC)
/* No Windoze support for now */
#include "morton.h"
MortonIdx Key2Morton3D (const FVECT key, const FVECT org, RREAL scale)
/* Compute Morton code (Z-curve index) of length 3 * MORTON3D_BITS bits
for 3D key within bounding box defined by org and scaled to maximum
index with scale */
{
unsigned i;
MortonIdx k [3];
/* Normalise key and map each dim to int of MORTON3D_BITS */
for (i = 0; i < 3; i++)
k [i] = scale * (key [i] - org [i]);
/* Interleave each dim with zeros and merge */
return (Morton3DBitInterleave(k [0]) |
Morton3DBitInterleave(k [1]) << 1 |
Morton3DBitInterleave(k [2]) << 2
);
}
MortonIdx Key2Morton2D (const RREAL key [2], const RREAL org [2], RREAL scale)
/* Compute Morton code (Z-curve index) of length 2 * MORTON2D_BITS bits
for 2D key within bounding box defined by org and scaled to maximum
index with scale */
{
unsigned i;
MortonIdx k [2];
/* Normalise key and map each dim to int of MORTON2D_BITS */
for (i = 0; i < 2; i++)
k [i] = scale * (key [i] - org [i]);
/* Interleave each dim with zeros and merge */
return (Morton2DBitInterleave(k [0]) | Morton2DBitInterleave(k [1]) << 1);
}
#endif /* NIX / PMAP_OOC */
Event Timeline
Log In to Comment