
org.joml.sampling.Math Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joml Show documentation
Show all versions of joml Show documentation
Java OpenGL Math Library
The newest version!
/*
* The MIT License
*
* Copyright (c) 2016-2024 JOML
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.joml.sampling;
/**
* Internal Math class used by the sampling package.
*
* @author Kai Burjack
*/
class Math extends org.joml.Math {
static final double PI = java.lang.Math.PI;
static final double PI2 = PI * 2.0;
static final double PIHalf = PI * 0.5;
private static final double ONE_OVER_PI = 1.0 / PI;
private static final double s5 = Double.longBitsToDouble(4523227044276562163L);
private static final double s4 = Double.longBitsToDouble(-4671934770969572232L);
private static final double s3 = Double.longBitsToDouble(4575957211482072852L);
private static final double s2 = Double.longBitsToDouble(-4628199223918090387L);
private static final double s1 = Double.longBitsToDouble(4607182418589157889L);
/**
* Reference: http://www.java-gaming.org/
*
* @author roquendm
*/
static double sin_roquen_9(double v) {
double i = java.lang.Math.rint(v * ONE_OVER_PI);
double x = v - i * Math.PI;
double qs = 1 - 2 * ((int) i & 1);
double x2 = x * x;
double r;
x = qs * x;
r = s5;
r = r * x2 + s4;
r = r * x2 + s3;
r = r * x2 + s2;
r = r * x2 + s1;
return x * r;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy