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


Java FastMath.sin方法代碼示例

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


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

示例1: doAnimUpdate

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
protected void doAnimUpdate(float interpolation) {
    // 注:初始化放在這裏是特殊情況,在doAnimInit裏初始化時,如果是從存檔中載入會無法更新顏色。
    // BUG未知.
    if (!localInit) {
        target.addMatParamOverride(colorOverride);
        target.addMatParamOverride(useMaterialColorOverride);
        target.addMatParamOverride(ambientOverride);
        target.addMatParamOverride(diffuseOverride);
        localInit = true;
    }
    
    float inter;
    if (useSine) {
        inter = FastMath.sin(interpolation * FastMath.HALF_PI);
    } else {
        inter = interpolation;
    }
    
    updateColor.set(startColor);
    updateColor.interpolateLocal(endColor, inter);
    updateColor(updateColor);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:24,代碼來源:ColorAnim.java

示例2: onLayout

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
protected void onLayout(ElementContainer<?,?> parent) {
	for (BaseElement el : parent.getElements()) {
		float cx = parent.getWidth() / 2f;
		float cy = parent.getHeight() / 2f;
		Vector2f elpref = el.calcPreferredSize();
		RadialLayoutInfo con = constraints.get(el);
		String layoutData = el.getLayoutData();
		if(layoutData != null && layoutData.length() > 0) {
			con = parseConstraints(layoutData);
		}
		float inset = this.inset;
		if (con != null) {
			if(con.getInset() != Float.MIN_VALUE)
				inset = con.getInset();
			cx += FastMath.sin(con.getAngle()) * (cx - inset);
			cy -= FastMath.cos(con.getAngle()) * (cy - inset);
			el.setBounds(Math.round(cx - (elpref.x / 2f)), Math.round(cy - (elpref.y / 2f)), elpref.x, elpref.y);
		}
	}
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:22,代碼來源:RadialLayout.java

示例3: computePosition

import com.jme3.math.FastMath; //導入方法依賴的package包/類
/**
 * Compute position.
 */
protected void computePosition() {

    float highDistance = (distance) * FastMath.sin((FastMath.PI / 2) - verticalRotation);

    position.set(highDistance * FastMath.cos(rotation), (distance) * FastMath.sin(verticalRotation), highDistance * FastMath.sin(rotation));
    position.addLocal(target.getWorldTranslation());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:11,代碼來源:EditorCamera.java

示例4: simpleUpdate

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public void simpleUpdate(float tpf){
    angle += tpf;
    angle %= FastMath.TWO_PI;
    float x = FastMath.cos(angle) * 2;
    float y = FastMath.sin(angle) * 2;
    emit.setLocalTranslation(x, 0, y);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:9,代碼來源:TestMovingParticle.java

示例5: rotatedBoundsLocal

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public static Vector2f rotatedBoundsLocal(Vector2f rect, float rad) {
	float s = FastMath.sin(rad);
	float c = FastMath.cos(rad);
	float rx = rect.y * FastMath.abs(s) + rect.x * FastMath.abs(c);
	float ry = rect.y * FastMath.abs(c) + rect.x * FastMath.abs(s);
	rect.set(rx, ry);
	return rect;
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:9,代碼來源:MathUtil.java

示例6: doAnimUpdate

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
protected void doAnimUpdate(float interpolation) {
    // 正弦曲線,增強運動效果
    if (useSine) {
        interpolation = FastMath.sin(interpolation * FastMath.HALF_PI);
    }
    
    TempVars tv = TempVars.get();
    float distance = interpolation * totalLength;
    getWayPointIndexForDistance(distance, tv.vect2d);
    spline.interpolate(tv.vect2d.y, (int) tv.vect2d.x, tv.vect1);
    
    // dir
    if (facing == Facing.path) {
        tv.vect1.subtract(target.getSpatial().getWorldTranslation(), tv.vect2).normalizeLocal();
        actorService.setViewDirection(target, tv.vect2);
        
    } else if (facing == Facing.target && targetAttribute != null) {
        Entity other = target.getScene().getEntity(targetAttribute.longValue());
        
        if (other != null) {
            other.getSpatial().getWorldTranslation()
                    .subtract(target.getSpatial().getWorldTranslation(), tv.vect5).normalizeLocal();
            actorService.setViewDirection(target, tv.vect5);
        }
    }
    
    if (interpolation >= 1) {
        // end
        actorService.setLocation(target, spline.getControlPoints().get(spline.getControlPoints().size() - 1));
    } else {
        // local必須在計算出facing後再設置
        actorService.setLocation(target, tv.vect1);
    }
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:37,代碼來源:ActorCurveMove.java

示例7: apply

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
public float apply (float a) {
	if (a <= 0.5f) {
		a *= 2;
		return FastMath.pow(value, power * (a - 1)) * FastMath.sin(a * 20) * 1.0955f / 2;
	}
	a = 1 - a;
	a *= 2;
	return 1 - (float)Math.pow(value, power * (a - 1)) * FastMath.sin((a) * 20) * 1.0955f / 2;
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:11,代碼來源:Interpolation.java

示例8: rot

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public Vector2f rot(Vector2f p, float angle) {
	cos = FastMath.cos(angle * FastMath.DEG_TO_RAD);
	sin = FastMath.sin(angle * FastMath.DEG_TO_RAD);
	x = p.x * cos - p.y * sin;
	y = p.x * sin + p.y * cos;
	return p.set(x, y);
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:8,代碼來源:AnimElementMesh.java

示例9: doMotion

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
protected void doMotion(Spatial ui, float factor) {
    sineFactor = FastMath.sin(factor * FastMath.PI);
    TempVars tv = TempVars.get();
    tv.vect1.set(startPos);
    tv.vect1.interpolateLocal(endPos, factor);
    tv.vect1.setY(tv.vect1.y + height * sineFactor);
    ui.setLocalTranslation(tv.vect1);
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:11,代碼來源:CurveMove.java

示例10: doAnimation

import com.jme3.math.FastMath; //導入方法依賴的package包/類
@Override
protected void doAnimation(float tpf) {
    float sineFactor = FastMath.sin(time / useTime * FastMath.PI);
    if (sineFactor < 0) {
        return;
    }
    TempVars tv = TempVars.get();
    float yOffset = height * sineFactor;
    target.setLocalTranslation(tv.vect1.set(origin).addLocal(0, yOffset, 0));
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:12,代碼來源:BounceMotion.java

示例11: getRandomPositionInXZPlane

import com.jme3.math.FastMath; //導入方法依賴的package包/類
/**
 * 以原點為中心,在半徑為radius的xz平麵範圍內取一個點
 * @param maxRadius
 * @param store
 * @return 
 */
public static Vector3f getRandomPositionInXZPlane(float maxRadius, Vector3f store) {
    if (store == null) {
        store = new Vector3f();
    }
    TempVars tv = TempVars.get();
   
    float radius = FastMath.nextRandomFloat() * maxRadius;
    float angleInRadian = FastMath.nextRandomFloat() * FastMath.TWO_PI;
    float x = FastMath.cos(angleInRadian) * radius;
    float y = FastMath.sin(angleInRadian) * radius;
    store.set(x, 0, y); // xz平麵
    tv.release();
    return store;
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:21,代碼來源:MathUtils.java

示例12: setGeometryData

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void setGeometryData() {
    // allocate vertices
    int vertCount = (circleSamples + 1) * (radialSamples + 1);
    FloatBuffer fpb = BufferUtils.createVector3Buffer(vertCount);
    setBuffer(Type.Position, 3, fpb);

    // allocate normals if requested
    FloatBuffer fnb = BufferUtils.createVector3Buffer(vertCount);
    setBuffer(Type.Normal, 3, fnb);

    // allocate texture coordinates
    FloatBuffer ftb = BufferUtils.createVector2Buffer(vertCount);
    setBuffer(Type.TexCoord, 2, ftb);

    // generate geometry
    float inverseCircleSamples = 1.0f / circleSamples;
    float inverseRadialSamples = 1.0f / radialSamples;
    int i = 0;
    // generate the cylinder itself
    Vector3f radialAxis = new Vector3f(), torusMiddle = new Vector3f(), tempNormal = new Vector3f();
    for (int circleCount = 0; circleCount < circleSamples; circleCount++) {
        // compute center point on torus circle at specified angle
        float circleFraction = circleCount * inverseCircleSamples;
        float theta = FastMath.TWO_PI * circleFraction;
        float cosTheta = FastMath.cos(theta);
        float sinTheta = FastMath.sin(theta);
        radialAxis.set(cosTheta, sinTheta, 0);
        radialAxis.mult(outerRadius, torusMiddle);

        // compute slice vertices with duplication at end point
        int iSave = i;
        for (int radialCount = 0; radialCount < radialSamples; radialCount++) {
            float radialFraction = radialCount * inverseRadialSamples;
            // in [0,1)
            float phi = FastMath.TWO_PI * radialFraction;
            float cosPhi = FastMath.cos(phi);
            float sinPhi = FastMath.sin(phi);
            tempNormal.set(radialAxis).multLocal(cosPhi);
            tempNormal.z += sinPhi;
            fnb.put(tempNormal.x).put(tempNormal.y).put(
                    tempNormal.z);
   
            tempNormal.multLocal(innerRadius).addLocal(torusMiddle);
            fpb.put(tempNormal.x).put(tempNormal.y).put(
                    tempNormal.z);

            ftb.put(radialFraction).put(circleFraction);
            i++;
        }

        BufferUtils.copyInternalVector3(fpb, iSave, i);
        BufferUtils.copyInternalVector3(fnb, iSave, i);

        ftb.put(1.0f).put(circleFraction);

        i++;
    }

    // duplicate the cylinder ends to form a torus
    for (int iR = 0; iR <= radialSamples; iR++, i++) {
        BufferUtils.copyInternalVector3(fpb, iR, i);
        BufferUtils.copyInternalVector3(fnb, iR, i);
        BufferUtils.copyInternalVector2(ftb, iR, i);
        ftb.put(i * 2 + 1, 1.0f);
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:67,代碼來源:Torus.java

示例13: computePosition

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private void computePosition() {

        float hDistance = (distance) * FastMath.sin((FastMath.PI / 2) - vRotation);
        pos.set(hDistance * FastMath.cos(rotation), (distance) * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation));
        pos.addLocal(target.getWorldTranslation());
    }
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:7,代碼來源:ChaseCamera.java

示例14: createCone

import com.jme3.math.FastMath; //導入方法依賴的package包/類
private static Mesh createCone(int radialSamples, float radius, float height) {
    Mesh cone = new Mesh();

    float fInvRS = 1.0f / radialSamples;

    // Generate points on the unit circle to be used in computing the mesh
    // points on a dome slice.
    float[] afSin = new float[radialSamples];
    float[] afCos = new float[radialSamples];
    for (int i = 0; i < radialSamples; i++) {
        float fAngle = FastMath.TWO_PI * fInvRS * i;
        afCos[i] = FastMath.cos(fAngle);
        afSin[i] = FastMath.sin(fAngle);
    }

    FloatBuffer vb = BufferUtils.createVector3Buffer(radialSamples + 2);
    cone.setBuffer(Type.Position, 3, vb);

    TempVars vars = TempVars.get();
    Vector3f tempVa = vars.vect1;

    for (int i = 0; i < radialSamples; i++) {
        Vector3f kRadial = tempVa.set(afCos[i], 0, afSin[i]);
        kRadial.mult(radius, tempVa);
        vb.put(tempVa.x).put(tempVa.y).put(tempVa.z);

        BufferUtils.populateFromBuffer(tempVa, vb, i);

    }
    vars.release();

    // top of the cone
    vb.put(0).put(height).put(0);
    // base of the cone
    vb.put(0).put(0).put(0);

    ShortBuffer ib = BufferUtils.createShortBuffer(3 * (radialSamples) * 2);
    cone.setBuffer(Type.Index, 3, ib);

    short top = (short) radialSamples;
    short bot = (short) (radialSamples + 1);

    for (int i = 0; i < radialSamples; i++) {
        short a = (short) i;
        short b = (short) ((i + 1) % radialSamples);
        ib.put(top);
        ib.put(b);
        ib.put(a);

        ib.put(a);
        ib.put(b);
        ib.put(bot);
    }

    cone.updateBound();

    return cone;
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:59,代碼來源:SceneEditTool.java

示例15: setGeometryData

import com.jme3.math.FastMath; //導入方法依賴的package包/類
/**
 * builds the vertices based on the radius
 */
private void setGeometryData() {
    setMode(Mode.Lines);

    FloatBuffer posBuf = BufferUtils.createVector3Buffer((radialSamples + 1));
    FloatBuffer colBuf = BufferUtils.createFloatBuffer((radialSamples + 1) * 4);
    FloatBuffer texBuf = BufferUtils.createVector2Buffer(radialSamples + 1);
    

    setBuffer(Type.Position, 3, posBuf);
    setBuffer(Type.Color, 4, colBuf);
    setBuffer(Type.TexCoord, 2, texBuf);

    // generate geometry
    float fInvRS = 1.0f / radialSamples;

    // Generate points on the unit circle to be used in computing the mesh
    // points on a sphere slice.
    float[] afSin = new float[(radialSamples + 1)];
    float[] afCos = new float[(radialSamples + 1)];
    for (int iR = 0; iR < radialSamples; iR++) {
        float fAngle = FastMath.TWO_PI * fInvRS * iR;
        afCos[iR] = FastMath.cos(fAngle);
        afSin[iR] = FastMath.sin(fAngle);
    }
    afSin[radialSamples] = afSin[0];
    afCos[radialSamples] = afCos[0];

    for (int iR = 0; iR <= radialSamples; iR++) {
        posBuf.put(afCos[iR])
                .put(afSin[iR])
                .put(0);
        colBuf.put(ColorRGBA.Orange.r)
                .put(ColorRGBA.Orange.g)
                .put(ColorRGBA.Orange.b)
                .put(ColorRGBA.Orange.a);
        texBuf.put(iR % 2f)
                .put(iR % 2f);

    }

    updateBound();
    setStatic();
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:47,代碼來源:ProbeRadiusShape.java


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