sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh
void getQuaternion(Mat R, double Q[]) | |
{ | |
double trace = R.at<double>(0,0) + R.at<double>(1,1) + R.at<double>(2,2); | |
if (trace > 0.0) | |
{ | |
double s = sqrt(trace + 1.0); | |
Q[3] = (s * 0.5); | |
s = 0.5 / s; | |
Q[0] = ((R.at<double>(2,1) - R.at<double>(1,2)) * s); |
// | |
// Compile for emscripten using | |
// emcc -Iinclude SingleFileOpenGLTex.cpp \ | |
-O2 -std=c++14 -s TOTAL_MEMORY=33554432 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --preload-file examples/data -s USE_SDL=2 -o html/SingleFileOpenGLTex.html | |
// where the following images must be located in a subfolder | |
// - examples/data/test.png | |
// - examples/data/cartman.png | |
// - examples/data/cube-negx.png | |
// - examples/data/cube-negz.png | |
// |
// CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / | |
// Notice the for loops have a hardcoded values for how far they can go (32) | |
// This is a result of WEBGL not allowing while loops. Change the value to what you find appropriate! | |
// CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / CAUTION / / / | |
// | |
// Hopefully this gives you the format for making your own operators such as XOR, NAND, etc. | |
// | |
// Adapted from this thread: | |
// https://scratch.mit.edu/discuss/topic/97026/ |
// BitwiseOperations.glsl | |
const int BIT_COUNT = 8; | |
int modi(int x, int y) { | |
return x - y * (x / y); | |
} | |
int or(int a, int b) { | |
int result = 0; |