Skip to content

Instantly share code, notes, and snippets.

View Xorgon's full-sized avatar

Elijah Andrews Xorgon

View GitHub Profile
@Xorgon
Xorgon / eigenvalues.py
Created March 14, 2017 14:23
Solving an eigenvalue problem in Python.
import numpy as np
matrix = np.array([[0., 0.16, 0., -9.81],
[-0.1250, -0.5, 212., 0.],
[0., -0.0082, -0.5, 0.],
[0., 0., 1., 0.]])
print("Matrix:\n" + str(matrix))
# Get the eigenvalues (eig returns tuple with eigenvalues and eigenvectors)
Matrix:
[[ 0.00000000e+00 1.60000000e-01 0.00000000e+00 -9.81000000e+00]
[ -1.25000000e-01 -5.00000000e-01 2.12000000e+02 0.00000000e+00]
[ 0.00000000e+00 -8.20000000e-03 -5.00000000e-01 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00]]
Eigenvalues:
(-0.498753770359+1.32368162214j)
(-0.498753770359-1.32368162214j)
(-0.00124622964121+0.0708790500223j)
@Xorgon
Xorgon / MSP_ATTITUDE.ino
Created March 18, 2017 16:23
An Arduino sketch for getting attitude data from a flight controller using MSP.
#include <SoftwareSerial.h>
#define MSP_ATTITUDE 108
SoftwareSerial mspSerial(11, 12); // RX TX
void setup() {
mspSerial.begin(9600);
Serial.begin(9600);
}
@Xorgon
Xorgon / redistribution_solver.py
Created June 27, 2017 00:09
Calculates coefficients for an equation to redistribute a random distribution between 0 and 1.
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 26 21:05:22 2017
@author: Xorgon
"""
import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt
@Xorgon
Xorgon / Sudoku Deserializer
Created September 5, 2017 22:34
Deserializer for Sudoku
import numpy as np
def deserialize_sudoku(serialized):
"""
a b c d e f g h i
j k l . . . . . .
. . . . . . . . .
would be from
abcdefghijkl...
"""
cmake_minimum_required(VERSION 3.7)
project(DEMOranges)
set(CMAKE_CXX_STANDARD 11)
# Fix Windows path environment variable.
if (WIN32)
STRING(REGEX REPLACE "\\\\" "/" OCL_ROOT $ENV{OCL_ROOT})
endif(WIN32)
# Set required OpenCL CMake build options.
@Xorgon
Xorgon / pen.py
Last active August 9, 2018 17:10
How classes work in terms of pens
class Pen:
color = None
ink_level = None
active = True
def __init__(self, color="black", ink_level=1000):
self.color = color
self.ink_level = ink_level
def __str__(self):