当前位置: 首页>>代码示例>>Java>>正文


Java FastMath.sqrtFast方法代码示例

本文整理汇总了Java中com.hackoeur.jglm.support.FastMath.sqrtFast方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.sqrtFast方法的具体用法?Java FastMath.sqrtFast怎么用?Java FastMath.sqrtFast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hackoeur.jglm.support.FastMath的用法示例。


在下文中一共展示了FastMath.sqrtFast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntrancePointDistance

import com.hackoeur.jglm.support.FastMath; //导入方法依赖的package包/类
public float getEntrancePointDistance(Vec3 org, Vec3 ray)
{
    List<Vec3> ps = getIntersectionPoints(org, ray);
    
    if (ps.isEmpty())
    {
        return Float.POSITIVE_INFINITY;
    }
    float cdist = Float.POSITIVE_INFINITY;
    for (int i = 0; i < ps.size(); i++)
    {
        float dist = ps.get(i).subtract(org).getLengthSquared();
        if (dist < cdist)
        {
            cdist = dist;
        }
    }
    return FastMath.sqrtFast(cdist);
}
 
开发者ID:jwfwessels,项目名称:AFK,代码行数:20,代码来源:BBox.java

示例2: testFastSqrt

import com.hackoeur.jglm.support.FastMath; //导入方法依赖的package包/类
@Test
public void testFastSqrt() {
	final float x = 133511f;
       final float fastSqrt = FastMath.sqrtFast(x);
       final float computedSqrt = (float) StrictMath.sqrt(x);
       
       Assert.assertEquals(fastSqrt, computedSqrt, 0.0001f);
}
 
开发者ID:jroyalty,项目名称:jglm,代码行数:9,代码来源:InvSqrtTest.java

示例3: intersectionTesting

import com.hackoeur.jglm.support.FastMath; //导入方法依赖的package包/类
/**
 * This function determines whether entity A will, and has crossed paths
 * with entity B. We make use of the following formulas:
 * <pre>
 * A = a1 - b1
 * B = (a2 - a1) - (b2 - b1)
 * d^2 = A^2 - ((A · B)^2 / B^2)
 * t = (-(A·B) - Sqr((A·B)^2 - B^2 (A^2 - (r(a) + r(b))^2))) / B^2
 * </pre> if B^2 = 0, then either both a and b are: stationary or moving in
 * the same direction at the same speed, and can thus not collide.
 * <p>
 * if d^2 > (r(a) + r(b))^2 - the sum of the entities radii squared. then
 * the entities can never collide on there current trajectories.
 * </p><p>
 * if t is greater or equal to 0, and smaller than 1. Then entities a and b
 * intersect in the current time step.
 * </p>
 *
 * @param a
 * @param b
 * @return
 */
protected boolean intersectionTesting(State a, State b)
{
    Vec3 B = (a.pos.subtract(a.prevPos)).subtract(b.pos.subtract(b.prevPos));
    double bSqr = B.getLengthSquared();
    if (Double.compare(bSqr, 0.0f) == 0)
    {
        return false;
    }
    Vec3 A = a.prevPos.subtract(b.prevPos);
    double aSqr = A.getLengthSquared();
    double rrSqr = ((a.scale.add(b.scale)).getLengthSquared()) / 2;
    double aDotb = (A.dot(B));
    double aDotbSqr = aDotb * aDotb;
    double d2 = aSqr - (aDotbSqr / bSqr);

    if (Double.compare(d2, rrSqr) > 0)
    {
        return false;
    }
    //find fastInv double implimentation
    double t = (-(aDotb) - FastMath.sqrtFast((float) ((aDotbSqr) - bSqr * (aSqr - (rrSqr))))) / bSqr;
    if (Double.compare(t, 0) < 0 || Double.compare(t, 1) >= 0)
    {
        return false;
    }
    return true;
}
 
开发者ID:jwfwessels,项目名称:AFK,代码行数:50,代码来源:ProjectileSystem.java

示例4: getLength

import com.hackoeur.jglm.support.FastMath; //导入方法依赖的package包/类
@Override
public final float getLength() {
	return (float) FastMath.sqrtFast( getLengthSquared() );
}
 
开发者ID:StavrosSkourtis,项目名称:SuperHornet,代码行数:5,代码来源:AbstractVec.java

示例5: angleInRadians

import com.hackoeur.jglm.support.FastMath; //导入方法依赖的package包/类
/**
 * @param vec
 * @return the angle between this and the given vector, in <em>radians</em>.
 */
public float angleInRadians(final Vec3 vec) {
	final float dot = dot(vec);
	final float lenSq = FastMath.sqrtFast( getLengthSquared() * vec.getLengthSquared() );
	return (float) FastMath.acos( dot / lenSq );
}
 
开发者ID:StavrosSkourtis,项目名称:SuperHornet,代码行数:10,代码来源:Vec3.java


注:本文中的com.hackoeur.jglm.support.FastMath.sqrtFast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。