def step_impl_generic_ray_full_with_sqrt(context, item, px, py, pz, vx, vynum, vydenom, vznum, vzdenom): pt = base.point(float(px), float(py), float(pz)) vc = base.vector(float(vx), -math.sqrt(float(vynum)) / float(vydenom), math.sqrt(float(vznum)) / float(vzdenom)) ensure_context_has_dict(context) context.dict[item] = base.ray(pt, vc)
def step_impl_generic_ray_full_with_sqrt2(context, item, pznum, pzdenom, vx, vy, vz): pt = base.point(np.float32(0), np.float32(0), np.float32(math.sqrt(float(pznum)) / float(pzdenom))) vc = base.vector(np.float32(vx), np.float32(vy), np.float32(vz)) ensure_context_has_dict(context) context.dict[item] = base.ray(pt, vc)
def __init__(self, p1, p2, outer, inner): self.name = '' # defining and calculating required properties axis = p2 - p1 length = axis.mag cm_local = vector(0.5 * length * axis.unit, p1.frame) # Refering the cm to the global reference frame # cm_global=p1+cm_local cm_global=recursive_transformation(axis.frame,grf).dot(p1)+\ recursive_transformation(axis.frame,grf).dot(cm_local) volume = (np.pi / 4) * (outer - inner)**2 * length * 10**-3 # cm cube mass = 7.9 * volume # defining the self.attributes self.cm_local = vector(cm_local, frame=axis.frame) self.cm_global = point(self.name + '_cm', cm_global) self.length = length self.volume = volume self.mass = mass self.p1 = p1 self.p2 = p2 self.r = outer / 2
def __init__(self, fore, aft, outer, body, outer_d=10, inner_d=8): super().__init__(fore, aft, outer_d, inner_d) self.name = body.name self.fore = fore self.aft = aft self.outer = outer # generating the two tubes tube1 = tube(fore, outer, outer_d, inner_d) tube2 = tube(aft, outer, outer_d, inner_d) # a_arm mass as a sum of the two tubes self.mass = tube1.mass + tube2.mass # calculating the x,y,z coordinates of the centroid x = ((tube1.cm_global.x * tube1.mass) + (tube2.cm_global.x * tube2.mass)) / self.mass y = ((tube1.cm_global.y * tube1.mass) + (tube2.cm_global.y * tube2.mass)) / self.mass z = ((tube1.cm_global.z * tube1.mass) + (tube2.cm_global.z * tube2.mass)) / self.mass self.cm_global = point(self.name + '_cm', [x, y, z]) #updating the body-coordinate-system bcs to be coincident on the cm and #parallel to the grf body.R = self.cm_global body.typ = outer.typ
def step_given_object_point_value(context, item, x, y, z): ensure_context_has_tuple(context) context.tuple[str(item)] = base.point(float(x), float(y), float(z))
def step_ray_element_has_value(context, item, element, x, y, z): assert(item in context.dict.keys()) comps_object_element = context.dict[str(item)].__dict__[str(element)] test_value = base.point(float(x), float(y), float(z)) assert(base.equal(comps_object_element, test_value))
def step_impl_generic_when_ray_full(context, item, px, py, pz, vx, vy, vz): pt = base.point(float(px), float(py), float(pz)) vc = base.vector(float(vx), float(vy), float(vz)) ensure_context_has_dict(context) context.dict[item] = base.ray(pt, vc)
def step_impl_generic_point(context, item, x, y, z): ensure_context_has_tuple(context) context.tuple[item] = base.point(float(x), float(y), float(z))
def step_impl_eval_ray_position(context, item, t, x, y, z): assert (item in context.dict.keys()) ray = context.dict[str(item)] ray_position = ray.position(float(eval(t))) test_point = base.point(float(x), float(y), float(z)) assert (base.equal(ray_position, test_point))
def step_impl_ray_element_point(context, item, element, x, y, z): assert (item in context.dict.keys()) assert (element in valid_ray_elements) thing = context.dict[str(item)].__dict__[str(element)] vec4_value = base.point(float(x), float(y), float(z)) assert (base.equal(thing, vec4_value))