From ffb4b60ea2847464c8492419a6499c48d1e5c873 Mon Sep 17 00:00:00 2001 From: Shaheen Gandhi Date: Sun, 18 Aug 2013 16:17:29 -0700 Subject: [PATCH] [Helix] Fix toroidal coil calculation --- ShaheenGandhi.pde | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); } } -- 2.34.1