Skip to main content

Transformations between related coordinate systems

Project description

Python package for coordinate conversions

This package allows to convert position and direction vectors between different coordinate frames. These frames must be arranged in a so called "mounttree", a tree-like structure which defines their relative orientation.

Usage

Load a mounttree in yaml format to get a CoordinateUniverse object

import mounttree as mnt
universe=mnt.load_mounttree('test/testmounttree.yaml')

If there are open variables in the tree, specify them before use:

universe.update(lat=0, lon=0, height=10,roll=0, pitch=0, yaw=0)

Now, we can get a transformation from 'HALO' to 'EARTH' coordinates

transform=self.universe.get_transformation('HALO','EARTH')

Use the transformation to convert positional or direction vectors

p1=transform.apply_point(0,0,0)
p2=transform.apply_direction(0,1,0)

We can also convert multiple points at once, if we provide numpy arrays of coordinates.

import numpy as np
x=np.array([[0,0,0],[0,1,1]])
y=np.array([[0,1,1],[0,0,0]])
z=np.array([[0,0,0],[1,1,1]])
px, py, pz=transform.apply_point(x,y,z)

Mounttree

Coordinate frames

Coordinate frames are objects to relate tuples of numbers (coordinates) to points in space. A point can be expressed in natural coordinates and cartesian coordinates. Each coordinate frame must provide functions to convert between natural and cartesian coordinates. Additionally, there must be a function to provide a natural orientation at each point in space. In mounttree_py, there are some predefined coordinate frames which are specified by the framespec keyword. Examples are 'WGS-84' and 'GRS-80' geospatial coordinate frames, where natural coordinates are latitude, longitude and height and natural orientation lets the x-axis of subframes point northward. If framespec is not given, a CartesianCoordinateFrame is assumed, where natural and cartesian coordinates are similar.

#Example how to specify a coordinate frame
framename: EARTH
framespec: WGS-84
position: [0,0,0]
rotation: [0,0,0]

Mounttree structure

A mounttree is a tree-like datastructure containing different coordinate frames with their relative orientation (see https://nbn-resolving.org/urn:nbn:de:bvb:19-261616, sec. 3.3.2). There must be exactly one root coordinate frame in the tree. Each coordinate frame can have any number of child frames, specified by the subframes keyword. A child frame in the tree needs a position and rotation relative to the parent.

Positions must be given as three floating point numbers in natural coordinates of the parent frame.

Rotations are assumed to be three floating point numbers, interpreted as euler angles relative to the local frame orientation of the parent frame at the childframe's position. Euler angles are in the "roll, pitch, yaw" convention, i.e. as sequence of rotations around 'x', 'y' and 'z' axis. Alternatively, a single string of a form similar to Ry(-85deg)*Rz(-90deg) can be provided at initialization, defining the rotation as a product of rotation matrices.

framename: EARTH
framespec: WGS-84
subframes:
    - framename: HALO
        position: [10.2,20.7,6000]
        rotation: [0,0,90]
        subframes:
            - framename: VNIR
            position: [0, 0, 0]
            rotation: Ry(-85deg)*Rz(-90deg)

Open variables

Instead of defining position and rotation of frames as three floating point numbers, some of the numbers can also be replaced by arbitrary strings. In this case, the strings are interpreted as open variables and must be associated to numbers with the "universe.update()" method before they can be used for transformations. If a transformation is requested and open variables without associated numbers are found to be necessary for this transformation, an error is thrown.

#Examples for open variables
framename: HALO
position: [lat, lon, height]
rotation: [roll, pitch, yaw]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mounttree-0.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

mounttree-0.0.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file mounttree-0.0.1.tar.gz.

File metadata

  • Download URL: mounttree-0.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for mounttree-0.0.1.tar.gz
Algorithm Hash digest
SHA256 82b0aec600a8000b7910ec037dd4a40bb0eabeed0dd166a3613af530ee52084f
MD5 793951a49b7ab3d9f98462d800e07049
BLAKE2b-256 73d8e67a2f964b58e0b7fe6f76d33072e79669c03a997a618ad31120334f390c

See more details on using hashes here.

File details

Details for the file mounttree-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mounttree-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for mounttree-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78d865e923f1a744e34161ca4a385b693f6e732b06f543a97f56225c4c5f4663
MD5 41b40d1b7462adaaadb62a18f09ccdcc
BLAKE2b-256 b2b7ffc574f16a81f47e0495a8620b87a3d63b5c8c7c3d2dffa2e000c1dc440d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page