當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.atan方法代碼示例

本文整理匯總了Java中com.jme3.math.FastMath.atan方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.atan方法的具體用法?Java FastMath.atan怎麽用?Java FastMath.atan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.math.FastMath的用法示例。


在下文中一共展示了FastMath.atan方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: zoomCamera

import com.jme3.math.FastMath; //導入方法依賴的package包/類
protected void zoomCamera(float value){
    // derive fovY value
    float h = cam.getFrustumTop();
    float w = cam.getFrustumRight();
    float aspect = w / h;

    float near = cam.getFrustumNear();

    float fovY = FastMath.atan(h / near)
              / (FastMath.DEG_TO_RAD * .5f);
    fovY += value * 0.1f;

    h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;
    w = h * aspect;

    cam.setFrustumTop(h);
    cam.setFrustumBottom(-h);
    cam.setFrustumLeft(-w);
    cam.setFrustumRight(w);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:21,代碼來源:FlyByCamera.java

示例2: doToggleOrthoPerspMode

import com.jme3.math.FastMath; //導入方法依賴的package包/類
protected boolean doToggleOrthoPerspMode() {

        float aspect = (float) cam.getWidth() / cam.getHeight();
        if (!cam.isParallelProjection()) {
            cam.setParallelProjection(true);
            float h = cam.getFrustumTop();
            float w;
            float dist = cam.getLocation().distance(focus);
            float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
            h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
            w = h * aspect;
            cam.setFrustum(-1000, 1000, -w, w, h, -h);
            return true;
        } else {
            cam.setParallelProjection(false);
            cam.setFrustumPerspective(45f, aspect, 1, 1000);
            return false;
        }
    }
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:20,代碼來源:AbstractCameraController.java

示例3: doToggleOrthoPerspMode

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public boolean doToggleOrthoPerspMode() {
    float aspect = (float) cam.getWidth() / cam.getHeight();
    if (!cam.isParallelProjection()) {
        cam.setParallelProjection(true);
        float h = cam.getFrustumTop();
        float w;
        float dist = cam.getLocation().distance(focus);
        float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
        h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
        w = h * aspect;
        cam.setFrustum(orthoNear, orthoFar, -w, w, h, -h);
        return true;
    } else {
        cam.setParallelProjection(false);
        cam.setFrustumPerspective(45f, aspect, perspNear, perspFar);
        return false;
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:19,代碼來源:BestEditCamera.java

示例4: controlRender

import com.jme3.math.FastMath; //導入方法依賴的package包/類
protected void controlRender(RenderManager rm, ViewPort vp){
    BoundingVolume bv = spatial.getWorldBound();

    Camera cam = vp.getCamera();
    float atanNH = FastMath.atan(cam.getFrustumNear() * cam.getFrustumTop());
    float ratio = (FastMath.PI / (8f * atanNH));
    float newDistance = bv.distanceTo(vp.getCamera().getLocation()) / ratio;
    int level;

    if (Math.abs(newDistance - lastDistance) <= distTolerance)
        level = lastLevel; // we haven't moved relative to the model, send the old measurement back.
    else if (lastDistance > newDistance && lastLevel == 0)
        level = lastLevel; // we're already at the lowest setting and we just got closer to the model, no need to keep trying.
    else if (lastDistance < newDistance && lastLevel == numLevels - 1)
        level = lastLevel; // we're already at the highest setting and we just got further from the model, no need to keep trying.
    else{
        lastDistance = newDistance;

        // estimate area of polygon via bounding volume
        float area = AreaUtils.calcScreenArea(bv, lastDistance, cam.getWidth());
        float trisToDraw = area * trisPerPixel;
        level = numLevels - 1;
        for (int i = numLevels; --i >= 0;){
            if (trisToDraw - numTris[i] < 0){
                break;
            }
            level = i;
        }
        lastLevel = level;
    }

    spatial.setLodLevel(level);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:34,代碼來源:LodControl.java

示例5: doOrthoMode

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public void doOrthoMode() {
    if (!cam.isParallelProjection()) {
        float aspect = (float) cam.getWidth() / cam.getHeight();
        cam.setParallelProjection(true);
        float h = cam.getFrustumTop();
        float w;
        float dist = cam.getLocation().distance(focus);
        float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
        h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
        w = h * aspect;
        cam.setFrustum(orthoNear, orthoFar, -w, w, h, -h);
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:14,代碼來源:BestEditCamera.java


注:本文中的com.jme3.math.FastMath.atan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。