<commit_before>package object;

import jboxGlue.PhysicalObjectRect;
import jgame.JGColor;

public class Spring extends PhysicalObjectRect{

	Mass mass1;
	Mass mass2;
	double restLength;
	double currentLength;
	double k;
	double dx;
	double dy;
	
	public Spring(String id, int collisionId, JGColor color, Mass mass1, Mass mass2, double length, double k) {
		super(id, collisionId, color, 0, 0, 0);
		this.mass1 = mass1;
		this.mass2 = mass2;
		this.restLength = length;
		this.currentLength = length;
		this.k = k;
	}
	
	public Spring(String id, int collisionId, JGColor color, Mass mass1, Mass mass2, double length) {
            super(id, collisionId, color, 0, 0, 0);
            this.mass1 = mass1;
            this.mass2 = mass2;
            this.restLength = length;
            if (length==0){
                restLength=Math.sqrt(Math.pow((this.mass1.x-this.mass2.x),2)+ Math.pow((this.mass1.y-this.mass2.y),2));
                System.out.println(restLength);
            }
            this.currentLength = length;
            this.k = 1;
        }
	
	public void move( ){
	        setLength();
		springMove();
	}
	
	public void springMove(){
	    dx = mass2.x - mass1.x;
	    dy = mass2.y - mass1.y;              
	       
	        
	    double force = k*(currentLength-restLength);
	                
	    mass1.setForce(dx*force, dy*force);
	    mass2.setForce(-dx*force, -dy*force);
	    
	    
//	    System.out.println("calling springMove force: " + force + " dx: " + dx + " dy: " + dy);
	}
	
	public void setLength(){
            currentLength = Math.sqrt(Math.pow((mass2.x-mass1.x),2) + Math.pow((mass2.y-mass1.y),2));<commit_msg>More uncertainty about spring distances<commit_after>package object;

import jboxGlue.PhysicalObjectRect;
import jgame.JGColor;

public class Spring extends PhysicalObjectRect{

	Mass mass1;
	Mass mass2;
	double restLength;
	double currentLength;
	double k;
	double dx;
	double dy;
	
	public Spring(String id, int collisionId, JGColor color, Mass mass1, Mass mass2, double length, double k) {
		super(id, collisionId, color, 0, 0, 0);
		this.mass1 = mass1;
		this.mass2 = mass2;
		this.restLength = length;
		if (length==0){
	                restLength=calculateActualDistance();
	                System.out.println(restLength);
	            }
		this.currentLength = length; //Should this be actual distance between masses?
		this.k = k;
	}
	
	public double calculateActualDistance(){
	    return Math.sqrt(Math.pow((mass1.x-mass2.x),2)+ Math.pow((mass1.y-mass2.y),2));
	}
	
	public Spring(String id, int collisionId, JGColor color, Mass mass1, Mass mass2, double length) {
            super(id, collisionId, color, 0, 0, 0);
            this.mass1 = mass1;
            this.mass2 = mass2;
            this.restLength = length;
            if (length==0){
                restLength=calculateActualDistance();
                System.out.println(restLength);
            }
            this.currentLength = length;
            this.k = 1;
        }
	
	public void move( ){
	        setLength();
		springMove();
	}
	
	public void springMove(){
	    dx = mass2.x - mass1.x;
	    dy = mass2.y - mass1.y;              
	       
	        
	    double force = k*(currentLength-restLength);
	                
	    mass1.setForce(dx*force, dy*force);
	    mass2.setForce(-dx*force, -dy*force);
	    
	    
//	    System.out.println("calling springMove force: " + force + " dx: " + dx + " dy: " + dy);
	}
	
	public void setLength(){
            currentLength = Math.sqrt(Math.pow((mass2.x-mass1.x),2) + Math.pow((mass2.y-mass1.y),2));
{'fraction_non_alphanumeric': 0.12584080717488788, 'fraction_numerical': 0.022701793721973094, 'mean_word_length': 2.289400921658986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6575818', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1145, 'n_words': 269}