本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.NEGATIVE_COMPLEX_MODULE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.NEGATIVE_COMPLEX_MODULE属性的具体用法?Java LocalizedFormats.NEGATIVE_COMPLEX_MODULE怎么用?Java LocalizedFormats.NEGATIVE_COMPLEX_MODULE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.NEGATIVE_COMPLEX_MODULE属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: polar2Complex
/**
* Creates a complex number from the given polar representation.
* <p>
* The value returned is <code>r·e<sup>i·theta</sup></code>,
* computed as <code>r·cos(theta) + r·sin(theta)i</code></p>
* <p>
* If either <code>r</code> or <code>theta</code> is NaN, or
* <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
* <p>
* If <code>r</code> is infinite and <code>theta</code> is finite,
* infinite or NaN values may be returned in parts of the result, following
* the rules for double arithmetic.<pre>
* Examples:
* <code>
* polar2Complex(INFINITY, π/4) = INFINITY + INFINITY i
* polar2Complex(INFINITY, 0) = INFINITY + NaN i
* polar2Complex(INFINITY, -π/4) = INFINITY - INFINITY i
* polar2Complex(INFINITY, 5π/4) = -INFINITY - INFINITY i </code></pre></p>
*
* @param r the modulus of the complex number to create
* @param theta the argument of the complex number to create
* @return <code>r·e<sup>i·theta</sup></code>
* @throws MathIllegalArgumentException if {@code r} is negative.
* @since 1.1
*/
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
if (r < 0) {
throw new MathIllegalArgumentException(
LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
}
return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}