Package pygeodesy :: Module vector3d :: Class Vector3d
[frames] | no frames]

Class Vector3d

object --+    
         |    
bases.Base --+
             |
            Vector3d
Known Subclasses:

Generic 3-D vector manipulation.

In a geodesy context, these may be used to represent:

Instance Methods
 
__abs__(self)
Norm of this vector (scalar).
 
__add__(self, other)
This plus an other vector (Vector3d).
 
__cmp__(self, other)
Compares this and an other vector?
 
__div__(self, scalar)
Divides this vector by a scalar.
 
__eq__(self, other)
Is this vector equal to an other vector?
 
__ge__(self, other)
Is this vector longer than or equal to an other vector?
 
__gt__(self, other)
Is this vector longer than an other vector?
 
__iadd__(self, other)
This plus an other vector (Vector3d).
 
__imatmul__(self, other)
Cross product of this and another vector.
 
__imul__(self, scalar)
Multiplies this vector by a scalar
 
__init__(self, x, y, z)
New 3-D vector.
 
__isub__(self, other)
This minus an other vector.
 
__itruediv__(self, scalar)
Divides this vector by a scalar.
 
__le__(self, other)
Is this vector shorter than or equal to an other vector?
 
__lt__(self, other)
Is this vector shorter than an other vector?
 
__matmul__(self, other)
Cross product of this and another vector.
 
__mul__(self, scalar)
Multiplies this vector by a scalar
 
__ne__(self, other)
Is this vector not equal to an other vector?
 
__neg__(self)
Negates this vector.
 
__pos__(self)
Copies this vector.
 
__radd__(self, other)
This plus an other vector (Vector3d).
 
__rmatmul__(self, other)
Cross product of an other and this vector.
 
__rmul__(self, scalar)
Multiplies this vector by a scalar
 
__rsub__(self, other)
An other minus this vector.
 
__sub__(self, other)
This minus an other vector.
 
__truediv__(self, scalar)
Divides this vector by a scalar.
 
angleTo(self, other, vSign=None)
Computes the angle between this and an other vector.
 
copy(self)
Copies this vector.
 
cross(self, other)
Cross product of this and an other vector.
 
dividedBy(self, factor)
Divides this vector by a scalar.
 
dot(self, other)
Dot (scalar) product of this and an other vector.
 
equals(self, other, units=False)
Checks if this and an other vector are equal or equivalent.
 
minus(self, other)
Subtracts an other vector from this vector.
 
negate(self)
This vector in opposite direction.
 
others(self, other, name='other')
Refined class comparison.
 
parse(self, str3d)
Parses an "x, y, z" string representing a Vector3d.
 
plus(self, other)
Adds this and an other vector.
 
rotate(self, axis, theta)
Rotates this vector by a specified angle around an axis.
 
rotateAround(self, axis, theta)
Rotates this vector by a specified angle around an axis.
 
sum(self, other)
Adds this and an other vector.
 
times(self, factor)
Multiplies this vector by a scalar.
 
to2ll(self)
Converts this vector to (geodetic) lat- and longitude.
 
to3xyz(self)
Returns this vector as a 3-tuple.
 
toStr(self, prec=5, fmt='(%s)', sep=', ')
String representation of this vector.
 
unit(self)
Normalize this vector to unit length.

Inherited from bases.Base: __repr__, __str__, classname, toStr2, topsub

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties
  length
Gets the length (norm, magnitude) of this vector (float).
  x
Gets the X component (scalar).
  y
Gets the Y component (scalar).
  z
Gets the Z component (scalar).

Inherited from object: __class__

Method Details

__abs__(self)

 

Norm of this vector (scalar).

Returns:
Norm, unit length (float);

__add__(self, other)
(Addition operator)

 

This plus an other vector (Vector3d).

Returns:
Vectorial sum (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__cmp__(self, other)
(Comparison operator)

 

Compares this and an other vector?

Parameters:
Returns:
-1, 0 or +1 (int).
Raises:
  • TypeError - Incompatible type(other).

__div__(self, scalar)

 

Divides this vector by a scalar.

Parameters:
  • scalar - The divisor (scalar).
Returns:
Quotient (Vector3d).
Raises:
  • TypeError - If scalar not scalar'

__eq__(self, other)
(Equality operator)

 

Is this vector equal to an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__ge__(self, other)
(Greater-than-or-equals operator)

 

Is this vector longer than or equal to an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__gt__(self, other)
(Greater-than operator)

 

Is this vector longer than an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__iadd__(self, other)

 

This plus an other vector (Vector3d).

Returns:
Vectorial sum (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__imatmul__(self, other)

 

Cross product of this and another vector.

Parameters:
Returns:
Cross product (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__imul__(self, scalar)

 

Multiplies this vector by a scalar

Parameters:
  • scalar - Factor (scalar).
Returns:
Product (Vector3d).

__init__(self, x, y, z)
(Constructor)

 

New 3-D vector.

The vector may be normalised, or use x/y/z values for height relative to the surface of the sphere or ellipsoid, distance from earth centre, etc.

Parameters:
  • x - X component of vector.
  • y - Y component of vector.
  • z - Z component of vector.
Overrides: object.__init__

__isub__(self, other)

 

This minus an other vector.

Parameters:
Returns:
Difference (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__itruediv__(self, scalar)

 

Divides this vector by a scalar.

Parameters:
  • scalar - The divisor (scalar).
Returns:
Quotient (Vector3d).
Raises:
  • TypeError - If scalar not scalar'

__le__(self, other)
(Less-than-or-equals operator)

 

Is this vector shorter than or equal to an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__lt__(self, other)
(Less-than operator)

 

Is this vector shorter than an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__matmul__(self, other)

 

Cross product of this and another vector.

Parameters:
Returns:
Cross product (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__mul__(self, scalar)

 

Multiplies this vector by a scalar

Parameters:
  • scalar - Factor (scalar).
Returns:
Product (Vector3d).

__ne__(self, other)

 

Is this vector not equal to an other vector?

Parameters:
Returns:
True if so (bool).
Raises:
  • TypeError - Incompatible type(other).

__neg__(self)

 

Negates this vector.

Returns:
Negative (Vector3d)

__pos__(self)

 

Copies this vector.

Returns:
Positive (Vector3d)

__radd__(self, other)
(Right-side addition operator)

 

This plus an other vector (Vector3d).

Returns:
Vectorial sum (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__rmatmul__(self, other)

 

Cross product of an other and this vector.

Parameters:
Returns:
Cross product (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__rmul__(self, scalar)

 

Multiplies this vector by a scalar

Parameters:
  • scalar - Factor (scalar).
Returns:
Product (Vector3d).

__rsub__(self, other)

 

An other minus this vector.

Parameters:
Returns:
Difference (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__sub__(self, other)
(Subtraction operator)

 

This minus an other vector.

Parameters:
Returns:
Difference (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

__truediv__(self, scalar)

 

Divides this vector by a scalar.

Parameters:
  • scalar - The divisor (scalar).
Returns:
Quotient (Vector3d).
Raises:
  • TypeError - If scalar not scalar'

angleTo(self, other, vSign=None)

 

Computes the angle between this and an other vector.

Parameters:
  • other - The other vector (Vector3d).
  • vSign - Vector, if supplied (and out of the plane of this and the other), angle is signed positive if this->other is clockwise looking along vSign or negative in opposite direction, otherwise angle is unsigned.
Returns:
Angle (radians).
Raises:
  • TypeError - If other or vSign not a Vector3d.

copy(self)

 

Copies this vector.

Returns:
New, vector copy (Vector3d).

cross(self, other)

 

Cross product of this and an other vector.

Parameters:
Returns:
Cross product (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

dividedBy(self, factor)

 

Divides this vector by a scalar.

Parameters:
  • factor - The divisor (scalar).
Returns:
New, scaled vector (Vector3d).
Raises:
  • TypeError - If factor not scalar'

dot(self, other)

 

Dot (scalar) product of this and an other vector.

Parameters:
Returns:
Dot product (float).
Raises:
  • TypeError - Incompatible type(other).

equals(self, other, units=False)

 

Checks if this and an other vector are equal or equivalent.

Parameters:
  • other - The other vector (Vector3d).
  • units - Use units=True to compare the normalized, unit version of both vectors.
Returns:
True if vectors are identical (bool).
Raises:
  • TypeError - Incompatible type(other).

Example:

>>> v1 = Vector3d(52.205, 0.119)
>>> v2 = Vector3d(52.205, 0.119)
>>> e = v1.equals(v2)  # True

minus(self, other)

 

Subtracts an other vector from this vector.

Parameters:
Returns:
New vector difference (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

negate(self)

 

This vector in opposite direction.

Returns:
New, opposite vector (Vector3d).

others(self, other, name='other')

 

Refined class comparison.

Parameters:
  • other - The other vector (Vector3d).
  • name - Other's name (string).
Raises:
  • TypeError - Incompatible type(other).
Overrides: bases.Base.others

parse(self, str3d)

 

Parses an "x, y, z" string representing a Vector3d.

The x, y and z must be separated by a comma.

Parameters:
  • str3d - X, y and z string.
Returns:
New vector (Vector3d).
Raises:
  • ValueError - Invalid str3d.

plus(self, other)

 

Adds this and an other vector.

Parameters:
Returns:
New vector sum (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

rotate(self, axis, theta)

 

Rotates this vector by a specified angle around an axis.

See Rotation matrix from axis and angle and Quaternion-derived rotation matrix.

Parameters:
  • axis - The axis being rotated around (Vector3d).
  • theta - The angle of rotation (radians).
Returns:
New, rotated vector (Vector3d).

JS name: rotateAround.

rotateAround(self, axis, theta)

 

Rotates this vector by a specified angle around an axis.

See Rotation matrix from axis and angle and Quaternion-derived rotation matrix.

Parameters:
  • axis - The axis being rotated around (Vector3d).
  • theta - The angle of rotation (radians).
Returns:
New, rotated vector (Vector3d).

JS name: rotateAround.

sum(self, other)

 

Adds this and an other vector.

Parameters:
Returns:
New vector sum (Vector3d).
Raises:
  • TypeError - Incompatible type(other).

times(self, factor)

 

Multiplies this vector by a scalar.

Parameters:
  • factor - Scale factor (scalar).
Returns:
New, scaled vector (Vector3d).

to2ll(self)

 

Converts this vector to (geodetic) lat- and longitude.

Returns:
2-Tuple (lat, lon) in (degrees90, degrees180).

Example:

>>> v = Vector3d(0.500, 0.500, 0.707)
>>> a, b = v.to2ll()  # 45.0, 45.0

to3xyz(self)

 

Returns this vector as a 3-tuple.

Returns:
3-Tuple (x, y, z) as (scalars).

toStr(self, prec=5, fmt='(%s)', sep=', ')

 

String representation of this vector.

Parameters:
  • prec - Number of decimal places (int).
  • fmt - Enclosing format to use (string).
  • sep - Separator between components (string).
Returns:
Vector as "(x, y, z)" (string).
Overrides: bases.Base.toStr

unit(self)

 

Normalize this vector to unit length.

Returns:
Normalized vector (Vector3d).

Property Details

length

Gets the length (norm, magnitude) of this vector (float).

Get Method:
length(self) - Gets the length (norm, magnitude) of this vector (float).

x

Gets the X component (scalar).

Get Method:
x(self) - Gets the X component (scalar).

y

Gets the Y component (scalar).

Get Method:
y(self) - Gets the Y component (scalar).

z

Gets the Z component (scalar).

Get Method:
z(self) - Gets the Z component (scalar).