SBPhysicalInterval#
This class represents a physical interval.
SBPhysicalInterval() # a dimensionless zero interval [0, 0]
SBPhysicalInterval(1, 2) # a dimensionless interval [1, 2]
SBPhysicalInterval([1, 2]) # a dimensionless interval [1, 2]
There are multiple convenience constructors available for the commonly used physical intervals:
These convenience constructors internally call SBPhysicalInterval
with proper SBQuantity
and can be used as follows, without specifying the SBQuantity
unit:
SBInterval(1, 2) # an interval in dimensionless units
SBLengthInterval(0, 10) # an interval in length units
SBForceInterval(1, 2) # an interval in force units
SBInterval(1, 2) == SBPhysicalInterval(1, 2) # True
SBLengthInterval(0, 1) == SBPhysicalInterval(SBQuantity.length(0), SBQuantity.length(1)) # True
See also
SAMSON SDK: SBDTypePhysicalInterval
- class samson.SBPhysicalInterval(*args, **kwargs)#
Bases:
pybind11_object
This class represents physical intervals.
SAMSON API: SBDTypePhysicalInterval
Overloaded function.
__init__(self: samson.SBPhysicalInterval) -> None
The default constructor, initializes all components to zero.
__init__(self: samson.SBPhysicalInterval, x: samson.SBQuantity.unitsSI) -> None
Constructs a physical interval [x, x].
__init__(self: samson.SBPhysicalInterval, x: samson.SBQuantity.unitsSI, y: samson.SBQuantity.unitsSI) -> None
Constructs a physical interval [x, y].
__init__(self: samson.SBPhysicalInterval, uvec2: list[samson.SBQuantity.unitsSI]) -> None
Constructs a physical interval [uvec2[0], uvec2[1]].
__init__(self: samson.SBPhysicalInterval, x: float) -> None
Constructs a dimensionless physical interval [x, x].
__init__(self: samson.SBPhysicalInterval, x: float, y: float) -> None
Constructs a dimensionless physical interval [x, y].
__init__(self: samson.SBPhysicalInterval, vec2: list[float]) -> None
Constructs a dimensionless physical interval [vec2[0], vec2[1]].
- __add__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) samson.SBPhysicalInterval #
- __contains__(*args, **kwargs)#
Overloaded function.
__contains__(self: samson.SBPhysicalInterval, v: samson.SBQuantity.unitsSI) -> bool
Returns True when this physical interval contains value v.
- Parameters:
v (samson.SBQuantity) – A quantity
- Return type:
bool
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> print(SBQuantity.nm(1.5) in interval) True
__contains__(self: samson.SBPhysicalInterval, v: float) -> bool
Returns True when this dimensionless physical interval contains value v.
- Parameters:
v (float) – A value
- Return type:
bool
Examples
>>> interval = SBInterval(1, 2) >>> print(1.5 in interval) True
__contains__(self: samson.SBPhysicalInterval, j: samson.SBPhysicalInterval) -> bool
Returns True when this physical interval contains value the physical interval j.
- Parameters:
j (samson.SBPhysicalInterval) – A physical interval
- Return type:
bool
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> print(SBLengthInterval(SBQuantity.nm(1.2), SBQuantity.nm(1.8)) in interval) True
- __eq__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) bool #
- __iadd__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) samson.SBPhysicalInterval #
- __imul__(*args, **kwargs)#
Overloaded function.
__imul__(self: samson.SBPhysicalInterval, arg0: float) -> samson.SBPhysicalInterval
__imul__(self: samson.SBPhysicalInterval, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalInterval
__imul__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) -> samson.SBPhysicalInterval
- __isub__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) samson.SBPhysicalInterval #
- __itruediv__(*args, **kwargs)#
Overloaded function.
__itruediv__(self: samson.SBPhysicalInterval, arg0: float) -> samson.SBPhysicalInterval
__itruediv__(self: samson.SBPhysicalInterval, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalInterval
__itruediv__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) -> samson.SBPhysicalInterval
- __mul__(*args, **kwargs)#
Overloaded function.
__mul__(self: samson.SBPhysicalInterval, arg0: float) -> samson.SBPhysicalInterval
__mul__(self: samson.SBPhysicalInterval, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalInterval
__mul__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) -> samson.SBPhysicalInterval
- __ne__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) bool #
- __neg__(self: samson.SBPhysicalInterval) samson.SBPhysicalInterval #
- __rmul__(*args, **kwargs)#
Overloaded function.
__rmul__(self: samson.SBPhysicalInterval, arg0: float) -> samson.SBPhysicalInterval
__rmul__(self: samson.SBPhysicalInterval, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalInterval
- __sub__(self: samson.SBPhysicalInterval, arg0: samson.SBPhysicalInterval) samson.SBPhysicalInterval #
- __truediv__(*args, **kwargs)#
Overloaded function.
__truediv__(self: samson.SBPhysicalInterval, arg0: float) -> samson.SBPhysicalInterval
__truediv__(self: samson.SBPhysicalInterval, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalInterval
- bound(*args, **kwargs)#
Overloaded function.
bound(self: samson.SBPhysicalInterval, v: samson.SBQuantity.unitsSI) -> None
Enlarges this physical interval to contain value v.
- Parameters:
v (samson.SBQuantity) – A quantity
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> interval.bound(SBQuantity.nm(3)) >>> print(interval) [1 nm, 3 nm]
bound(self: samson.SBPhysicalInterval, v: float) -> None
Enlarges this dimensionless physical interval to contain value v.
- Parameters:
v (float) – A value
Examples
>>> interval = SBInterval(1, 2) >>> interval.bound(3) >>> print(interval) [1 (dimensionless), 3 (dimensionless)]
bound(self: samson.SBPhysicalInterval, j: samson.SBPhysicalInterval) -> None
Enlarges this physical interval to contain the physical interval j.
- Parameters:
j (samson.SBPhysicalInterval) – A physical interval
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> interval.bound(SBLengthInterval(SBQuantity.nm(1.5), SBQuantity.nm(3))) >>> print(interval) [1 nm, 3 nm]
- center(self: samson.SBPhysicalInterval) samson.SBQuantity.unitsSI #
Returns the center, 0.5*(i[0]+i[1]), of the physical interval.
- contains(*args, **kwargs)#
Overloaded function.
contains(self: samson.SBPhysicalInterval, v: samson.SBQuantity.unitsSI) -> bool
Returns True when this physical interval contains value v.
- Parameters:
v (samson.SBQuantity) – A quantity
- Return type:
bool
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> print(interval.contains(SBQuantity.nm(1.5))) True
contains(self: samson.SBPhysicalInterval, v: float) -> bool
Returns True when this dimensionless physical interval contains value v.
- Parameters:
v (float) – A value
- Return type:
bool
Examples
>>> interval = SBInterval(1, 2) >>> print(interval.contains(1.5)) True
contains(self: samson.SBPhysicalInterval, j: samson.SBPhysicalInterval) -> bool
Returns True when this physical interval contains value the physical interval j.
- Parameters:
j (samson.SBPhysicalInterval) – A physical interval
- Return type:
bool
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> print(interval.contains(SBLengthInterval(SBQuantity.nm(1.2), SBQuantity.nm(1.8)))) True
- diameter(self: samson.SBPhysicalInterval) samson.SBQuantity.unitsSI #
Returns the diameter, i[1]-i[0], of the physical interval.
- expand(*args, **kwargs)#
Overloaded function.
expand(self: samson.SBPhysicalInterval, r: samson.SBQuantity.unitsSI) -> None
Expands this physical interval by offset r.
This function expands this physical interval by offset r: [a, b] becomes [a-r, b+r].
- Parameters:
r (samson.SBQuantity) – The offset.
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(1), SBQuantity.nm(2)) >>> interval.expand(SBQuantity.nm(1)) >>> print(interval) [0 nm, 3 nm]
expand(self: samson.SBPhysicalInterval, r: float) -> None
Expands this dimensionless physical interval by offset r.
This function expands this dimensionless physical interval by offset r: [a, b] becomes [a-r, b+r].
- Parameters:
r (samson.SBQuantity) – The offset.
Examples
>>> interval = SBInterval(1, 2) >>> interval.expand(1) >>> print(interval) [0 (dimensionless), 3 (dimensionless)]
- getAbsLower(self: samson.SBPhysicalInterval) samson.SBQuantity.unitsSI #
Returns the lower bound of the absolute value of this physical interval.
- getAbsUpper(self: samson.SBPhysicalInterval) samson.SBQuantity.unitsSI #
Returns the upper bound of the absolute value of this physical interval.
- isEmpty(*args, **kwargs)#
Overloaded function.
isEmpty(self: samson.SBPhysicalInterval, u: samson.SBPhysicalInterval) -> bool
Determines whether the intersection between this physical interval and the physical interval u is empty.
isEmpty(self: samson.SBPhysicalInterval, l: samson.SBQuantity.unitsSI, r: samson.SBQuantity.unitsSI) -> bool
Determines whether the intersection between this physical interval and the physical interval [l, r] is empty.
- setZero(self: samson.SBPhysicalInterval) None #
Sets the physical interval to [0, 0].
- shrink(*args, **kwargs)#
Overloaded function.
shrink(self: samson.SBPhysicalInterval, r: samson.SBQuantity.unitsSI) -> None
Shrinks this physical interval by offset r.
This function shrinks this physical interval by offset r: [a, b] becomes [a+r, b-r]. When the offset r is larger than the half-size of the physical interval, the interval becomes [m, m], where m is the center of the interval.
- Parameters:
r (samson.SBQuantity) – The offset.
Examples
>>> interval = SBLengthInterval(SBQuantity.nm(-2), SBQuantity.nm(2)) >>> interval.shrink(SBQuantity.nm(1)) >>> print(interval) [-1 nm, 1 nm]
shrink(self: samson.SBPhysicalInterval, r: float) -> None
Shrinks this dimensionless physical interval by offset r.
This function shrinks this dimensionless physical interval by offset r: [a, b] becomes [a+r, b-r]. When the offset r is larger than the half-size of the physical interval, the interval becomes [m, m], where m is the center of the interval.
- Parameters:
r (samson.SBQuantity) – The offset.
Examples
>>> interval = SBInterval(-2, 2) >>> interval.shrink(1) >>> print(interval) [-1 (dimensionless), 1 (dimensionless)]
- str(self: samson.SBPhysicalInterval, fullName: bool = False) str #
Converts the physical interval to a string with a full unit name when fullName is True.
- property isDimensionless#
Returns True if the physical interval is dimensionless
- property value#