Skip to content

Instantly share code, notes, and snippets.

View mdsumner's full-sized avatar

Michael Sumner mdsumner

  • Integrated Digital East Antarctica, Australian Antarctic Division
  • Hobart, Australia
View GitHub Profile
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <gdal/ogrsf_frmts.h>
#include <geos_c.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
@jeroen
jeroen / shit.md
Last active March 4, 2022 07:18
Getting shit to work

Getting shit to work

Disclaimers

  • No authority
  • Official reference is writing r extentions (joke extentions)
  • If you thought writing regular r packages was tricky, hold on
@timelyportfolio
timelyportfolio / Readme.md
Created January 25, 2017 20:52
igraph layout editing with mapedit

This is certainly not the intended purpose of mapedit, but I thought it would be fun to use some accumulated R knowledge to use mapedit and leaflet to edit an igraph layout. To run the code, make sure to run the edit_map and Shiny parts separately.

library(igraph)
library(leaflet)
library(mapedit)

karate <- graph.famous("Zachary")
igrf_layout <- layout.auto(karate)
@timelyportfolio
timelyportfolio / Readme.md
Last active March 4, 2017 01:49
use d3.quadtree in R and plot with base graphics

d3r aims to make d3.js easy in R. Here is an example of combining d3.quadtree with base graphics in R using the new d3_v8() function.

Code

# d3.quadtree example

library(d3r)
@jamesgrecian
jamesgrecian / extract NSIDC.r
Last active June 12, 2018 15:08
Extract NSIDC geotiff data to points
############################################
### Extract NSIDC geotiff data to points ###
############################################
#Many thanks to mdsumner for help with this:
#https://github.com/mdsumner/extractNSIDC/blob/master/extract_script.R
#Load libraries
require(tidyverse)
require(lubridate)
@brodieG
brodieG / extruded-polygon-tests.R
Created May 2, 2020 21:15
Code used to test rayrender polygon extrusion patches
mk_name <- function(name=NULL) {
v <- as.character(packageVersion('rayrender'))
dir <- file.path('~', 'Downloads', 'rr-tests')
if(is.null(name)) {
name <- sprintf( 'a_%s.png', format(Sys.time(), "%Y-%m-%d_%H%M%S"))
} else {
name <- sprintf('%s.png', name)
}
file.path(dir, v, name)
}
@djnavarro
djnavarro / ff_b.cpp
Created August 22, 2020 10:30
fractal flame
#include <Rcpp.h>
using namespace Rcpp;
// turmite function to be called from R
// [[Rcpp::export]]
NumericMatrix flame(int iter, int layers) {
NumericMatrix points(iter, 3); // initially zero
NumericMatrix coeffs(9, layers);
@coolbutuseless
coolbutuseless / user-callbacks.R
Created September 8, 2020 04:32
mouse callbacks in rgl
library(rgl)
pan3d <- function(button, dev = rgl.cur(), subscene = currentSubscene3d(dev)) {
start <- list()
begin <- function(x, y) {
activeSubscene <- par3d("activeSubscene", dev = dev)
start$listeners <<- par3d("listeners", dev = dev, subscene = activeSubscene)
for (sub in start$listeners) {
library(rgl)
sl <- shapelist3d(cube3d(alpha = 1,
color = 'grey90',
specular = 'black',
lit = TRUE),
plot = FALSE)
create_next_level <- function(sl, level) {
@coolbutuseless
coolbutuseless / ray-tracer.Rmd
Last active July 22, 2021 11:48
Simple ray tracer in Base R
MIT Licensed. Copyright (c) 2021 mikefc@coolbutuseless.com
Share and Enjoy.
## Introduction
This code was a personal challenge to write a simple ray-tracer in pure R.
Ray tracing is an example of something which is really silly to do in base R,
and I'd be interested to see how others would approach this problem.