Spaces:
Runtime error
Runtime error
import numpy as np | |
from shapely.geometry import * | |
from shapely.affinity import * | |
from env_utils import get_obj_pos, get_obj_names | |
from ctrl_utils import put_first_on_second | |
# define function: total = get_total(xs=numbers). | |
def get_total(xs): | |
return np.sum(xs) | |
# define function: y = eval_line(x, slope, y_intercept=0). | |
def eval_line(x, slope, y_intercept): | |
return x * slope + y_intercept | |
# define function: pt = get_pt_to_the_left(pt, dist). | |
def get_pt_to_the_left(pt, dist): | |
return pt + [-dist, 0] | |
# define function: pt = get_pt_to_the_top(pt, dist). | |
def get_pt_to_the_top(pt, dist): | |
return pt + [0, dist] | |
# define function line = make_line_by_length(length=x). | |
def make_line_by_length(length): | |
line = LineString([[0, 0], [length, 0]]) | |
return line | |
# define function: line = make_vertical_line_by_length(length=x). | |
def make_vertical_line_by_length(length): | |
line = make_line_by_length(length) | |
vertical_line = rotate(line, 90) | |
return vertical_line | |
# define function: pt = interpolate_line(line, t=0.5). | |
def interpolate_line(line, t): | |
pt = line.interpolate(t, normalized=True) | |
return np.array(pt.coords[0]) | |
# example: scale a line by 2. | |
line = make_line_by_length(1) | |
new_shape = scale(line, xfact=2, yfact=2) | |
# example: put object1 on top of object0. | |
put_first_on_second('object1', 'object0') | |
# example: get the position of the first object. | |
obj_names = get_obj_names() | |
pos_2d = get_obj_pos(obj_names[0]) |