<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package curveavg;

import processing.core.*;
import processing.event.*;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import static curveavg.Pv3D.*;
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;

/**
 *
 * @author <NAME>
 */
public class CurveAverage extends PApplet {

	public static final float SCALE = 50;
	private static final float PICK_TOLERANCE = 20;
	public static final float DEG_TO_RAD = PI / 180.0f;
	private static final float FPS = 60;
	private static final int CURVE_INTERPOLATION_SAMPLES = 32;
	private static final int CURVE_CYLINDER_SAMPLES = 8;
	private static final float CURVE_CYLINDER_RADIUS = 0.15f*SCALE;

	private float dz = 0; // distance to camera. Manipulated with wheel or when 
//float rx=-0.06*TWO_PI, ry=-0.04*TWO_PI;    // view angles manipulated when space pressed but not mouse
	private float rx = 0, ry = 0;    // view angles manipulated when space pressed but not mouse
	private  boolean animating = false, tracking = false, center = true, gouraud = true;
	private boolean interpolateControlCurve = true;
	private boolean equispacedInterpolation = true;
	private boolean viewpoint = false;
	private PImage myFace;
	private boolean filming = false, takePicture = false;
	private boolean change = false;
	private int frameCounter = 0;
	private int pictureCounter = 0;
	
	private long time1, time2;
	private float tpf;
	
	private int pickedPoint = 0;
	private Vector3f[] controlPoints;
	private Vector3f[] curveA, curveB;
        public Vector3f[] debugPoints;             ///< Some useful points that we can drag around 
	boolean recalculateCurve = false;
	private Vector3f[] samplesA, samplesB;

	String title = "6491 P3 2015: Curve Average", name = "<NAME>, <NAME>",
			menu = "!:picture, ~:(start/stop)capture, space:rotate, "
			+ "s/wheel:closer, a:anim, i:interpolate control curve, e:equispaced interpolation, #:quit",
			guide = "click'n'drag center of frames or arrow tips to change the start frame (green) and end frame (red)"; // user's guide

	public static void main(String[] args) {
		PApplet.main(CurveAverage.class.getName());
	}
	
	public void settings() {
		size(900, 900, P3D); // p3D means that we will do 3D graphics
		noSmooth();
	}

	public void setup() {
		frameRate(FPS);
		
		myFace = loadImage("data/pic.jpg");  // load image from file pic.jpg in folder data *** replace that file with your pic of your own face
		textureMode(NORMAL);
		
		//example curve
		controlPoints = new Vector3f[] {
			new Vector3f(-50, -30, -70), //start
			new Vector3f(-60, 10, -40),
			new Vector3f(-70, 12, -6),
			new Vector3f(0, 50, 60),
			new Vector3f(80, 45, 140),
			new Vector3f(150, 80, 200), //end
			new Vector3f(140, 90, 160),
			new Vector3f(100, 37, 100),
			new Vector3f(50, 39, 40),
                        new Vector3f(17.307629f, 0.0f, -47.95851f)
//			new Vector3f(0, 15, -20)
		};
                for(int i = 0; i < controlPoints.length; i++)
                    controlPoints[i].y = 0.0f;
                
		curveA = new Vector3f[controlPoints.length / 2 + 1];
		curveB = new Vector3f[controlPoints.length / 2 + 1];
		for (int i=0; i<curveA.length; ++i) {
			curveA[i] = controlPoints[i];
		}
		curveB[0] = controlPoints[0];
		for (int i=1; i<curveB.length; ++i) {
			curveB[i] = controlPoints[controlPoints.length - i];
		}
		recalculateCurve = true;

		rx+=0.0001f;
		ry+=0.0001f;
		
		time1 = System.currentTimeMillis();
		time2 = System.currentTimeMillis();
                <commit_msg>Seem to work for 3D as well. Note that can change to 2D after definition of control points. Next: Work on edge cases that Sebastian points out<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package curveavg;

import processing.core.*;
import processing.event.*;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import static curveavg.Pv3D.*;
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;

/**
 *
 * @author <NAME>
 */
public class CurveAverage extends PApplet {

	public static final float SCALE = 50;
	private static final float PICK_TOLERANCE = 20;
	public static final float DEG_TO_RAD = PI / 180.0f;
	private static final float FPS = 60;
	private static final int CURVE_INTERPOLATION_SAMPLES = 32;
	private static final int CURVE_CYLINDER_SAMPLES = 8;
	private static final float CURVE_CYLINDER_RADIUS = 0.15f*SCALE;

	private float dz = 0; // distance to camera. Manipulated with wheel or when 
//float rx=-0.06*TWO_PI, ry=-0.04*TWO_PI;    // view angles manipulated when space pressed but not mouse
	private float rx = 0, ry = 0;    // view angles manipulated when space pressed but not mouse
	private  boolean animating = false, tracking = false, center = true, gouraud = true;
	private boolean interpolateControlCurve = true;
	private boolean equispacedInterpolation = true;
	private boolean viewpoint = false;
	private PImage myFace;
	private boolean filming = false, takePicture = false;
	private boolean change = false;
	private int frameCounter = 0;
	private int pictureCounter = 0;
	
	private long time1, time2;
	private float tpf;
	
	private int pickedPoint = 0;
	private Vector3f[] controlPoints;
	private Vector3f[] curveA, curveB;
        public Vector3f[] debugPoints;             ///< Some useful points that we can drag around 
	boolean recalculateCurve = false;
	private Vector3f[] samplesA, samplesB;

	String title = "6491 P3 2015: Curve Average", name = "<NAME>, <NAME>",
			menu = "!:picture, ~:(start/stop)capture, space:rotate, "
			+ "s/wheel:closer, a:anim, i:interpolate control curve, e:equispaced interpolation, #:quit",
			guide = "click'n'drag center of frames or arrow tips to change the start frame (green) and end frame (red)"; // user's guide

	public static void main(String[] args) {
		PApplet.main(CurveAverage.class.getName());
	}
	
	public void settings() {
		size(900, 900, P3D); // p3D means that we will do 3D graphics
		noSmooth();
	}

	public void setup() {
		frameRate(FPS);
		
		myFace = loadImage("data/pic.jpg");  // load image from file pic.jpg in folder data *** replace that file with your pic of your own face
		textureMode(NORMAL);
		
		//example curve
		controlPoints = new Vector3f[] {
			new Vector3f(-50, -30, -70), //start
			new Vector3f(-60, 10, -40),
			new Vector3f(-70, 12, -6),
			new Vector3f(0, 50, 60),
			new Vector3f(80, 45, 140),
			new Vector3f(150, 80, 200), //end
			new Vector3f(140, 90, 160),
			new Vector3f(100, 37, 100),
			new Vector3f(50, 39, 40),
//                        new Vector3f(17.307629f, 0.0f, -47.95851f)
			new Vector3f(0, 15, -20)
		};
//                for(int i = 0; i < controlPoints.length; i++) controlPoints[i].y = 0.0f;
                
		curveA = new Vector3f[controlPoints.length / 2 + 1];
		curveB = new Vector3f[controlPoints.length / 2 + 1];
		for (int i=0; i<curveA.length; ++i) {
			curveA[i] = controlPoints[i];
		}
		curveB[0] = controlPoints[0];
		for (int i=1; i<curveB.length; ++i) {
			curveB[i] = controlPoints[controlPoints.length - i];
		}
		recalculateCurve = true;

		rx+=0.0001f;
		ry+=0.0001f;
		
		time1 = System.currentTimeMillis();
		time2 = System.currentTimeMillis();
                
{'fraction_non_alphanumeric': 0.11395018712091882, 'fraction_numerical': 0.04542521615692347, 'mean_word_length': 3.5295149035651665, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1857787', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2498, 'n_words': 818}