📄 mathextensions.java
字号:
package org.jgraph.utils;
import java.awt.geom.Point2D;
/**
* @author winkler
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public abstract class MathExtensions {
/******************************************************************************/
/**
* Extracts the leading sign of x.
*
* @param x Any double value.
* @return If x has a positive value <code>-1.0</code>, for <code>x = 0.0</code>
* here comes <code>0.0</code> and if x has a negative the method returns
* <code>-1.0</code>.
*/
public static double sgn(double x){
if( x < 0.0 ) {
return -1.0;
}
else if( x > 0.0 ){
return 1.0;
}
else {
return 0.0;
}
}
/******************************************************************************/
/**
* Computes the absolute value of <code>v</code>. Assuming <code>v</code>
* is a mathematical Vector, pointing from Point Zero to the Point, represented
* by <code>x</code> and <code>y</code> in v, then this method returns the
* length of v.
* <p><blockquote><blockquote><code>
* return sqrt( v.x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -