This file contains hidden or 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
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.sparse as sparse | |
import scipy.sparse.linalg | |
xs = [25.0, 50.0, 60.0] | |
ys = [ 1.0, -1.0, 0.3] |
This file contains hidden or 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
''' | |
An example of having a function being called regularly | |
while still processing user input | |
''' | |
import threading | |
# the regular event | |
timer = None |
This file contains hidden or 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
// why does makeTransform1 give the same results as makeTransform2? | |
mat3 rotationMatrix(float angle, vec3 axis) { | |
... // returns a 3x3 rotation matrix for rotating about the given axis | |
} | |
mat3 makeTransform1(float alpha, float beta, float gamma) { | |
mat3 alphaTransform = rotationMatrix(alpha, vec3(0.0, 1.0, 0.0)); | |
mat3 betaTransform = rotationMatrix(beta, vec3(1.0, 0.0, 0.0)); |
This file contains hidden or 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
// curtesy of https://github.com/DavidSaxon and http://www.parashift.com/c++-faq-lite/ | |
#include <iostream> | |
// this function will be called by the base class | |
void baseFunction() { | |
std::cout << "Base Class!" << std::endl; | |
} |
This file contains hidden or 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
// adapted from intersectCube in https://github.com/evanw/webgl-path-tracing/blob/master/webgl-path-tracing.js | |
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method | |
// no intersection means vec.x > vec.y (really tNear > tFar) | |
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) { | |
vec3 tMin = (boxMin - rayOrigin) / rayDir; | |
vec3 tMax = (boxMax - rayOrigin) / rayDir; | |
vec3 t1 = min(tMin, tMax); | |
vec3 t2 = max(tMin, tMax); | |
float tNear = max(max(t1.x, t1.y), t1.z); |
This file contains hidden or 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
# a recursive function that produces big numbers. What is the time complexity of this? | |
def up(a, b, depth): | |
if depth == 0: | |
return a*b # assume this takes one unit of time | |
out = 1 | |
for i in xrange(b): # repeat the following b times | |
out = up(a, out, depth-1) | |
return out |
This file contains hidden or 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
# a recursive function that produces big numbers. What is the time complexity of this? | |
def big(a, b, depth): | |
if depth == 0: | |
return a*b # assume this takes one unit of time | |
out = 1 | |
for i in xrange(b): # repeat the following b times | |
out = big(a, out, depth-1) | |
return out |
This file contains hidden or 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
import numpy as np | |
''' | |
Solves matrix M in the following equation given matricies A and B: | |
MA = B | |
A.shape == B.shape == (m, n) | |
M.shape = (n, n) | |
This file contains hidden or 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
from datetime import datetime, timedelta | |
import os | |
import traceback | |
# This code is called when instances of this SOP cook. | |
node = hou.pwd() | |
geo = node.geometry() | |
myLocals = { |
This file contains hidden or 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
actions = { | |
(False, False) : lambda x: x, | |
(True, False) : lambda x: "fizz", | |
(False, True ) : lambda x: "buzz", | |
(True, True ) : lambda x: "fizzBuzz", | |
} | |
print '\n'.join([ actions[x%3==0, x%5==0](x) for x in xrange(1,101) ]) |