Direction
Reference for the gtFrame.direction module.
This module implements direction vectors which rotate with changing frames of
reference, but are not impacted by translation of those references. This can be
achieved with the gtFrame.direction.Direction2d and
gtFrame.direction.Direction3d classes, which hold the direction
vector as coordinates and the frame of reference on which it is defined.
This module implements the Direction2d and Direction3d classe, which serve to represent direction-vectors (like velocity or acceleration). They hold information on the frame of reference in which they are defined and can be converted to different frames of reference by rotation. Unlike position vectors these vectors remain unchanged by translation.
Module Contents
- Classes:
Direction2d
Direction3d
- class gtFrame.direction.Direction2d(vector, reference, rtol=1e-12)
This class holds information about a direction expressed as a 2d-array of coordinates defined on a specific frame of reference.
- Parameters:
vector (np.ndarray) – the direction expressed as a vector in the given frame of reference
reference (gtFrame.basic.Frame2d) – the frame of reference on which the vector is defined
rtol (float) – The relative tolerance to be used when comparing Direction2d objects. The default is set to the global variable DEFAULT_RTOL.
- apply_direction(direction)
Adds the vector of ‘direction’ to the vector of self, after transforming it in to self.reference.
- Parameters:
direction (Direction2d) – the Direction2d object to be applied to this one
- Returns:
None
- length()
Returns the length (i.e. euclidean norm) of the direction vector.
- Returns:
the euclidean norm of the direction vector
- Return type:
float
- scale(factor)
Scales the length of the direction vector, by multiplying it with a factor.
- Parameters:
factor (float) – the factor for scaling the vector
- Returns:
None
- transform_to(reference)
Transform the direction vector into another frame of reference.
- Parameters:
reference (gtFrame.basic.Frame2d) – the frame of reference to transform to
- Returns:
the direction vector in the other frame of reference
- Return type:
np.ndarray
- class gtFrame.direction.Direction3d(vector, reference, rtol=1e-12)
This class holds information about a direction expressed as a 3d-array of coordinates defined on a specific frame of reference.
- Parameters:
vector (np.ndarray) – the direction expressed as a vector in the given frame of reference
reference (gtFrame.basic.Frame3d) – the frame of reference on which the vector is defined
rtol (float) – The relative tolerance to be used when comparing Direction3d objects. The default is set to the global variable DEFAULT_RTOL.
- apply_direction(direction)
Adds the vector of ‘direction’ to the vector of self, after transforming it in to self.reference.
- Parameters:
direction (Direction3d) – the Direction3d object to be applied to this one
- Returns:
None
- length()
Returns the length (i.e. euclidean norm) of the direction vector.
- Returns:
the euclidean norm of the direction vector
- Return type:
float
- scale(factor)
Scales the length of the direction vector, by multiplying it with a factor.
- Parameters:
factor (float) – the factor for scaling the vector
- Returns:
None
- transform_to(reference)
Transform the direction vector into another frame of reference.
- Parameters:
reference (gtFrame.basic.Frame3d) – the frame of reference to transform to
- Returns:
the direction vector in the other frame of reference
- Return type:
np.ndarray