Skip to content

Instantly share code, notes, and snippets.

View sjhalayka's full-sized avatar

Shawn Halayka sjhalayka

View GitHub Profile
float mean(const vector<float> &src)
{
float m = 0;
float size = static_cast<float>(src.size());
for (size_t i = 0; i < src.size(); i++)
m += src[i];
m /= size;
bool are_connected(size_t index0, size_t index1, const vector< vector<bool> > &graph)
{
if (graph[index0][index1] && graph[index1][index0])
return true;
return false;
}
bool is_cycle_hamiltonian(const vector<size_t> &cycle, const vector< vector<bool> > &graph)
custom_math::vector_3 acceleration(custom_math::vector_3 pos, custom_math::vector_3 vel, custom_math::vector_3 ang_vel)
{
// http://twu.tennis-warehouse.com/learning_center/aerodynamics2.php
const double air_density = 1.225;
const double lift_coeff = 0.05;
const double drag_coeff = 0.55;
const double ball_cross_section = 0.0034;
const double ball_mass = 0.0585;
// Gravitation, in metres per second, per second
#include <string>
#include <set>
#include <vector>
using namespace std;
#include <Windows.h>
#define J4D2_CACHE_FILE_EXTENSION (L"j4d2cache")
#include <string>
#include <set>
#include <vector>
using namespace std;
#include <Windows.h>
#define J4D2_CACHE_FILE_EXTENSION (L"j4d2cache")
#include <iostream>
#include <cstdio>
#include <ctime>
using namespace std;
int main(void)
{
srand(time(0));
@sjhalayka
sjhalayka / main.cpp
Created August 1, 2020 04:53
Bare bones GLFW + Dear Imgui
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "dear imgui/imgui.h"
#include "dear imgui/imgui_impl_glfw.h"
#include "dear imgui/imgui_impl_opengl3.h"
// Automatically link in the GLFW and GLEW libraries if compiling on MSVC++
#ifdef _MSC_VER
#pragma comment(lib, "glew32")
vector<unsigned char> output_pixels(2048*2048*4);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glReadPixels(0, 0, 2048, 2048, GL_RGBA, GL_UNSIGNED_BYTE, &output_pixels[0]);
// Set up Targa TGA image data.
unsigned char idlength = 0;
unsigned char colourmaptype = 0;
unsigned char datatypecode = 2;
#version 430
uniform sampler2DShadow shadow_map;
in vec3 Position;
in vec3 Normal;
in vec4 ShadowCoord;
uniform vec4 LightPosition; // in view space
uniform vec4 LightPosition_Untransformed; // in world space
#include <iostream>
#include <cmath>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
float iterate_Mandelbrot_2d(vector< complex<float> >& trajectory_points,
const complex<float> C,