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


Java FastMath.tan方法代码示例

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


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

示例1: setFrustumPerspective

import com.jme3.math.FastMath; //导入方法依赖的package包/类
/**
 * <code>setFrustumPerspective</code> defines the frustum for the camera.  This
 * frustum is defined by a viewing angle, aspect ratio, and near/far planes
 *
 * @param fovY   Frame of view angle along the Y in degrees.
 * @param aspect Width:Height ratio
 * @param near   Near view plane distance
 * @param far    Far view plane distance
 */
public void setFrustumPerspective(float fovY, float aspect, float near,
        float far) {
    if (Float.isNaN(aspect) || Float.isInfinite(aspect)) {
        // ignore.
        logger.log(Level.WARNING, "Invalid aspect given to setFrustumPerspective: {0}", aspect);
        return;
    }

    float h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * near;
    float w = h * aspect;
    frustumLeft = -w;
    frustumRight = w;
    frustumBottom = -h;
    frustumTop = h;
    frustumNear = near;
    frustumFar = far;

    onFrustumChange();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:Camera.java

示例2: 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

示例3: doZoomCamera

import com.jme3.math.FastMath; //导入方法依赖的package包/类
protected void doZoomCamera(float amount) {
    amount = cam.getLocation().distance(focus) * amount;
    float dist = cam.getLocation().distance(focus);
    amount = dist - Math.max(0f, dist - amount);
    Vector3f loc = cam.getLocation().clone();
    loc.scaleAdd(amount, cam.getDirection(), loc);
    cam.setLocation(loc);

    if (cam.isParallelProjection()) {
        float aspect = (float) cam.getWidth() / cam.getHeight();
        float h = FastMath.tan(45f * FastMath.DEG_TO_RAD * .5f) * dist;
        float w = h * aspect;
        cam.setFrustum(-1000, 1000, -w, w, h, -h);
    }

}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:17,代码来源:AbstractCameraController.java

示例4: 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

示例5: doZoomCamera

import com.jme3.math.FastMath; //导入方法依赖的package包/类
public void doZoomCamera(float amount) {
        amount = amount * 0.1f;
        amount = cam.getLocation().distance(focus) * amount;
        float dist = cam.getLocation().distance(focus);
        amount = dist - Math.max(0f, dist - amount);
        
        // 一个最小距离用于防止拉到0距离后缩放不回来的BUG
        if (amount >= dist) {
            amount -= minDistance;
        }
        
        Vector3f loc = cam.getLocation().clone();
        loc.scaleAdd(amount, cam.getDirection(), loc);
        cam.setLocation(loc);

        if (cam.isParallelProjection()) {
            float aspect = (float) cam.getWidth() / cam.getHeight();
            float h = FastMath.tan(45f * FastMath.DEG_TO_RAD * .5f) * dist;
            float w = h * aspect;
            cam.setFrustum(orthoNear, orthoFar, -w, w, h, -h);
        }
//        LOG.log(Level.INFO, "doZoomCamera, Camera location={0}", cam.getLocation());
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:24,代码来源:BestEditCamera.java

示例6: 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

示例7: 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

示例8: oppositeSide

import com.jme3.math.FastMath; //导入方法依赖的package包/类
private static float oppositeSide(float angle, float adjacent) {
    // tan(angle) = opposite / adjacent
    return FastMath.tan(angle) * adjacent;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:5,代码来源:LightConeRadiusUpdate.java

示例9: update

import com.jme3.math.FastMath; //导入方法依赖的package包/类
@Override
public void update(float tpf) {
	if (!enabled) {
		return;
	}
    super.update(tpf);
    if (velocity > 0 && holding.size() > 0) {
        release();
    }
    
    if (holding.size() > 0) {
        velocity = 0;
        return;
    }
    
    // check holding objects
    float maxDiff = opening * FastMath.tan(FastMath.QUARTER_PI / 4);
    for (Entry<Float, Spatial> e1 : leftContacts.entrySet()) {
        for (Entry<Float, Spatial> e2 : rightContacts.entrySet()) {
            if (e1.getValue() != e2.getValue()) {
                continue;
            }
            if (FastMath.abs(e1.getKey() - e2.getKey()) > maxDiff) {
                continue;
            }
        	
            Spatial s = e1.getValue();
            if (holding.contains(s)) {
                continue;
            }
            MyRigidBodyControl rbc = s.getControl(MyRigidBodyControl.class);
            if (rbc == null || rbc.getMass() == 0 || rbc.isKinematic()) {
                continue;
            }
            hold(s);
            logger.log(Level.INFO, "hold");
        }
    }
    
    if ((leftContacts.size() > 0 || rightContacts.size() > 0) && holding.size() <= 0) {
        logger.log(Level.INFO, "cannot hold: {0}", maxDiff);
    }
                
    leftContacts.clear();
    rightContacts.clear();

    
    if (velocity != 0) {
        if (velocity < 0) {
            float impulse = -velocity * tpf * FINGER_MASS * 2;
            impulse -= fingerPressure;
            float offset = impulse / (FINGER_MASS * 2);
            offset = FastMath.clamp(offset, 0, offset);
            opening -= offset;
            checkDigitCollision = true;
        } else {
            opening += velocity * tpf;
            checkDigitCollision = false;
        }
        opening = FastMath.clamp(opening, 0, Gripper.MAX_OPENING);

        // update finger opeining
        Vector3f v = leftFinger.getLocalTranslation();
        v.x = -opening / 2 - Gripper.FINGER_SIZE.x / 2;
        leftFinger.setLocalTranslation(v);
        v = rightFinger.getLocalTranslation();
        v.x = opening / 2 + Gripper.FINGER_SIZE.x / 2;
        rightFinger.setLocalTranslation(v);
        
        fingerPressure = 0;
        velocity = 0;
    } else {
        checkDigitCollision = false;
    }
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:76,代码来源:Gripper.java


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