package com.haxademic.core.draw.shapes;

import processing.core.PApplet;
import processing.core.PVector;

import com.haxademic.core.app.P;

public class BoxBetween {
	
	protected static PVector pointMid = new PVector();
	protected static PVector rotationDir = new PVector();
	
	/**
	 * Draw a box between (2) 3d points. Original code from Dave Bollinger.
	 * @param p
	 * @param point1
	 * @param point2
	 * @param thickness
	 */
	public static void draw( PApplet p, PVector point1, PVector point2, float thickness ) {
		if( point1 == null || point2 == null ) return; 
			
		// reuse halfway vector and find the midpoint
		pointMid.set( point1.x, point1.y, point1.z );
		pointMid.lerp( point2, 0.5f );

		// use to perform orientation to velocity vector
		PVector.sub( point1, point2, rotationDir );
		float r = P.sqrt( rotationDir.x * rotationDir.x + rotationDir.y * rotationDir.y + rotationDir.z * rotationDir.z );
		float theta = P.atan2(rotationDir.y, rotationDir.x);
		float phi = P.acos(rotationDir.z / r);

		// update location
		p.pushMatrix();
		p.translate( pointMid.x, pointMid.y, pointMid.z );
		
		// set draw context orientation 
		p.rotateZ(theta);
		p.rotateY(phi);
		p.rotateX(P.HALF_PI);

		// draw box
		p.box( thickness, point1.dist(point2), thickness );

		p.popMatrix(); 
	}
}

@@ -34,16 +34,50 @@
 hapes;%0A%0A
+import com.haxademic.core.app.P;%0A%0A
 import p
@@ -128,48 +128,48 @@
 re.P
-Vector;%0A%0Aimport com.haxademic.core.app.P
+Graphics;%0Aimport processing.core.PVector
 ;%0A%0Ap
@@ -546,16 +546,152 @@
 ess ) %7B%0A
+%09%09draw(p.g, point1, point2, thickness);%0A%09%7D%0A%09%0A%09public static void draw( PGraphics p, PVector point1, PVector point2, float thickness ) %7B%0A
 %09%09if( po

Add PGraphics mask method