Android Open Source - fun-gl Vector3






From Project

Back to project page fun-gl.

License

The source code is released under:

Apache License

If you think the Android project fun-gl listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jcxavier.android.opengl.math;
//from   w w w .j  a va2s  .  com
/**
 * Created on 11/03/2014.
 *
 * @author Joo Xavier <jcxavier@jcxavier.com>
 */
public final class Vector3 implements IVector<Vector3> {

    public float x;
    public float y;
    public float z;

    public Vector3() {
        x = 0;
        y = 0;
        z = 0;
    }

    public Vector3(final float x, final float y, final float z) {
        set(x, y, z);
    }

    public Vector3(final Vector3 v) {
        set(v);
    }

    @Override
    public Vector3 set(final Vector3 v) {
        x = v.x;
        y = v.y;
        z = v.z;
        return this;
    }

    public Vector3 set(final float x, final float y, final float z) {
        this.x = x;
        this.y = y;
        this.z = z;
        return this;
    }

    @Override
    public Vector3 add(final Vector3 v) {
        return set(x + v.x, y + v.y, z + v.z);
    }

    @Override
    public Vector3 sub(final Vector3 v) {
        return set(x - v.x, y - v.y, z - v.z);
    }

    @Override
    public Vector3 negate() {
        return set(-x, -y, -z);
    }

    /**
     * Constructs a new vector containing the sum of two given vectors.
     *
     * @param vectorLeft  the left-hand side vector
     * @param vectorRight the right-hand side vector
     * @return a new vector with the result of the sum
     */
    public static Vector3 add(Vector3 vectorLeft, Vector3 vectorRight) {
        Vector3 v = new Vector3(vectorLeft);
        v.add(vectorRight);
        return v;
    }

    /**
     * Constructs a new vector containing the subtraction of two given vectors.
     *
     * @param vectorLeft  the left-hand side vector
     * @param vectorRight the right-hand side vector
     * @return a new vector with the result of the subtraction
     */
    public static Vector3 subtract(Vector3 vectorLeft, Vector3 vectorRight) {
        Vector3 v = new Vector3(vectorLeft);
        v.sub(vectorRight);
        return v;
    }

    /**
     * Constructs a new negated vector (i.e. with all its components negated).
     *
     * @param v the original vector
     * @return a new vector
     */
    public static Vector3 negate(final Vector3 v) {
        return new Vector3(-v.x, -v.y, -v.z);
    }
}




Java Source Code List

com.jcxavier.android.opengl.engine.BitmapConfigHelper.java
com.jcxavier.android.opengl.engine.EngineActivity.java
com.jcxavier.android.opengl.engine.EngineRenderer.java
com.jcxavier.android.opengl.engine.EngineView.java
com.jcxavier.android.opengl.engine.RendererOptions.java
com.jcxavier.android.opengl.engine.cache.GLState.java
com.jcxavier.android.opengl.engine.gdx.GdxEglConfigChooser.java
com.jcxavier.android.opengl.engine.shader.ColorShader.java
com.jcxavier.android.opengl.engine.shader.ShaderManager.java
com.jcxavier.android.opengl.engine.shader.Shader.java
com.jcxavier.android.opengl.engine.shader.TextureShader.java
com.jcxavier.android.opengl.engine.texture.TextureFilteringMode.java
com.jcxavier.android.opengl.engine.texture.TextureManager.java
com.jcxavier.android.opengl.engine.texture.TextureWrap.java
com.jcxavier.android.opengl.engine.texture.Texture.java
com.jcxavier.android.opengl.engine.type.RotationMode.java
com.jcxavier.android.opengl.file.FileManager.java
com.jcxavier.android.opengl.game.GameStage.java
com.jcxavier.android.opengl.game.SimpleGameStage.java
com.jcxavier.android.opengl.game.camera.Camera.java
com.jcxavier.android.opengl.game.camera.DefaultCamera.java
com.jcxavier.android.opengl.game.camera.OrthographicCamera.java
com.jcxavier.android.opengl.game.manager.GameManager.java
com.jcxavier.android.opengl.game.manager.ScreenManager.java
com.jcxavier.android.opengl.game.manager.input.InputHandler.java
com.jcxavier.android.opengl.game.manager.input.InputManager.java
com.jcxavier.android.opengl.game.object.DrawableObject.java
com.jcxavier.android.opengl.game.object.GameObject.java
com.jcxavier.android.opengl.game.object.Sprite.java
com.jcxavier.android.opengl.game.type.Resizeable.java
com.jcxavier.android.opengl.game.type.Touchable.java
com.jcxavier.android.opengl.game.type.Transformable.java
com.jcxavier.android.opengl.game.type.Updateable.java
com.jcxavier.android.opengl.math.IVector.java
com.jcxavier.android.opengl.math.Matrix4.java
com.jcxavier.android.opengl.math.Vector2.java
com.jcxavier.android.opengl.math.Vector3.java
com.jcxavier.android.opengl.math.Vector4.java
com.jcxavier.android.opengl.sample.GameActivity.java
com.jcxavier.android.opengl.sample.TestStage.java
com.jcxavier.android.opengl.util.BitmapUtils.java
com.jcxavier.android.opengl.util.Constants.java
com.jcxavier.android.opengl.util.ReflectionUtils.java
com.jcxavier.android.opengl.util.WeakList.java
com.sample.clean.TestActivity.java
com.sample.clean.TestStage.java