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

# Class Vector3d

     object --+
              |
    bases.Named --+
                  |
        bases.Based --+
                      |
      bases.VectorBased --+
                          |
                         Vector3d

Known Subclasses:
  - ellipsoidalBase.CartesianBase
  - , nvector.Nvector

Generic 3-D vector manipulation.

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

- n-vector representing a normal to point on earth's surface
- earth-centered, earth-fixed vector (= n-vector for spherical model)
- great circle normal to vector
- motion vector on earth's surface
- etc.

Instance Methods
__abs__(self) Return the norm of this vector (scalar). |
__add__(self, other) Add this to an other vector (Vector3d). |
__cmp__(self, other) Compare this and an other vector |
__div__(self, scalar) Divide 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) Add this to an other vector (Vector3d). |
__imatmul__(self, other) Compute the cross product of this and an other vector. |
__imul__(self, scalar) Multiply this vector by a scalar |
__init__(self, x, y, z, ll=None, name=`'````'`) New 3-D vector. |
__isub__(self, other) Subtract an other vector from this vector. |
__itruediv__(self, scalar) Divide 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) Compute the cross product of this and an other vector. |
__mul__(self, scalar) Multiply this vector by a scalar |
__ne__(self, other) Is this vector not equal to an other vector? |
__neg__(self) Negate this vector. |
__pos__(self) Copy this vector. |
__radd__(self, other) Add this to an other vector (Vector3d). |
__rmatmul__(self, other) Compute the cross product of an other and this vector. |
__rmul__(self, scalar) Multiply this vector by a scalar |
__rsub__(self, other) Subtract this vector from an other vector. |
__sub__(self, other) Subtract an other vector from this vector. |
__truediv__(self, scalar) Divide this vector by a scalar. |
angleTo(self, other, vSign=None) Compute the angle between this and an other vector. |
copy(self) Copy this vector. |
cross(self, other, raiser=None) Compute the cross product of this and an other vector. |
dividedBy(self, factor) Divide this vector by a scalar. |
dot(self, other) Compute the dot (scalar) product of this and an other vector. |
equals(self, other, units=False) Check if this and an other vector are equal or equivalent. |
minus(self, other) Subtract an other vector from this vector. |
negate(self) Return this vector in opposite direction. |
others(self, other, name=`'``other``'`) Refined class comparison. |
parse(self, str3d) Parse an "x, y, z" string representing a Vector3d. |
plus(self, other) Add this vector and an other vector. |
rotate(self, axis, theta) Rotate this vector by a specified angle around an axis. |
rotateAround(self, axis, theta) Rotate this vector by a specified angle around an axis. |
sum(self, other) Add this vector and an other vector. |
times(self, factor) Multiply this vector by a scalar. |
to2ll(self) Convert this vector to (geodetic) lat- and longitude. |
to3xyz(self) Return this vector as a 3-tuple. |
toStr(self, prec=5, fmt=`'``(%s)``'`, sep=`'``,` `'`) Return a string representation of this vector. |
unit(self) Normalize this vector to unit length. |
Inherited from `bases.Based`: `__repr__`, `__str__`, `classof`, `toStr2` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Properties
| crosserrors Get CrossErrors (bool).
| length Get the length (norm, magnitude) of this vector (float).
| x Get the X component (scalar).
| y Get the Y component (scalar).
| z Get the Z component (scalar).
Inherited from `bases.Named`: `classname`, `classnaming`, `name` Inherited from `object`: `__class__`

Method Details

### __abs__(self) |
Return the norm of this vector (scalar). Returns: Norm, unit length (float);

### __add__(self, other) (Addition operator) |
Add this to an other vector (Vector3d). Returns: Vectorial sum (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __cmp__(self, other) (Comparison operator) |
Compare this and an other vector Parameters: `other` - The other vector (Vector3d). Returns: -1, 0 or +1 (int). Raises: `TypeError` - Incompatible type(other).

### __div__(self, scalar) |
Divide 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: `other` - The other vector (Vector3d). 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: `other` - The other vector (Vector3d). 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: `other` - The other vector (Vector3d). Returns: True if so (bool). Raises: `TypeError` - Incompatible type(other).

### __iadd__(self, other) |
Add this to an other vector (Vector3d). Returns: Vectorial sum (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __imatmul__(self, other) |
Compute the cross product of this and an other vector. Parameters: `other` - The other vector (Vector3d). Returns: Cross product (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __imul__(self, scalar) |
Multiply this vector by a scalar Parameters: `scalar` - Factor (scalar). Returns: Product (Vector3d).

### __init__(self, x, y, z, ll=None, name=`'````'`) (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. `ll` - Optional, original latlon (LatLon). `name` - Optional name (string). Overrides: object.__init__

### __isub__(self, other) |
Subtract an other vector from this vector. Parameters: `other` - The other vector (Vector3d). Returns: Difference (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __itruediv__(self, scalar) |
Divide 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: `other` - The other vector (Vector3d). 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: `other` - The other vector (Vector3d). Returns: True if so (bool). Raises: `TypeError` - Incompatible type(other).

### __matmul__(self, other) |
Compute the cross product of this and an other vector. Parameters: `other` - The other vector (Vector3d). Returns: Cross product (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __mul__(self, scalar) |
Multiply 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: `other` - The other vector (Vector3d). Returns: True if so (bool). Raises: `TypeError` - Incompatible type(other).

### __neg__(self) |
Negate this vector. Returns: Negative (Vector3d)

### __pos__(self) |
Copy this vector. Returns: Positive (Vector3d)

### __radd__(self, other) (Right-side addition operator) |
Add this to an other vector (Vector3d). Returns: Vectorial sum (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __rmatmul__(self, other) |
Compute the cross product of an other and this vector. Parameters: `other` - The other vector (Vector3d). Returns: Cross product (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __rmul__(self, scalar) |
Multiply this vector by a scalar Parameters: `scalar` - Factor (scalar). Returns: Product (Vector3d).

### __rsub__(self, other) |
Subtract this vector from an other vector. Parameters: `other` - The other vector (Vector3d). Returns: Difference (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __sub__(self, other) (Subtraction operator) |
Subtract an other vector from this vector. Parameters: `other` - The other vector (Vector3d). Returns: Difference (Vector3d). Raises: `TypeError` - Incompatible type(other).

### __truediv__(self, scalar) |
Divide this vector by a scalar. Parameters: `scalar` - The divisor (scalar). Returns: Quotient (Vector3d). Raises: `TypeError` - If scalar not scalar'

### angleTo(self, other, vSign=None) |
Compute the angle between this and an other vector. Parameters: `other` - The other vector (Vector3d). `vSign` - Optional 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) |
Copy this vector. Returns: The copy (Vector3d or subclass thereof). Overrides: bases.Named.copy

### cross(self, other, raiser=None) |
Compute the cross product of this and an other vector. Parameters: `other` - The other vector (Vector3d). `raiser` - Optional, CrossError label if raised (string). Returns: Cross product (Vector3d). Raises: `CrossError` - Zero or near-zero cross product and both raiser and crosserrors set. `TypeError` - Incompatible type(other). `ValueError` - Coincident or colinear to other.

### dividedBy(self, factor) |
Divide this vector by a scalar. Parameters: `factor` - The divisor (scalar). Returns: New, scaled vector (Vector3d). Raises: `TypeError` - If factor not scalar. `ValueError` - Invalid or zero factor.

### dot(self, other) |
Compute the dot (scalar) product of this and an other vector. Parameters: `other` - The other vector (Vector3d). Returns: Dot product (float). Raises: `TypeError` - Incompatible type(other).

### equals(self, other, units=False) |
Check if this and an other vector are equal or equivalent. Parameters: `other` - The other vector (Vector3d). `units` - Optionally, 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) |
Subtract an other vector from this vector. Parameters: `other` - The other vector (Vector3d). Returns: New vector difference (Vector3d). Raises: `TypeError` - Incompatible type(other).

### negate(self) |
Return 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` - Optional, other's name (string). Returns: None. Raises: `TypeError` - Incompatible type(other). Overrides: bases.Based.others

### parse(self, str3d) |
Parse 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) |
Add this vector and an other vector. Parameters: `other` - The other vector (Vector3d). Returns: New vector sum (Vector3d). Raises: `TypeError` - Incompatible type(other).

### rotate(self, axis, theta) |
Rotate 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) |
Rotate 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) |
Add this vector and an other vector. Parameters: `other` - The other vector (Vector3d). Returns: New vector sum (Vector3d). Raises: `TypeError` - Incompatible type(other).

### times(self, factor) |
Multiply this vector by a scalar. Parameters: `factor` - Scale factor (scalar). Returns: New, scaled vector (Vector3d). Raises: `TypeError` - If factor not scalar.

### to2ll(self) |
Convert 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) |
Return this vector as a 3-tuple. Returns: 3-Tuple (x, y, z) as (scalars).

### toStr(self, prec=5, fmt=`'``(%s)``'`, sep=`'``,` `'`) |
Return a string representation of this vector. Parameters: `prec` - Optional number of decimal places (int). `fmt` - Optional, enclosing format to use (string). `sep` - Optional separator between components (string). Returns: Vector as "(x, y, z)" (string). Overrides: bases.Based.toStr

### unit(self) |
Normalize this vector to unit length. Returns: Normalized vector (Vector3d).

Property Details

### crosserrors Get CrossErrors (bool). Get Method: crosserrors(self) - Get CrossErrors (bool). Set Method: crosserrors(self, raiser) - Set the raising of CrossErrors (bool).

### length Get the length (norm, magnitude) of this vector (float). Get Method: length(self) - Get the length (norm, magnitude) of this vector (float). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### x Get the X component (scalar). Get Method: x(self) - Get the X component (scalar). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### y Get the Y component (scalar). Get Method: y(self) - Get the Y component (scalar). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### z Get the Z component (scalar). Get Method: z(self) - Get the Z component (scalar). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.