Skip to content

Instantly share code, notes, and snippets.

@natevm
natevm / hploc.slang
Last active August 27, 2024 15:51
An implementation of "H-PLOC Hierarchical Parallel Locally-Ordered Clustering for Bounding Volume Hierarchy Construction".
// MIT License
// Copyright (c) 2024 Nathan V. Morrical
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@natevm
natevm / helperMath.h
Created December 3, 2021 20:05
CUDA Math Helper Functions
#pragma once
#include <iostream>
#include <cuda_runtime.h>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#ifndef __CUDACC__
using namespace std;
@natevm
natevm / pseudoangle.h
Created October 11, 2017 21:37
Pseudo-angle method
// angle relative to the x axis.
inline float pseudoangle(float2 p1, float2 p2) {
float dx, dy, t;
dx = p2.x - p1.x;
dy = p2.y - p1.y;
if ((dx == 0.0) && (dy == 0.0)) {
return -1; // indicating error
}
else {
t = dy / (fabs(dx) + fabs(dy));