Skip to content

Instantly share code, notes, and snippets.

View justinmeiners's full-sized avatar

Justin Meiners justinmeiners

View GitHub Profile
#include <stdint.h>
#include <stdio.h>
#include <memory.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#define DDS_MAGIC 542327876
#define FOUR_CC_DXT1 0x31545844
indent -bl -lp -bap -npsl -l160 -nut -ldi1 -di1 -i4 vec_math.h vec_math3.h
#!/bin/bash
convert lena.tiff test0.jpg
b=4
for i in `seq 1 360`; do
x=$(($i-1))
if [ $(($i%2)) -eq 0 ];
then
b=$((4))
else
#include <iostream>
#include <cmath>
template <class T, class F>
struct double_decorator
{
F func;
double_decorator(F func) : func(func) {}
T operator()(T x)
#include <iostream>
template <typename T>
struct vector
{
constexpr static int DEFAULT_SIZE = 16;
vector()
{
size = 0;
capacity = 0;
@justinmeiners
justinmeiners / lisp.cpp
Last active June 23, 2018 06:05
Incomplete Lisp interpreter. See the one on my github.
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <regex>
#include <ctype.h>
namespace Lisp
{
#include <stdint.h>
#include <stdio.h>
typedef struct
{
float x, y, z;
} Vec3;
typedef struct
(use srfi-1)
; partition(0)
; (null)
; partition(n)
; (n) + part(0)
; (n - 1) + part(1)
; (n - 2) + part(2)
; ...
(define (prime-sieve count)
(let ((marked (make-vector count #f)))
(define (build-list index)
(if (>= index count)
'()
(if (vector-ref marked index)
(build-list (+ index 1))
(cons (+ index 1) (build-list (+ index 1))))))
@justinmeiners
justinmeiners / MultiplyPoint.cs
Last active June 23, 2018 06:12
Difference between MultiplyPoint and MultiplyPoint3x4
// See my SO answer https://stackoverflow.com/questions/35208476/unity3d-difference-between-multiplypoint-and-multiplypoint3x4
// https://github.com/jameslinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/Matrix4x4.cs
public Vector3 MultiplyPoint(Vector3 v)
{
Vector3 vector3;
vector3.x = ( m00 * v.x + m01 * v.y + m02 * v.z) + m03;
vector3.y = ( m10 * v.x + m11 * v.y + m12 * v.z) + m13;
vector3.z = ( m20 * v.x + m21 * v.y + m22 * v.z) + m23;
float num = 1f / ( ( m30 * v.x + m31 * v.y + m32 * v.z) + m33);
vector3.x *= num;