Package com.itextpdf.kernel.geom
Class Vector
java.lang.Object
com.itextpdf.kernel.geom.Vector
Represents a vector (i.e. a point in space). This class is completely unrelated to the
For many PDF related operations, the z coordinate is specified as 1 This is to support the coordinate transformation calculations. If it helps, just think of all PDF drawing operations as occurring in a single plane with z=1.
Vector
class in the standard JRE.
For many PDF related operations, the z coordinate is specified as 1 This is to support the coordinate transformation calculations. If it helps, just think of all PDF drawing operations as occurring in a single plane with z=1.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionComputes the cross product of this vector and the specified matrixComputes the cross product of this vector and the specified vectorfloat
Computes the dot product of this vector with the specified vectorboolean
float
get
(int index) Gets the value from a coordinate of the vectorint
hashCode()
Calculates the hashcode using the values.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
Computes the length squared of this vector.multiply
(float by) Multiplies the vector by a scalarNormalizes the vector (i.e.Computes the difference between this vector and the specified vectortoString()
-
Field Details
-
I1
public static final int I1index of the X coordinate- See Also:
-
I2
public static final int I2index of the Y coordinate- See Also:
-
I3
public static final int I3index of the Z coordinate- See Also:
-
-
Constructor Details
-
Vector
public Vector(float x, float y, float z) Creates a new Vector- Parameters:
-
x
- the X coordinate -
y
- the Y coordinate -
z
- the Z coordinate
-
-
Method Details
-
get
public float get(int index) Gets the value from a coordinate of the vector- Parameters:
-
index
- the index of the value to get (I1, I2 or I3) - Returns:
- a coordinate value
-
cross
Computes the cross product of this vector and the specified matrix- Parameters:
-
by
- the matrix to cross this vector with - Returns:
- the result of the cross product
-
subtract
Computes the difference between this vector and the specified vector- Parameters:
-
v
- the vector to subtract from this one - Returns:
- the results of the subtraction
-
cross
Computes the cross product of this vector and the specified vector- Parameters:
-
with
- the vector to cross this vector with - Returns:
- the cross product
-
normalize
Normalizes the vector (i.e. returns the unit vector in the same orientation as this vector)- Returns:
- the unit vector
-
multiply
Multiplies the vector by a scalar- Parameters:
-
by
- the scalar to multiply by - Returns:
- the result of the scalar multiplication
-
dot
Computes the dot product of this vector with the specified vector- Parameters:
-
with
- the vector to dot product this vector with - Returns:
- the dot product
-
length
public 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. If you want to compute the length of a vector, subtract it from the origin first (this will set the Z axis to 0).
For example:aVector.subtract(originVector).length();
- Returns:
- the length of this vector
-
lengthSquared
public float lengthSquared()Computes the length squared of this vector. The square of the length is less expensive to compute, and is often useful without taking the square root.
Note: See the important note underlength()
- Returns:
- the square of the length of the vector
-
toString
-
hashCode
public int hashCode()Calculates the hashcode using the values. -
equals
-