This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <set> | |
#include <vector> | |
using namespace std; | |
#include <Windows.h> | |
#define J4D2_CACHE_FILE_EXTENSION (L"j4d2cache") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <set> | |
#include <vector> | |
using namespace std; | |
#include <Windows.h> | |
#define J4D2_CACHE_FILE_EXTENSION (L"j4d2cache") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <ctime> | |
using namespace std; | |
int main(void) | |
{ | |
srand(time(0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, |