Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<style>
/* Edit this to customize font-size and other font properties */
ul.tree-structure {
font-size: 1em;
font-family: inherit;
}

Default rotation matrix multiply:

(x', y')^T = ((cosθ, -sinθ), (sinθ, cosθ)) * (x, y)^T

(multiplied out)

  • x' = x cosθ - y sinθ
  • y' = x sinθ + y cosθ

Rotation formula around center point:

# create all combinations
p_0 = []
for a in range(10):
for b in range(10):
for c in range(10):
p_0.append([a, b, c])
# hint 1
/BEGIN.*-+([^-]*)-+END/g
@hugabor
hugabor / ChemicalCompoundLexer.js
Created March 23, 2017 01:27
Returns a list of tokens from a string of a chemical compound
const UPPERCASE_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
const LOWERCASE_LETTERS = 'abcdefghijklmnopqrstuvwxyz'.split('')
const DIGITS = '0123456789'.split('')
const WHITESPACE = ' '.split('')
// TOKEN TYPES
const COEFF = 'COEFF'
const ELEM = 'ELEM'
@hugabor
hugabor / NumStringUtil.js
Last active October 11, 2016 19:02
Basic, often-used functions for stringifying positive numbers (in JavaScript)
let fixLength = function(num, length) {
let numStr = "" + num;
if (parseInt(numStr, 10) < 0) return fixLength(0, length);
while (numStr.length < length) {
numStr = "0" + numStr;
}
return numStr;
};
@hugabor
hugabor / NumStringUtil.java
Last active October 11, 2016 19:04
Basic, often-used functions for stringifying positive numbers (in Java)
public final class NumStringUtil {
private NumStringUtil() {}
/**
* If the number string given has length less than the desired length, then
* the string is left-padded with zeroes and returned.
*
* @param numStr string to left-pad with zeroes