From: Shaheen Gandhi Date: Sun, 18 Aug 2013 23:17:29 +0000 (-0700) Subject: [Helix] Fix toroidal coil calculation X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=ffb4b60ea2847464c8492419a6499c48d1e5c873 [Helix] Fix toroidal coil calculation --- diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde index c25badd..a842fcf 100644 --- a/ShaheenGandhi.pde +++ b/ShaheenGandhi.pde @@ -42,10 +42,11 @@ class HelixPattern extends SCPattern { PVector rotatePoint(final PVector pt, final float rads) { Vec3D axisVec3D = new Vec3D(vector.x, vector.y, vector.z); - Matrix4x4 mat = new Matrix4x4(); - mat.rotateAroundAxis(axisVec3D, rads); - Vec3D ptVec3D = new Vec3D(pt.x, pt.y, pt.z); - Vec3D rotatedPt = mat.applyTo(ptVec3D); + Vec3D originVec3D = new Vec3D(origin.x, origin.y, origin.z); + Matrix4x4 mat = new Matrix4x4().identity() + .rotateAroundAxis(axisVec3D, rads); + Vec3D ptVec3D = new Vec3D(pt.x, pt.y, pt.z).sub(originVec3D); + Vec3D rotatedPt = mat.applyTo(ptVec3D).add(originVec3D); return new PVector(rotatedPt.x, rotatedPt.y, rotatedPt.z); } }