SBPhysicalVector3#
This class represents a three-dimensional physical vector.
SBPhysicalVector3() # a dimensionless zero vector
SBPhysicalVector3(1, 2, 3) # a dimensionless vector
SBPhysicalVector3([1, 2, 3]) # a dimensionless vector
SBPhysicalVector3(SBQuantity.position(1)) # a vector with the same components
SBPhysicalVector3(SBQuantity.squareTime(1))
SBPhysicalVector3(SBQuantity.nm(1.14), SBQuantity.nm(3.14), SBQuantity.nm(2.7))
There are multiple convenience constructors available for the commonly used physical vectors:
These convenience constructors internally call SBPhysicalVector3 samson.SBPhysicalVector3
with proper SBQuantity
and can be used as follows, without specifying the SBQuantity
unit:
SBVector3(1.0) # a vector in dimensionless units
SBForce3(0.0) # a vector in force units
SBPosition3(0.0, 1.0, 2.0) # a vector in length units
SBVector3(1, 2, 3) == SBPhysicalVector3(1, 2, 3) # True
SBPosition3(0.0, 1.0, 2.0) == SBPhysicalVector3(
SBQuantity.position(0.0),
SBQuantity.position(1.0),
SBQuantity.position(2.0)) # True
The code below shows various examples of accessing vector attributes, applying mathematical operations, etc:
# create a position vector in length units
pos = SBPosition3(0.0, 1.0, 2.0)
# this is the same as
#pos = SBPhysicalVector3(SBQuantity.position(0.0), SBQuantity.position(1.0), SBQuantity.position(2.0))
# arithmetic operations with numbers, units, and vectors
pos /= 2.0
pos * 1.5
# accessing components
pos.x # x-component of the vector
pos.y # y-component of the vector
pos.z # z-component of the vector
pos[0] # x-component of the vector
pos.value # components of the vector (read-only)
# operations with vectors
pos.norm() # returns norm of a vector
pos.norm2() # returns squared norm of a vector
pos.swap(1, 2) # swaps 2 components
pos.setZero() # sets all components to zero
# get normalized version of the vector
pos_norm = pos.normalizedVersion()
# get normalized version of the vector with units
pos_norm_u = pos.normalizedVersionWithUnits()
pos += SBPhysicalVector3(SBQuantity.angstrom(1))
time = SBQuantity.femtosecond(1)
# this will create a velocity vector in proper length/time units
velocity = pos / time
pos2 = SBPhysicalVector3(
SBQuantity.angstrom(1.14),
SBQuantity.angstrom(3.14),
SBQuantity.angstrom(2.7))
pos | pos2 # returns the dot product of vectors
pos ^ pos2 # returns the cross product of vectors
pos + pos2 # returns the sum of vectors
pos == pos2 # lexicographic comparison
pos < pos2 # lexicographic comparison
# In case of an operation with vectors of different units (e.g. nanometers and angstrom)
# the units of the first vector in the operation will be used for the resulting vector
pos_nm = SBPhysicalVector3(
SBQuantity.nanometer(1.1),
SBQuantity.nanometer(2.2),
SBQuantity.nanometer(3.3))
pos_a = SBPhysicalVector3(
SBQuantity.angstrom(1.14),
SBQuantity.angstrom(3.14),
SBQuantity.angstrom(2.72))
pos_a + pos_nm # the result is in angstroms
pos_nm - pos_a # the result is in nanometers
See also
SAMSON SDK: SBDTypePhysicalVector3
- class samson.SBPhysicalVector3(*args, **kwargs)#
Bases:
pybind11_object
This class represents physical vectors.
SAMSON API: SBDTypePhysicalVector3
Overloaded function.
__init__(self: samson.SBPhysicalVector3) -> None
Constructs the zero physical vector [ 0 0 0 ].
__init__(self: samson.SBPhysicalVector3, x: samson.SBQuantity.unitsSI) -> None
Constructs the physical vector [ x x x ].
__init__(self: samson.SBPhysicalVector3, x: samson.SBQuantity.unitsSI, y: samson.SBQuantity.unitsSI, z: samson.SBQuantity.unitsSI) -> None
Constructs the physical vector [ x y z ].
__init__(self: samson.SBPhysicalVector3, u: list[samson.SBQuantity.unitsSI]) -> None
Constructs the physical vector [ u[0] u[1] u[2] ].
__init__(self: samson.SBPhysicalVector3, x: float) -> None
Constructs the dimensionless physical vector [ x x x ].
__init__(self: samson.SBPhysicalVector3, x: float, y: float, z: float) -> None
Constructs the dimensionless physical vector [ x y z ].
__init__(self: samson.SBPhysicalVector3, vec3: list[float]) -> None
Constructs the dimensionless physical vector [ vec3[0] vec3[1] vec3[2] ].
- __add__(*args, **kwargs)#
Overloaded function.
__add__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__add__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
__add__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) -> samson.SBPhysicalVector3
- __eq__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __ge__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __gt__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __iadd__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) samson.SBPhysicalVector3 #
- __imul__(*args, **kwargs)#
Overloaded function.
__imul__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__imul__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
- __isub__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) samson.SBPhysicalVector3 #
- __itruediv__(*args, **kwargs)#
Overloaded function.
__itruediv__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__itruediv__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
- __le__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __lt__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __mul__(*args, **kwargs)#
Overloaded function.
__mul__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__mul__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
__mul__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) -> samson.SBPhysicalVector3
- __ne__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) bool #
- __neg__(self: samson.SBPhysicalVector3) samson.SBPhysicalVector3 #
- __radd__(*args, **kwargs)#
Overloaded function.
__radd__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__radd__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
- __rmul__(*args, **kwargs)#
Overloaded function.
__rmul__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__rmul__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
- __rsub__(*args, **kwargs)#
Overloaded function.
__rsub__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__rsub__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
- __sub__(*args, **kwargs)#
Overloaded function.
__sub__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__sub__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
__sub__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) -> samson.SBPhysicalVector3
- __truediv__(*args, **kwargs)#
Overloaded function.
__truediv__(self: samson.SBPhysicalVector3, arg0: float) -> samson.SBPhysicalVector3
__truediv__(self: samson.SBPhysicalVector3, arg0: samson.SBQuantity.unitsSI) -> samson.SBPhysicalVector3
__truediv__(self: samson.SBPhysicalVector3, arg0: samson.SBPhysicalVector3) -> samson.SBPhysicalVector3
- static computeAngle(a: samson.SBPhysicalVector3, b: samson.SBPhysicalVector3) samson.SBQuantity.unitsSI #
Computes the angle in radians between the vector a and the vector b
- static computeDihedralAngle(a: samson.SBPhysicalVector3, b: samson.SBPhysicalVector3, c: samson.SBPhysicalVector3, d: samson.SBPhysicalVector3) samson.SBQuantity.unitsSI #
Computes the dihedral angle in radians based on the four given positions a, b, c, d, where positions b and c form the main axis
- norm(self: samson.SBPhysicalVector3) samson.SBQuantity.unitsSI #
Returns the norm of this physical vector.
- norm2(self: samson.SBPhysicalVector3) samson.SBQuantity.unitsSI #
Returns the squared norm of this physical vector.
- normalize(self: samson.SBPhysicalVector3) None #
Normalizes this dimensionless physical vector.
- normalizeWithUnits(self: samson.SBPhysicalVector3) None #
Normalizes this physical vector while preserving units.
- normalizedVersion(self: samson.SBPhysicalVector3) samson.SBPhysicalVector3 #
Returns the dimensionless normalized version of this physical vector.
- normalizedVersionWithUnits(self: samson.SBPhysicalVector3) samson.SBPhysicalVector3 #
Returns the normalized version of this physical vector, but with preserved units.
- static sampledUnitSphere3(numberOfPoints: int) list[samson.SBPhysicalVector3] #
Returns a list with evenly distributed numberOfPoints points on a unit 3D sphere. The points on a unit 3D sphere are generated using the golden section spiral algorithm.
- Parameters:
numberOfPoints (integer) – The number of points on a unit 3D sphere.
- Returns:
A list of points on a unit 3D sphere.
- Return type:
list
- setOne(self: samson.SBPhysicalVector3) None #
Sets all components to one.
- setZero(self: samson.SBPhysicalVector3) None #
Sets all components to zero.
- str(self: samson.SBPhysicalVector3, fullName: bool = False) str #
Converts the physical vector to a string with a full unit name when fullName is True.
- swap(self: samson.SBPhysicalVector3, i: int, j: int) None #
Swaps components i and j of this physical vector.
- property isDimensionless#
Returns True if the physical vector is dimensionless
- property value#
- property x#
The x component.
- property y#
The y component.
- property z#
The z component.