classdef Interval < handle
% An Interval has a left endpoint and a right endpoint.

properties
left
right
end

methods
function Inter = Interval(lt, rt)
% Constructor: construct an Interval object
Inter.left= lt;
Inter.right= rt;
end

function scaleRight(self, f)
% Scale the interval by a factor f; left end remains the same.
w= self.right - self.left;
self.right= self.left + w*f;
end

function shift(self, s)
% Shift the interval by s
self.left= self.left + s;
self.right= self.right + s;
end

function tf = isIn(self, other)
% tf is true if this Interval itself is in the other Interval
tf= self.left>=other.left && self.right<=other.right;
end

end %methods

end %classdef