Skip to content

Instantly share code, notes, and snippets.

View todocono's full-sized avatar
🤖
Flow?

Rodolfo todocono

🤖
Flow?
View GitHub Profile
//Millis example
//Coded during class - Interaction Lab
//NYUSH IMA
//Mar 5 2024
int val;
int prevVal;
long startTime;
int state = 0;
//Millis example
//Coded during class - Interaction Lab
//NYUSH IMA
//Mar 5 2024
int val;
int prevVal;
long startTime;
void setup() {
@todocono
todocono / fingPivot.cpp
Last active August 23, 2023 15:44
findPivot function
/*Remember Quick Sort?  The pivot element selection has a significant impact on the efficiency of quick sort. The optimal pivot is the median element. The median element is an element that (almost) half of the elements in the list are smaller than the pivot element and (almost) half of elements are greater than the pivot element. For example, if a list is {3, 2, 9, 4, 5}, the median element is 4 (index 3) since 2 elements are smaller than 4 and 2 elements are greater than 4. Another example, if a list is {3, 2, 9, 5}, the median element is 3 (index 0) since 1 element is smaller than 3 and 2 elements are greater than 3. 
Write a function findPivot that accepts an array of integers, its size as parameters, and it returns the index of median element in the array. Here is the function prototype:
unsigned int findPivot( int* p_array, unsigned int size);
If we use this function in quick sort to select the pivot element, do you think it will help with efficiency of quick sort? Explain your reasoning. */
//a very
@todocono
todocono / L5-examples-BIT2400.cpp
Last active July 19, 2023 19:05
Lecture 5 examples, including inheritance, public, private, protected, and new
//Lecture 5 - BIT2400
//Example 3 - Inheritance & protected
//Exercise: Watch https://www.youtube.com/watch?v=jsNE1yGItx0 and
//make bullets have a different hit value depending on speed
#include <iostream>
#include <string>
using namespace std; //this is OK for our class only
import processing.video.*;
String[] cameras = Capture.list();
Capture liveFeed;
float angle =0;
void setup() {
size(1280, 960);
printArray(cameras);
liveFeed = new Capture(this, "pipeline:autovideosrc");
liveFeed.start();
import processing.video.*;
//String[] cameras = Capture.list();
Capture cam;
float alpha =0;
void setup() {
size(1280, 960);
//printArray(cameras);
cam = new Capture(this, "pipeline:autovideosrc"); // use if camera trouble: cam = new Capture(this, 640, 480, cameras[0],30);
/**
* Based on SendMultipleValue - See more at https://osteele.github.io/Processing_SerialRecord/
*
* Processing code
* Programmed in class - Interaction Lab 2022Fall
*
*
*/
import processing.serial.*;
import osteele.processing.SerialRecord.*;
/*
Based on SendMultipleValue by Oliver Steele, 2020-2022
See more at https://osteele.github.io/Arduino_SerialRecord/
Arduino code
Programmed in class - Interaction Lab 2022Fall
This example code is in the public domain.
*/
/* PROCESSING CODE
/**
* Example sketch for the SerialRecord library for Processing.
*
* Receives an integer from the serial port, and uses it to control the
* horizontal positon of a line on the canvas.
*
* This sketch has the same effect as calling `serialPort.read(0)`.
*
/**
* Based on ReceiveSingleValue - See more at https://osteele.github.io/Processing_SerialRecord/
*
* Processing code
* Programmed in class - Interaction Lab 2022Fall
*
*
*/
import processing.serial.*;