Skip to content

Instantly share code, notes, and snippets.

View ClickerMonkey's full-sized avatar
💭
VPLs, ORMs, and Bag End

Philip Diffenderfer ClickerMonkey

💭
VPLs, ORMs, and Bag End
View GitHub Profile
@ClickerMonkey
ClickerMonkey / Intlerp.java
Created August 30, 2014 00:56
Interpolation between two integers taking N moves without using floats and avoiding division and modulus.
package org.magnos.path;
import static org.junit.Assert.*;
import org.junit.Test;
public class TestIntlerp
{
public class Intlerp
@ClickerMonkey
ClickerMonkey / Shuffle.java
Created September 2, 2014 15:27
Class used to iterate N items as if they were shuffled.
public class Shuffle
{
public int n;
public int[] index;
public long seed;
public Shuffle( int size )
{
this( System.currentTimeMillis(), size );
@ClickerMonkey
ClickerMonkey / Veclerp.java
Created September 2, 2014 15:34
Interpolation between two points on a grid. The resulting points from iteration can be imagined as hitting all pixels on a screen that intersect a line that's drawn from any pixel to any pixel on the screen.
public class Veclerp
{
public int x, y;
private int x_inc, y_inc, dx, dy, error, n;
public void start( int x0, int y0, int x1, int y1 )
{
dx = Math.abs( x1 - x0 );
dy = Math.abs( y1 - y0 );
@ClickerMonkey
ClickerMonkey / Elongate.java
Last active August 29, 2015 14:08
Transforms Java code to be as many lines as possible.
import java.util.Scanner;
public class Elongate
{
public static void main( String[] args )
{
Scanner in = new Scanner( System.in );
StringBuilder code = new StringBuilder();
while (in.hasNextLine())
@ClickerMonkey
ClickerMonkey / Sqrt.java
Last active July 3, 2022 17:57
1/Sqrt VS Fast Inverse Sqrt
import java.nio.ByteBuffer;
public class Sqrt
{
private static float invsqrt0(float x)
{
return 1.0f / (float)Math.sqrt( x );
}
@ClickerMonkey
ClickerMonkey / StringTemplate.java
Last active August 29, 2015 14:08
A simple string templating utility.
public class StringTemplate
{
public static final String DEFAULT_START = "{";
public static final String DEFAULT_END = "}";
private String[] chunks;
public StringTemplate( String text )
{
@ClickerMonkey
ClickerMonkey / Wikipedia.java
Last active August 29, 2015 14:08
Gathers information about all articles on Wikipedia and builds a graph of all related articles.
public class Wikipedia
{
public static class Article implements Serializable {
private static final long serialVersionUID = 1L;
public int id;
public String title;
public Set<String> related = new HashSet<String>();
}
@ClickerMonkey
ClickerMonkey / CircleCircle.java
Created October 29, 2014 15:07
Priori intersection algorithms for circles, rectangles, and planes.
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
@ClickerMonkey
ClickerMonkey / CollisionResolution.java
Created October 29, 2014 15:09
Collision resolution visualization
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.Arrays;
import java.util.List;
@ClickerMonkey
ClickerMonkey / Matching.java
Created October 29, 2014 15:10
A shape & color matching game for kids.
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.event.KeyEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;