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
@vvzen
vvzen / OSX Example
Last active September 1, 2016 12:01 — forked from baku89/OSX Example
Command line arguments in openFrameworks
open -n ./emptyExampleDebug.app/ --args --myargs 1 2 3 4
@vvzen
vvzen / 2dcirclepacking_bruteforce.cpp
Last active October 6, 2016 01:13
A brute force approach for sampling 2d unequal circles inside a rect. Openframeworks (C++)
// BRUTE FORCE APPROACH
int nOfTrials = 0;
// Stop when we've got 1024 circles inside circles vector
// circles is a vector of PackedCircle
while(circles.size() < 1024){
// A simple custom object for drawing circles
PackedCircle nextCircle;
// Add new circle at random position x and y and with random radius ranging from 4 to 64
// 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);
// 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
@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"
@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 / 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;
# 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
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@title : FUNCTIONAL. Initial study
@date : 27/01/2018
@author: vvz3n
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
import peasy.*;
import controlP5.*;
PeasyCam cam;
/*
* 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