Example usage for com.badlogic.gdx.math Vector3 dot

List of usage examples for com.badlogic.gdx.math Vector3 dot

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Vector3 dot.

Prototype

public float dot(float x, float y, float z) 

Source Link

Document

Returns the dot product between this and the given vector.

Usage

From source file:com.mygdx.game.pathfinding.Triangle.java

License:Apache License

/**
 * Calculates the angle in radians between a reference vector and the (plane) normal of the triangle.
 *
 * @param reference/*from   w  w  w  .j ava 2  s  . c om*/
 * @return
 */
public float getAngle(Vector3 reference) {
    float x = reference.x;
    float y = reference.y;
    float z = reference.z;
    Vector3 normal = reference;
    normal.set(a).sub(b).crs(b.x - c.x, b.y - c.y, b.z - c.z).nor();
    float angle = (float) Math.acos(normal.dot(x, y, z) / (normal.len() * Math.sqrt(x * x + y * y + z * z)));
    reference.set(x, y, z);
    return angle;
}