MoveableThing#
- class blueprints.MoveableThing[source]#
Bases:
MoveableThingType,BaseThingThis class enables Things to have a position in space and an orientation specified using (improper) euler angles. To place the same Thing in multiple positions and orientations four shortcut methods can be used to construct copies of the Thing on the fly. Those method manipulate position and orientation and this manipulation is either relative to the current position/orientation or absolute, overwriting the current position/orientation.
Relative manipulation:#>>> thing = MoveableThing(pos=[0, 0, 1], alpha=0.8) >>> shifted_thing = thing.shift([2, 0, 0]) >>> shifted_thing.pos array([2., 0., 1.], dtype=float32) >>> rotated_thing = thing.rotate(beta=0.3) >>> rotated_thing.euler array([0.8, 0.3, 0. ], dtype=float32)
Absolute manipulation:#>>> located_thing = thing.locate([2, 0, 0]) >>> located_thing.pos array([2., 0., 0.], dtype=float32) >>> oriented_thing = thing.align(beta=0.3) >>> oriented_thing.euler array([0. , 0.3, 0. ], dtype=float32)
Size manipulation:#>>> scaled_thing = thing.scaled(3) >>> scaled_thing.pos array([0., 0., 3.], dtype=float32) >>> scaled_thing.size array([1.5, 1.5, 1.5], dtype=float32)
For
MoveableThinginstances in a kinematic tree, position and orientation are locally defined, describing the relative change in position and rotation to their parents. If one wants to create relocated copies usingshift()orlocate()for global coordinates thegloballyargument can be set on call.Relocation shortcuts also take other
MoveableThinginstances as arguments. This results in a change in position by the arguments position.>>> thing_a = MoveableThing(pos=[0, 0, 1]) >>> thing_b = MoveableThing(pos=[0, 1, 0]) >>> thing_c = thing_a.shift(pos=thing_b) >>> thing_c.pos array([0., 1., 1.], dtype=float32)
Attributes Summary
Note that euler angles are not additive for rotations.
The global angular velocity for all axis
Note that euler angles are not additive for rotations.
Note that euler angles are not additive for rotations.
Note that euler angles are not additive for rotations.
Individual components of
global_poscan be found inglobal_x,global_yandglobal_z.The matrix is constructed for global orientation) — in contrast to local orientation.
The matrix is constructed for local orientation (w.r.t.
The global velocity for all axis
If the whole position should be updated use
posinstead.If the whole position should be updated use
posinstead.If the whole position should be updated use
posinstead.Methods Summary
align([alpha, beta, gamma, quat])This method creates a copy that is oriented according to the (improper) euler angles.
locate([pos, globally, x, y, z])This method creates a copy that is relocated to
pos.rotate([alpha, beta, gamma, quat, globally, ...])This method creates a copy that is rotated by the (improper) euler angles.
scaled(scale[, keep_pos])This method creates a copy that is rescaled in size and position.
shift([pos, globally, x, y, z])This method creates a copy that is shifted by
pos.Attributes Documentation
- alpha#
Note that euler angles are not additive for rotations. Use
rotate()for this.- Returns:
The (improper) euler angle of rotation around the X-axis.
- Return type:
float | None
- angular_vel#
The global angular velocity for all axis
- Return type:
np.ndarray
- beta#
Note that euler angles are not additive for rotations. Use
rotate()for this.- Returns:
The (improper) euler angle of rotation around the Y-axis.
- Return type:
float | None
- euler#
Note that euler angles are not additive for rotations. Use
rotate()for this.- Returns:
The orientation is represented as a vector containing the (improper) euler angles array([alpha, beta, gamma]).
- Return type:
np.ndarray
- gamma#
Note that euler angles are not additive for rotations. Use
rotate()for this.- Returns:
The (improper) euler angle of rotation around the Z-axis.
- Return type:
float | None
- global_pos#
Individual components of
global_poscan be found inglobal_x,global_yandglobal_z.- Returns:
The position of the Thing is given in global coordinates.
- Return type:
np.ndarray
- global_rotation_matrix#
The matrix is constructed for global orientation) — in contrast to local orientation. For this use
Rotation.E_rot.- Returns:
The rotation matrix for the Thins orientation.
- Return type:
np.ndarray
- pos#
Individual components of
poscan be found inx,yandz.- Returns:
The position of the Thing is given in local coordinates.
- Return type:
np.ndarray
- rotation_matrix#
The matrix is constructed for local orientation (w.r.t. to parent orientation) — in contrast to global orientation. For this use
Rotation.global_orientation.- Returns:
The rotation matrix for the Thins orientation.
- Return type:
np.ndarray
- vel#
The global velocity for all axis
- Return type:
np.ndarray
- x#
If the whole position should be updated use
posinstead.- Returns:
The
X-coordinate of the Things local position.- Return type:
float | None
- y#
If the whole position should be updated use
posinstead.- Returns:
The
Y-coordinate of the Things local position.- Return type:
float | None
- z#
If the whole position should be updated use
posinstead.- Returns:
The
Z-coordinate of the Things local position.- Return type:
float | None
Methods Documentation
- align(alpha=0.0, beta=0.0, gamma=0.0, quat=None, **kwargs)[source]#
This method creates a copy that is oriented according to the (improper) euler angles.
>>> MoveableThing(alpha=TAU/4, beta=0, gamma=TAU/8).align(beta=PI).euler array([0, PI, 0], dtype=float32)
- Parameters:
alpha (
int | float, optional) – The (improer) euler angle of rotation around theX-axis in radians.beta (
int | float, optional) – The (improer) euler angle of rotation around theY-axis in radians.gamma (
int | float, optional) – The (improer) euler angle of rotation around theZ-axis in radians.**kwargs – Keyword arguments are passed to the
copy().quat (list[int | float] | ndarray | None)
- Returns:
A copy of the Thing set to the given orientation is returned.
- Return type:
blue.MoveableThingType
- locate(pos=None, globally=False, x=None, y=None, z=None, **kwargs)[source]#
This method creates a copy that is relocated to
pos.>>> MoveableThing(pos=[5, 0, 0]).locate(x=-3, y=10).pos array([-3., 10., 0.], dtype=float32)
- Parameters:
pos (
list[int | float] | np.ndarray | blue.MoveableThingType | None) – The position to which the Thing is shifted, optionally anotherMoveableThingcan be passed in which case the position of this Thing is taken.globally (
bool, optional) – Determining whether the relocation is relative to the local orientation or the global orientation.x (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just theXcomponent of the position is to be changed.y (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just theYcomponent of the position is to be changed.z (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just theZcomponent of the position is to be changed.**kwargs – Keyword arguments are passed to
copy().
- Returns:
A relocated copy is returned.
- Return type:
blue.MoveableThingType
- rotate(alpha=0, beta=0, gamma=0, quat=None, globally=True, center=None, **kwargs)[source]#
This method creates a copy that is rotated by the (improper) euler angles.
>>> MoveableThing(alpha=TAU/4, beta=0, gamma=TAU/8).rotate(beta=PI).euler array([-TAU/4, PI, TAU/8], dtype=float32)
- Parameters:
alpha (
int | float, optional) – The (improer) euler angle of rotation around theX-axis in radians.beta (
int | float, optional) – The (improer) euler angle of rotation around theY-axis in radians.gamma (
int | float, optional) – The (improer) euler angle of rotation around theZ-axis in radians.globally (
bool, optional) – Determining whether the rotation is relative to the local orientation or the global orientation.center (
list[int | float] | np.ndarray | blue.MoveableThingType | None, optional) – The copied Thing will be rotated around center. If center is None, it will be rotated at its position instead.**kwargs – Keyword arguments are passed to the
copy().quat (list[int | float] | ndarray | None)
- Returns:
A copy of the returned Thing is returned.
- Return type:
blue.MoveableThingType
- scaled(scale, keep_pos=False, **kwargs)[source]#
This method creates a copy that is rescaled in size and position.
- scaleint | float | None, optional
The scaling factor by which the Things size and position is increased.
- keep_posbool
If set, the position is kept, otherwise, the position is scaled as well.
- **kwargs
Keyword arguments are passed to the
copy().
- Returns:
A copy of the rescaled Thing.
- Return type:
blue.MoveableThingType- Parameters:
scale (int | float)
keep_pos (bool)
- shift(pos=None, globally=False, x=None, y=None, z=None, **kwargs)[source]#
This method creates a copy that is shifted by
pos.>>> MoveableThing(pos=[5, 0, 0]).shift(x=-3, y=10).pos array([2., 10., 0.], dtype=float32)
- Parameters:
pos (
list[int | float] | np.ndarray | blue.MoveableThingType | None) – The amount by which the Thing is shifted, optionally anotherMoveableThingcan be passed in which case the position of this Thing is taken.globally (
bool, optional) – Determining whether the shift is relative to the local orientation or the global orientation.x (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just the X component of the position is to be changed.y (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just the Y component of the position is to be changed.z (
int | float | np.int32 | np.int64 | np.float32 | np.float64 | None) – This argument can be set if just the Z component of the position is to be changed.**kwargs – Keyword arguments are passed to the
copy().
- Returns:
A shifted copy is returned.
- Return type:
blue.MoveableThingType
- __init__(pos=[0.0, 0.0, 0.0], alpha=0.0, beta=0.0, gamma=0.0, name=None, x=None, y=None, z=None, quat=None, **kwargs)[source]#
MoveableThing implements multiple Thing location and orientation in (improper) euler angles in radians.
- Parameters:
pos (
list[int | float] | np.ndarray | None, optional) – Represents the position of the object. Changing this attribute also changes the propertiesx,yandz.alpha (
int | float | None, optional) – (Improper) euler angle of rotation around the x-axis in radian. Changing this value also changes theeulerproperty.beta (
int | float | None, optional) – (Improper) euler angle of rotation around the y-axis in radian. Changing this value also changes theeulerproperty.gamma (
int | float | None, optional) – (Improper) euler angle of rotation around the z-axis in radian. Changing this value also changes theeulerproperty.name (
str | None, optional) – The user specified name for the Thing.x (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the X position coordinate.y (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Y position coordinate.z (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Z position coordinate.quat (
list [ int | float ] | np.ndarray | None, optional) – If set, the quaternion orientation overwrites the euler anglesalpha,betaandgamma.**kwargs – Keyword arguments are passed to
super().__init__.
- classmethod __new__(*args, **kwargs)#