Table of Contents

Class Vector

Namespace
iText.Kernel.Geom
Assembly
itext.kernel.dll

Represents a vector (i.e. a point in space).

public class Vector
Inheritance
Vector
Inherited Members

Remarks

Represents a vector (i.e. a point in space). This class is completely unrelated to the 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.

Constructors

Vector(float, float, float)

Creates a new Vector

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

Parameters

x float

the X coordinate

y float

the Y coordinate

z float

the Z coordinate

Fields

I1

index of the X coordinate

public const int I1 = 0

Field Value

int

I2

index of the Y coordinate

public const int I2 = 1

Field Value

int

I3

index of the Z coordinate

public const int I3 = 2

Field Value

int

Methods

Cross(Matrix)

Computes the cross product of this vector and the specified matrix

public virtual Vector Cross(Matrix by)

Parameters

by Matrix

the matrix to cross this vector with

Returns

Vector

the result of the cross product

Cross(Vector)

Computes the cross product of this vector and the specified vector

public virtual Vector Cross(Vector with)

Parameters

with Vector

the vector to cross this vector with

Returns

Vector

the cross product

Dot(Vector)

Computes the dot product of this vector with the specified vector

public virtual float Dot(Vector with)

Parameters

with Vector

the vector to dot product this vector with

Returns

float

the dot product

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool
See Also

Get(int)

Gets the value from a coordinate of the vector

public virtual float Get(int index)

Parameters

index int

the index of the value to get (I1, I2 or I3)

Returns

float

a coordinate value

GetHashCode()

Calculates the hashcode using the values.

public override int GetHashCode()

Returns

int

Length()

Computes the length of this vector

public virtual float Length()

Returns

float

the length of this vector

Remarks

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();

LengthSquared()

Computes the length squared of this vector.

public virtual float LengthSquared()

Returns

float

the square of the length of the vector

Remarks

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 under Length()

Multiply(float)

Multiplies the vector by a scalar

public virtual Vector Multiply(float by)

Parameters

by float

the scalar to multiply by

Returns

Vector

the result of the scalar multiplication

Normalize()

Normalizes the vector (i.e. returns the unit vector in the same orientation as this vector)

public virtual Vector Normalize()

Returns

Vector

the unit vector

Subtract(Vector)

Computes the difference between this vector and the specified vector

public virtual Vector Subtract(Vector v)

Parameters

v Vector

the vector to subtract from this one

Returns

Vector

the results of the subtraction

ToString()

public override string ToString()

Returns

string
See Also