Skip to content

Instantly share code, notes, and snippets.

View sherbondy's full-sized avatar

Ethan Sherbondy sherbondy

View GitHub Profile
@sherbondy
sherbondy / core.clj
Last active December 22, 2015 05:39
Ran into an issue using the latest version of core.typed (0.1.26) with a simple defrecord
(ns rt.core
(:refer-clojure :exclude [+ - * /])
(:require [clojure.core.typed :as typed
:refer [ann ann-datatype ann-form ann-record check-ns]])
(:require [clojure.algo.generic.arithmetic :as arith :refer [+ - * /]]))
(ann-record Vec3 [x :- Number y :- Number z :- Number])
(defrecord Vec3 [x y z])
(def a (Vec3. 1 2 3))
// From ElementADPK2:
virtual void computeSecondPiolaKirchhoff(Vec3DiffMatrix3x3 &matS, const Vec3DiffMatrix3x3 &matF, const MaterialParams &matParams) const {
//*****************ASSIGNMENT 4 START HERE ***********************
//Compute Strain
// Vec3DiffMatrix3x3 matE =
//Compute Second Piola Kirchoff Stress (S)
// matS =
// matF is the deformation matrix
abstract class OpVar
case class RegVar(val varName:String) extends OpVar {
var _register = 0
def register = {
"%r" + _register
}
def register_=(reg: Int) = {
_register = reg
}
@sherbondy
sherbondy / a4.cxx
Last active December 17, 2015 02:19
Baby's first FEM simulation
// Need to compute:
//*************************ASSIGNMENT 4 START HERE*******************
matd = Vec3DiffMatrix3x3::createFromColumnVectors(xEl[1] - xEl[0], xEl[2] - xEl[0], xEl[3] - xEl[0]);
//Compute the deformation gradient F = d*D^{-1}
matF = matd * matDInv();
//Get the second Piola Kirchoff stress from your element
//Place the value in matS
///@TODO draw scanline here
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glVertex3f(imgNum, 0, 0.1);
glVertex3f(imgNum, resy, 0.1);
glVertex3f(imgNum+1, resy, 0.1);
glVertex3f(imgNum+1, 0, 0.1);
glEnd();
///@TODO draw scanline here
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glVertex3f(imgNum, 0, 0.1);
glVertex3f(imgNum, resy, 0.1);
glVertex3f(imgNum+1, resy, 0.1);
glVertex3f(imgNum+1, 0, 0.1);
glEnd();
class ColorsController < UIViewController
def viewDidLoad
super
self.view.backgroundColor = UIColor.whiteColor
@label = UILabel.alloc.initWithFrame(CGRectZero)
@label.text = "Colors"
@label.sizeToFit
@label.center = [
@sherbondy
sherbondy / ubuntu-mba.sh
Created October 28, 2012 00:46
Ubuntu 12.10 on 2012 MacBook Air 5.2
# I am currently using http://refit.sourceforge.net/ as my boot menu.
# Mac OS is installed on a tiny partition.
# I was able to create a USB stick with 12.10 using these instructions:
# https://help.ubuntu.com/community/How%20to%20install%20Ubuntu%20on%20MacBook%20using%20USB%20Stick
# By restarting and holding option, I was able to boot into the Ubuntu installer
# (no refit needed for this step).
# The installation process went hitch-free.
# But after installation, the graphics card (Intel HD4000) was not recognized.
# So I did the following:
@sherbondy
sherbondy / assignment3.scm
Created October 1, 2012 08:26
Assignment 3
;; Ethan Sherbondy
;; 6.946, Fall 2012
;; Project Exercise 1.39
;; The Double Pendulum
(define ((L-rect-pend m1 m2 g) local)
(let ((q (coordinate local))
(v (velocity local)))
(let* ((v1 (ref v 0))
@sherbondy
sherbondy / pset1.scm
Created September 14, 2012 04:12
6.946 pset1
(define ((parametric-path-action Lagrangian t0 q0 t1 q1) qs)
(let ((path (make-path t0 q0 t1 q1 qs)))
(Lagrangian-action Lagrangian path t0 t1)))
; canned multi-dimensional minimization
; used to find approximate solution path
(define (find-path Lagrangian t0 q0 t1 q1 n)
(let ((initial-qs (linear-interpolants q0 q1 n)))
(let ((minimizing-qs
(multidimensional-minimize