Position

Reference for the gtFrame.position module. This Module is designed to give a position vector which is linked with a frame of reference for increased usability. This way one must not keep track of which vector is defined in which frame of reference but rather just create the Position2d or Position3d objects, which will handle conversion and comparision.

This module implements the position class, which acts as a wrapper containing information about a position vector (either 2d or 3d numpy array) and the frame of reference on which the vector coordinates are defined.

Module Contents

Classes:
  • Position2d

  • Position3d

class gtFrame.position.BoundPosition2d(coordinates, reference, rtol=1e-12)

This is a wrapper class for Position2d. It has the same functionality as gtFrame.position.BoundPosition2d, only that the frame is bound to the position and gets updated instead of the coordinates.

Parameters:
  • coordinates (np.ndarray) – the coordinates of the 2d-vector representing a point in space

  • reference (gtFrame.basic.Frame2d) – the reference in which the coordinates are defined

  • rtol (float) – The relative tolerance to be used when comparing Position2d objects. The default is set to the global variable DEFAULT_RTOL.

add_direction(direction)

Returns the point that results in adding a direction vector to this point.

Parameters:

direction (gtFrame.direction.Direction2d) – a direction vector to be added to the point

Returns:

The resulting point from the addition with a direction vector. The returned Position2d object will inherit the reference and rtol of this (self) object.

Return type:

BoundPosition2d

apply_direction(direction)

Adds a given direction vector to this Position2d object. This results in the same point as would be returned by the .add_direction method. The difference is that .apply_direction applies the changes to the coordinates from this object, while .add_direction creates a new gtFrame.direction.Position2d object with the modified coordinates.

Parameters:

direction (gtFrame.direction.Direction2d) – a direction vector to be added to the point

Returns:

None

class gtFrame.position.BoundPosition3d(coordinates, reference, rtol=1e-12)

This is a wrapper class for Position3d. It has the same functionality as gtFrame.position.BoundPosition3d, only that the frame is bound to the position and gets updated instead of the coordinates.

Parameters:
  • coordinates (np.ndarray) – the coordinates of the 3d-vector representing a point in space

  • reference (gtFrame.basic.Frame3d) – the reference in which the coordinates are defined

  • rtol (float) – The relative tolerance to be used when comparing Position3d objects. The default is set to the global variable DEFAULT_RTOL.

add_direction(direction)

Returns the point that results in adding a direction vector to this point.

Parameters:

direction (gtFrame.direction.Direction3d) – a direction vector to be added to the point

Returns:

The resulting point from the addition with a direction vector. The returned Position3d object will inherit the reference and rtol of this (self) object.

Return type:

BoundPosition3d

apply_direction(direction)

Adds a given direction vector to this Position3d object. This results in the same point as would be returned by the .add_direction method. The difference is that .apply_direction applies the changes to the coordinates from this object, while .add_direction creates a new gtFrame.direction.Position3d object with the modified coordinates.

Parameters:

direction (gtFrame.direction.Direction3d) – a direction vector to be added to the point

Returns:

None

class gtFrame.position.Position2d(coordinates, reference, rtol=1e-12)

This class holds the coordinates of a 2d vector in a numpy array and the frame of reference in which they have been defined.

Parameters:
  • coordinates (np.ndarray) – the coordinates of the 2d-vector representing a point in space

  • reference (gtFrame.basic.Frame2d) – the reference in which the coordinates are defined

  • rtol (float) – The relative tolerance to be used when comparing Position2d objects. The default is set to the global variable DEFAULT_RTOL.

add_direction(direction)

Returns the point that results in adding a direction vector to this point.

Parameters:

direction (gtFrame.direction.Direction2d) – a direction vector to be added to the point

Returns:

The resulting point from the addition with a direction vector. The returned Position2d object will inherit the reference and rtol of this (self) object.

Return type:

Position2d

apply_direction(direction)

Adds a given direction vector to this Position2d object. This results in the same point as would be returned by the .add_direction method. The difference is that .apply_direction applies the changes to the coordinates from this object, while .add_direction creates a new gtFrame.direction.Position2d object with the modified coordinates.

Parameters:

direction (gtFrame.direction.Direction2d) – a direction vector to be added to the point

Returns:

None

get_direction(other)

Returns the direction from one position to another as a gtFrame.direction.Direction2d object. The gtFrame.direction.Direction2d object will be defined on the reference of this object (i.e. self.reference)

Parameters:

other (gtFrame.position.Position2d) – the other position to point to

Returns:

the direction from this position to ‘other’ as a gtFrame.direction.Direction2d object

Return type:

gtFrame.direction.Direction2d

get_distance(other)

Returns the distance from one position to another.

Parameters:

other (gtFrame.position.Position2d) – the other position

Returns:

distance to ‘other’ position

Return type:

float

transform_to(reference)

Transform the coordinates of the vector into a desired reference.

Parameters:

reference (gtFrame.basic.Frame2d) – the desired reference for the coordinates to be transformed into

Returns:

the transformed coordinates

Return type:

np.ndarray

class gtFrame.position.Position3d(coordinates, reference, rtol=1e-12)

This class holds the coordinates of a 3d vector in a numpy array and the frame of reference in which they have been defined.

Parameters:
  • coordinates (np.ndarray) – the coordinates of the 3d-vector representing a point in space

  • reference (gtFrame.basic.Frame3d) – the reference in which the coordinates are defined

  • rtol (float) – The relative tolerance to be used when comparing Position3d objects. The default is set to the global variable DEFAULT_RTOL.

add_direction(direction)

Returns the point that results in adding a direction vector to this point.

Parameters:

direction (gtFrame.direction.Direction3d) – a direction vector to be added to the point

Returns:

The resulting point from the addition with a direction vector. The returned Position2d object will inherit the reference and rtol of this (self) object.

Return type:

Position3d

apply_direction(direction)

Adds a given direction vector to this Position3d object. This results in the same point as would be returned by the .add_direction method. The difference is that .apply_direction applies the changes to the coordinates from this object, while .add_direction creates a new gtFrame.direction.Position3d object with the modified coordinates.

Parameters:

direction (gtFrame.direction.Direction3d) – a direction vector to be added to the point

Returns:

None

get_direction(other)

Returns the direction from one position to another as a gtFrame.direction.Direction3d object. The gtFrame.direction.Direction3d object will be defined on the reference of this object (i.e. self.reference)

Parameters:

other (gtFrame.position.Position3d) – the other position to point to

Returns:

the direction from this position to ‘other’ as a gtFrame.direction.Direction3d object

Return type:

gtFrame.direction.Direction3d

get_distance(other)

Returns the distance from one position to another.

Parameters:

other (gtFrame.position.Position3d) – the other position

Returns:

distance to ‘other’ position

Return type:

float

transform_to(reference)

Transform the coordinates of the vector into a desired reference.

Parameters:

reference (gtFrame.basic.Frame3d) – the desired reference for the coordinates to be transformed into

Returns:

the transformed coordinates

Return type:

np.ndarray