<commit_before>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.beh.phy;

import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.jtrfp.trcl.AttribAnimator;
import org.jtrfp.trcl.IndirectDouble;
import org.jtrfp.trcl.Sequencer;
import org.jtrfp.trcl.beh.Behavior;

public class RotatingObjectBehavior extends Behavior
	{
	private final IndirectDouble angle = new IndirectDouble();
	private final Sequencer seq;
	private final AttribAnimator angleAnimator;
	private final Vector3D rotationAxisTop,originalHeading,originalTop;
	
	public RotatingObjectBehavior(Vector3D rotationAxisTop, Vector3D originalHeading, Vector3D originalTop, int periodLengthMsec, double phaseShift)
		{
		seq=new Sequencer(periodLengthMsec,2,true);
		angleAnimator= new AttribAnimator(angle,seq,new double [] {0+phaseShift,2.*Math.PI+phaseShift},false);
		this.rotationAxisTop=rotationAxisTop;
		this.originalHeading=originalHeading;
		this.originalTop=originalTop;
		}
	
	@Override
	protected void _tick(long tickTimeInMillis)
		{
		angleAnimator.updateAnimation();
		super.getParent().setTop(new Rotation(rotationAxisTop,angle.get()).applyTo(originalTop));
		super.getParent().setHeading(new Rotation(rotationAxisTop,angle.get()).applyTo(originalHeading));
		}

	}//end RotatingObjectBehavior
<commit_msg>Add reverse support to RotatingObjectBehavior.<commit_after>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.beh.phy;

import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.jtrfp.trcl.AttribAnimator;
import org.jtrfp.trcl.IndirectDouble;
import org.jtrfp.trcl.Sequencer;
import org.jtrfp.trcl.beh.Behavior;

public class RotatingObjectBehavior extends Behavior
	{
	private final IndirectDouble angle = new IndirectDouble();
	private final Sequencer seq;
	private final AttribAnimator angleAnimator;
	private final Vector3D rotationAxisTop,originalHeading,originalTop;
	
	public RotatingObjectBehavior(Vector3D rotationAxisTop, Vector3D originalHeading, Vector3D originalTop, int periodLengthMsec, double phaseShift)
		{//TODO: Coding style, cleanup
	    	final boolean reverse = periodLengthMsec < 0;
	    	if(reverse)
	    	    periodLengthMsec*=-1;
		seq=new Sequencer(periodLengthMsec,2,true);
		final double [] rotationRange = 
			reverse?
			    new double [] {2.*Math.PI+phaseShift,0+phaseShift}
			:
			    new double [] {0+phaseShift,2.*Math.PI+phaseShift};
		angleAnimator= new AttribAnimator(angle,seq,rotationRange,false);
		this.rotationAxisTop=rotationAxisTop;
		this.originalHeading=originalHeading;
		this.originalTop=originalTop;
		}
	
	@Override
	protected void _tick(long tickTimeInMillis)
		{
		angleAnimator.updateAnimation();
		super.getParent().setTop(new Rotation(rotationAxisTop,angle.get()).applyTo(originalTop));
		super.getParent().setHeading(new Rotation(rotationAxisTop,angle.get()).applyTo(originalHeading));
		}

	}//end RotatingObjectBehavior

{'fraction_non_alphanumeric': 0.16352201257861634, 'fraction_numerical': 0.010643444605708756, 'mean_word_length': 5.914715719063545, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5563089', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1170, 'n_words': 269}