def __init__(self, rest_length=0.0): Terminus.__init__(self) self.coordinates = [] self.frames = [] if rest_length < 0.0: raise Error("The rest length of a spring must be zero or positive.") self.rest_length = rest_length
def __init__(self, rest_length=0.0): Terminus.__init__(self) self.coordinates = [] self.frames = [] if rest_length < 0.0: raise Error( "The rest length of a spring must be zero or positive.") self.rest_length = rest_length
def sanity_check(self): if len(self.frames) != 2: raise Error("A Spring expression needs two frames.") if len(self.input_variables) > 2: raise Error("A Spring expression needs at most two input_variables.") if len(self.coordinates) != 2: raise Error("A Spring energy term must have two coordinates.") Terminus.sanity_check(self)
def register_input_variable(self, variable, coordinate): if not (isinstance(variable, Frame) or isinstance(variable, Translation) or isinstance(variable, NoFrame)): raise Error("Expression requires iterative.var.Frame or iterative.var.Translation as variable") self.coordinates.append(coordinate) self.frames.append(variable) if not isinstance(variable, NoFrame): variable.add_mass(coordinate) Terminus.register_input_variable(self, variable)
def sanity_check(self): if len(self.frames) != 2: raise Error("A Spring expression needs two frames.") if len(self.input_variables) > 2: raise Error( "A Spring expression needs at most two input_variables.") if len(self.coordinates) != 2: raise Error("A Spring energy term must have two coordinates.") Terminus.sanity_check(self)
def register_input_variable(self, variable, coordinate): if not (isinstance(variable, Frame) or isinstance( variable, Translation) or isinstance(variable, NoFrame)): raise Error( "Expression requires iterative.var.Frame or iterative.var.Translation as variable" ) self.coordinates.append(coordinate) self.frames.append(variable) if not isinstance(variable, NoFrame): variable.add_mass(coordinate) Terminus.register_input_variable(self, variable)