<commit_before>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package org.pathvisio.view;

/**
 * Helper class for rotation calculations.
 *
 */
public class LinAlg 
{
	
	/**
	 * Determines angle between two vectors defined by p1 and p2 
	 * Both vectors start at 0.0
	 * 
	 * @param p1 start point of vector
	 * @param p2 end point of vector
	 * @return angle in radians
	 */
	public static double angle(Point p1, Point p2) 
	{
		//Angle:
		//					p1.p2	
        //cos(angle) = --------------
        //          	||p1||*||p2||
		double cos = dot(p1,p2) / (p1.len() * p2.len());
		return direction(p1,p2) * Math.acos(cos);
	}
		
	/**
	 * negative: ccw positive: cw
	 */
	public static double direction(Point p1, Point p2) 
	{
		return Math.signum(p1.x * p2.y - p1.y * p2.x);
	}<commit_msg>patch from <NAME>: - fixed bug in angle calculation (returned NaN for zero angle)<commit_after>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package org.pathvisio.view;

/**
 * Helper class for rotation calculations.
 *
 */
public class LinAlg 
{
	
	/**
	 * Determines angle between two vectors defined by p1 and p2 
	 * Both vectors start at 0.0
	 * 
	 * @param p1 start point of vector
	 * @param p2 end point of vector
	 * @return angle in radians
	 */
	public static double angle(Point p1, Point p2) 
	{
		//Angle:
		//					p1.p2	
        //cos(angle) = --------------
        //          	||p1||*||p2||

		double cos = dot(p1,p2) / (p1.len() * p2.len());
		if(cos>1)
		{
			cos=1;
		}
		return direction(p1,p2) * Math.acos(cos);
	}
		
	/**
	 * negative: ccw positive: cw
	 */
	public static double direction(Point p1, Point p2) 
	{
		
		return Math.signum(p1.x * p2.y - p1.y * p2.x);
	}
{'fraction_non_alphanumeric': 0.12223710649698594, 'fraction_numerical': 0.02478231748158071, 'mean_word_length': 2.6338199513381997, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2352169', 'n_tokens_mistral': 1015, 'n_tokens_neox': 924, 'n_words': 354}