public class Vector extends Object
Vector
class in the standard JRE.
Constructor and Description |
---|
Vector(float x,
float y,
float z)
Creates a new Vector
|
Modifier and Type | Method and Description |
---|---|
Vector |
add(Vector v)
Computes the sum of this vector and the specified vector
|
Vector |
cross(Matrix by)
Computes the cross product of this vector and the specified matrix
|
Vector |
cross(Vector with)
Computes the cross product of this vector and the specified vector
|
float |
dot(Vector with)
Computes the dot product of this vector with the specified vector
|
float |
get(int index)
Gets the value from a coordinate of the vector
|
float |
length()
Computes the length of this vector
Note: If you are working with raw vectors from PDF, be careful -
the Z axis will generally be set to 1.
|
float |
lengthSquared()
Computes the length squared of this vector.
|
Vector |
subtract(Vector v)
Computes the difference between this vector and the specified vector
|
String |
toString() |
public Vector(float x, float y, float z)
x
- the X coordinatey
- the Y coordinatez
- the Z coordinatepublic float get(int index)
index
- the index of the value to get (I1, I2 or I3)public Vector cross(Matrix by)
by
- the matrix to cross this vector withpublic Vector subtract(Vector v)
v
- the vector to subtract from this onepublic Vector add(Vector v)
v
- the vector to subtract from this onepublic Vector cross(Vector with)
with
- the vector to cross this vector withpublic float dot(Vector with)
with
- the vector to dot product this vector withpublic float length()
For example:
aVector.subtract(originVector).length();
public float lengthSquared()
The square of the length is less expensive to compute, and is often
useful without taking the square root.
Note: See the important note under length()
public String toString()
toString
in class Object
Object.toString()
Copyright © 2020. All rights reserved.