Skip to content

Instantly share code, notes, and snippets.

View vvzen's full-sized avatar
🎥
Pipeline Developer

Valerio Viperino vvzen

🎥
Pipeline Developer
View GitHub Profile
/*
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
*/
// PINS
#define CS_PIN 4
/*
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
*/
// PINS
#define CS_PIN 4
/*
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
*/
// PINS
#define CS_PIN 4
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@title : FUNCTIONAL. Initial study
@date : 27/01/2018
@author: vvz3n
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
import peasy.*;
import controlP5.*;
PeasyCam cam;
# see https://en.wikipedia.org/wiki/Spherical_coordinate_system
def spherical_to_cartesian(lat, lon, radius):
latitude = math.radians(lat)
longitude = math.radians(lon)
x = radius * math.sin(latitude) * math.cos(longitude)
y = radius * math.sin(latitude) * math.sin(longitude)
z = radius * math.cos(latitude)
return x, y, z
@vvzen
vvzen / example_export.cpp
Created August 5, 2017 08:33
Export .ply from mesh (openframeworks)
void ofApp::exportPlyCloud(ofMesh pcMesh, string filename){
ofFile ply;
if(ply.open(filename, ofFile::WriteOnly)){
// write the header
ply << "ply" << endl;
ply << "format binary_little_endian 1.0" << endl;
ply << "element vertex " << pcMesh.getVertices().size() << endl;
ply << "property float x" << endl;
ply << "property float y" << endl;
@vvzen
vvzen / OF_with_visual_studio_code.md
Last active August 17, 2023 02:59
A quick reminder on how to use openframeworks without XCode (macOS)

Using OpenFrameworks with Visual Studio Code (macOS)

  1. First, install the cpptools extension in studio code

  2. Then add the include paths in the c_cpp_properties.json file.

    If a small light bulb icon (💡) appears near the include statements on any of your source file, just click it in order to access the c_c_pp_properties.json file.

    If there's no 💡 icon, then in the project directory create a hidden folder called vscode:

@vvzen
vvzen / cronjob_example.sh
Created February 20, 2017 23:55
A simple example of adding notifications to a cronjob
osascript -e 'display notification "Starting uTorrent from crontab" with title "Launching uTorrent"' && open -a "uTorrent"
// Everything is like before, we have only modified these 2 methods
// 1. Method for generating a mitchell best candidate. v2 : NOW WITH DIFFERENT RADII INCLUDED!
// PackedCircle is just a wrapper for a 2d point with a radius and the methods for drawing it
PackedCircle ofApp::getMitchellBestCandidate(){
// The more time has past, the more I want to pick smaller radii
float maxRunTime = 30 * 1000; // time in ms
float randomMin = maxRunTime / ofGetElapsedTimeMillis() / 2;
// If anything goes below 4, clamp it to 4
// Algorithm is divided in 4 parts
// 1. Method for generating a mitchell best candidate
// PackedCircle is just a wrapper for a 2d point with a radius and the methods for drawing it
PackedCircle ofApp::getMitchellBestCandidate(){
float greatestDistance = 0.0f;
PackedCircle winningSample;
// Init at (0,0) with radius of 0
winningSample.setup(ofPoint(0,0), 0.0f);