/** * @(#) $RCSfile: Attractor4DPull.as,v $ $Revision: 1.2 $ $Date: 2003/03/17 22:53:05 $ * * Copyright 2003 Orgdot AS. All Rights Reserved. * http://dev.swfit.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * Compute the pull from an attractor on this particle. * * @author Olaf Havnes * @version $Revision: 1.2 $ $Date: 2003/03/17 22:53:05 $ * @since SWFIT1.0 */ dx = _parent.ax - px; dy = _parent.ay - py; dz = _parent.az - pz; dq = _parent.aq - pq; // Eliminate the 4th dimension dq = 0; a_len_sq = dx * dx + dy * dy + dz * dz + dq * dq; //a_len = (a_len + a_len_sq / a_len) / 2; //a_f = _parent.pull / (a_len * a_len_sq); a_f = _parent.pull / a_len_sq; /** * The force is F = Constant / a_len_sq along the vector (dx, dy, dz, dq) / a_len */ vx += a_f * dx; vy += a_f * dy; vz += a_f * dz; vq += a_f * dq; px += vx; py += vy; pz += vz; pq += vq;