Package com.google.ar.sceneform.math
Class Vector3
- java.lang.Object
-
- com.google.ar.sceneform.math.Vector3
-
public class Vector3 extends java.lang.ObjectA Vector with 3 floats.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Vector3add(Vector3 lhs, Vector3 rhs)Adds two Vector3'sstatic floatangleBetweenVectors(Vector3 a, Vector3 b)Returns the shortest angle in degrees between two vectors.static Vector3back()Gets a Vector3 set to (0, 0, 1)static Vector3cross(Vector3 lhs, Vector3 rhs)Get cross product of two Vector3'sstatic floatdot(Vector3 lhs, Vector3 rhs)Get dot product of two Vector3'sstatic Vector3down()Gets a Vector3 set to (0, -1, 0)static booleanequals(Vector3 lhs, Vector3 rhs)Compares two Vector3's are equal if each component is equal within a tolerance.booleanequals(java.lang.Object other)Returns true if the other object is a Vector3 and each component is equal within a tolerance.static Vector3forward()Gets a Vector3 set to (0, 0, -1)inthashCode()static Vector3left()Gets a Vector3 set to (-1, 0, 0)floatlength()floatlengthSquared()static Vector3lerp(Vector3 a, Vector3 b, float t)Linearly interpolates between a and b.static Vector3max(Vector3 lhs, Vector3 rhs)Get a Vector3 with each value set to the element wise maximum of two Vector3's valuesstatic Vector3min(Vector3 lhs, Vector3 rhs)Get a Vector3 with each value set to the element wise minimum of two Vector3's valuesVector3negated()Negates a Vector3Vector3normalized()Scales the Vector3 to the unit lengthstatic Vector3one()Gets a Vector3 with all values set to onestatic Vector3right()Gets a Vector3 set to (1, 0, 0)Vector3scaled(float a)Uniformly scales a Vector3voidset(float vx, float vy, float vz)Set each valuevoidset(Vector3 v)Copy the values from another Vector3 to this Vector3static Vector3subtract(Vector3 lhs, Vector3 rhs)Subtract two Vector3java.lang.StringtoString()static Vector3up()Gets a Vector3 set to (0, 1, 0)static Vector3zero()Gets a Vector3 with all values set to zero
-
-
-
Constructor Detail
-
Vector3
public Vector3()
Construct a Vector3 and assign zero to all values
-
Vector3
public Vector3(float x, float y, float z)Construct a Vector3 and assign each value
-
Vector3
public Vector3(Vector3 v)
Construct a Vector3 and copy the values
-
-
Method Detail
-
set
public void set(Vector3 v)
Copy the values from another Vector3 to this Vector3
-
set
public void set(float vx, float vy, float vz)Set each value
-
lengthSquared
public float lengthSquared()
-
length
public float length()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
normalized
public Vector3 normalized()
Scales the Vector3 to the unit length
-
scaled
public Vector3 scaled(float a)
Uniformly scales a Vector3- Returns:
- a Vector3 multiplied by a scalar amount
-
negated
public Vector3 negated()
Negates a Vector3- Returns:
- A Vector3 with opposite direction
-
add
public static Vector3 add(Vector3 lhs, Vector3 rhs)
Adds two Vector3's- Returns:
- The combined Vector3
-
subtract
public static Vector3 subtract(Vector3 lhs, Vector3 rhs)
Subtract two Vector3- Returns:
- The combined Vector3
-
dot
public static float dot(Vector3 lhs, Vector3 rhs)
Get dot product of two Vector3's- Returns:
- The scalar product of the Vector3's
-
cross
public static Vector3 cross(Vector3 lhs, Vector3 rhs)
Get cross product of two Vector3's- Returns:
- A Vector3 perpendicular to Vector3's
-
min
public static Vector3 min(Vector3 lhs, Vector3 rhs)
Get a Vector3 with each value set to the element wise minimum of two Vector3's values
-
max
public static Vector3 max(Vector3 lhs, Vector3 rhs)
Get a Vector3 with each value set to the element wise maximum of two Vector3's values
-
lerp
public static Vector3 lerp(Vector3 a, Vector3 b, float t)
Linearly interpolates between a and b.- Parameters:
a- the beginning valueb- the ending valuet- ratio between the two floats.- Returns:
- interpolated value between the two floats
-
angleBetweenVectors
public static float angleBetweenVectors(Vector3 a, Vector3 b)
Returns the shortest angle in degrees between two vectors. The result is never greater than 180 degrees.
-
equals
public static boolean equals(Vector3 lhs, Vector3 rhs)
Compares two Vector3's are equal if each component is equal within a tolerance.
-
equals
public boolean equals(java.lang.Object other)
Returns true if the other object is a Vector3 and each component is equal within a tolerance.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
zero
public static Vector3 zero()
Gets a Vector3 with all values set to zero
-
one
public static Vector3 one()
Gets a Vector3 with all values set to one
-
forward
public static Vector3 forward()
Gets a Vector3 set to (0, 0, -1)
-
back
public static Vector3 back()
Gets a Vector3 set to (0, 0, 1)
-
up
public static Vector3 up()
Gets a Vector3 set to (0, 1, 0)
-
down
public static Vector3 down()
Gets a Vector3 set to (0, -1, 0)
-
right
public static Vector3 right()
Gets a Vector3 set to (1, 0, 0)
-
left
public static Vector3 left()
Gets a Vector3 set to (-1, 0, 0)
-
-