Math Classes¶
Note
Many of these classes wrap the vanilla Sims 4 classes to provide insight into the properties and functions of them.
Comparison (Equal To)¶
Comparison (Greater Than)¶
Comparison (Less Than)¶
Comparison (Greater Than Or Equal To)¶
Comparison (Less Than Or Equal To)¶
Location¶
- class CommonLocation(transform, routing_surface, parent_ref=None, joint_name_or_hash=None, slot_hash=0)¶
Bases:
objectA class that contains locational data.
- static empty()¶
Create an empty location.
- Returns:
An empty location.
- Return type:
- static from_location(location)¶
Convert a vanilla Location object into a CommonLocation.
- Parameters:
location (Union[Location, CommonLocation]) – An instance of a Location.
- Returns:
An instance of a CommonLocation or None if the object failed to convert.
- Return type:
Union[CommonLocation, None]
- property joint_name_or_hash¶
The name or hash identifier of the joint the location is located at.
- Returns:
The name or hash identifier of the joint the location is located at.
- Return type:
Union[str, int]
- property parent_ref¶
The parent reference of the location.
- Returns:
The parent reference of the location.
- Return type:
Any
- property routing_surface¶
The routing surface the location is located on.
- Returns:
The routing surface the location is located on.
- Return type:
- property slot_hash¶
The hash identifier of the Slot the location is located at.
- Returns:
The hash identifier of the Slot the location is located at.
- Return type:
int
- property transform¶
The translation and orientation of the location.
- Returns:
The translation and orientation of the location.
- Return type:
Routing Location¶
- class CommonRoutingLocation(position, orientation=None, routing_surface=None)¶
Bases:
objectA Location used for routing.
- Parameters:
position (CommonVector3) – The position of the location.
orientation (CommonQuaternion, optional) – The orientation of the location. Default is None.
routing_surface (CommonSurfaceIdentifier, optional) – The routing surface of the location. Default is None.
- static empty()¶
Create an empty location.
- Returns:
An empty location.
- Return type:
- static from_location(location)¶
Convert a vanilla Location object into a CommonRoutingLocation.
- Parameters:
location (Union[routing.Location, sims4.math.Location, CommonLocation, CommonRoutingLocation]) – An instance of a Location.
- Returns:
An instance of a CommonRoutingLocation or None if the object failed to convert.
- Return type:
Union[CommonRoutingLocation, None]
- get_world_surface_location()¶
Retrieve the Location as a world surface location.
- Returns:
A world surface location.
- Return type:
- property orientation¶
The orientation of the location.
- Returns:
The orientation of the Location.
- Return type:
- property position¶
The translation and orientation of the location.
- Returns:
The translation and orientation of the location.
- Return type:
- property routing_surface¶
The routing surface the location is located on.
- Returns:
The routing surface the location is located on.
- Return type:
Polygon¶
- class CommonPolygon(polygon_vertices)¶
Bases:
objectA class that contains polygonal data.
- static empty()¶
Create an empty Polygon.
- Returns:
An empty Polygon.
- Return type:
- static from_polygon(polygon)¶
Convert a vanilla Polygon object into a CommonPolygon.
- Parameters:
polygon (Union[Polygon, CommonPolygon]) – An instance of a Polygon
- Returns:
An instance of a CommonPolygon or None if the object failed to convert.
- Return type:
Union[CommonLocation, None]
Quaternion¶
- class CommonQuaternion(x, y, z, w)¶
Bases:
objectA class that contains orientation data.
- static conjugate(quaternion)¶
Conjugate a quaternion.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to conjugate.
- Returns:
A conjugated Quaternion.
- Return type:
- classmethod deserialize(data)¶
- Return type:
Optional[CommonQuaternion]
- static divide(quaternion, quaternion_other)¶
Divides two quaternions without normalizing the result. Use q = q1 / q2 for a normalized result.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to be divided.
quaternion_other (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to divide with.
- Returns:
A divided Quaternion.
- Return type:
- static empty()¶
Deprecated, use “identity” instead.
Create an empty quaternion.
- Returns:
An empty quaternion.
- Return type:
- static from_degrees(degrees)¶
Convert an angle in degrees into a CommonQuaternion.
- Parameters:
degrees (float) – An angle in degrees
- Returns:
An instance of a CommonQuaternion.
- Return type:
- static from_quaternion(quaternion)¶
Convert a Quaternion into a CommonQuaternion.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – An instance of a Quaternion.
- Returns:
An instance of a CommonQuaternion or None if the object failed to convert.
- Return type:
Union[CommonQuaternion, None]
- static from_radian(radian)¶
Convert a radian value into a CommonQuaternion.
- Parameters:
radian (float) – An angle in radians
- Returns:
An instance of a CommonQuaternion.
- Return type:
- static identity()¶
Create an identity quaternion.
- Returns:
An identity quaternion.
- Return type:
- static is_empty(quaternion)¶
Determine if a quaternion is empty or not.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to check.
- Returns:
True, if the quaternion is empty. False, if not.
- Return type:
bool
- static multiply(quaternion, quaternion_other)¶
Multiplies two quaternions without normalizing the result. Use q = q1 * q2 for a normalized result.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to be multiplied.
quaternion_other (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to multiply with.
- Returns:
A divided Quaternion.
- Return type:
- static normalize(quaternion, tolerance=1e-05)¶
Normalize a quaternion.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to normalize.
tolerance (float, optional) – The tolerance level for normalization. Default is 0.00001.
- Returns:
A normalized Quaternion.
- Return type:
- static rotate_vector(quaternion, vector)¶
Rotate a vector with a quaternion.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – The quaternion to use for rotation.
vector (CommonVector3) – The vector to rotate.
- Returns:
A normalized Quaternion.
- Return type:
- static serialize(quaternion)¶
- Return type:
Union[str,Dict[str,Any]]
- static to_degrees(quaternion)¶
Convert a Quaternion into degrees.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – An instance of a Quaternion.
- Returns:
The quaternion represented in degrees.
- Return type:
float
- static to_radian(quaternion)¶
Convert a Quaternion into radians.
- Parameters:
quaternion (Union[Quaternion, MathPb2Quaternion, CommonQuaternion]) – An instance of a Quaternion.
- Returns:
The quaternion represented in radians.
- Return type:
float
- property w¶
The rotation.
- Returns:
The rotation.
- Return type:
Any
- property x¶
The x position.
- Returns:
The x position.
- Return type:
float
- property y¶
The y position.
- Returns:
The y position.
- Return type:
float
- property z¶
The z position.
- Returns:
The z position.
- Return type:
float
Range (Float)¶
- class CommonFloatRange(min_value=None, max_value=None)¶
Bases:
objectA range with a minimum and maximum for use in calculations.
- Parameters:
min_value (float, optional) – The minimum threshold. Set to None if there is no minimum. Default is None.
max_value (float, optional) – The maximum threshold. Set to None if there is no maximum. Default is None.
- in_range(value, or_equal=True)¶
If a Minimum and Maximum value are specified, determine if the specified value is between or equal to the Minimum and Maximum values. If a Maximum value is not specified, determine if the specified value is greater than or equal to the Minimum value. If a Minimum value is not specified, determine if the specified value is less than or equal to the Maximum value.
- Parameters:
value (float) – The value to check.
or_equal (bool, optional) – If True, the value may equal the minimum or maximum values to pass. Default is True.
- Returns:
True, if the value is within range of the Minimum and Maximum values. False, it not.
- Return type:
bool
- property max_value¶
The maximum threshold of this range.
- Returns:
The maximum threshold of this range.
- Return type:
Union[float, None]
- property min_value¶
The minimum threshold of this range.
- Returns:
The minimum threshold of this range.
- Return type:
Union[float, None]
Range (Integer)¶
- class CommonIntegerRange(min_value=None, max_value=None)¶
Bases:
objectA range with a minimum and maximum for use in calculations.
- Parameters:
min_value (int, optional) – The minimum threshold. Set to None if there is no minimum. Default is None.
max_value (int, optional) – The maximum threshold. Set to None if there is no maximum. Default is None.
- in_range(value, or_equal=True)¶
If a Minimum and Maximum value are specified, determine if the specified value is between or equal to the Minimum and Maximum values. If a Maximum value is not specified, determine if the specified value is greater than or equal to the Minimum value. If a Minimum value is not specified, determine if the specified value is less than or equal to the Maximum value.
- Parameters:
value (int) – The value to check.
or_equal (bool, optional) – If True, the value may equal the minimum or maximum values to pass. Default is True.
- Returns:
True, if the value is within range of the Minimum and Maximum values. False, it not.
- Return type:
bool
- property max_value¶
The maximum threshold of this range.
- Returns:
The maximum threshold of this range.
- Return type:
Union[int, None]
- property min_value¶
The minimum threshold of this range.
- Returns:
The minimum threshold of this range.
- Return type:
Union[int, None]
Surface Identifier¶
- class CommonSurfaceIdentifier(primary_id, secondary_id=None, surface_type=routing.SurfaceType.SURFACETYPE_WORLD)¶
Bases:
objectA class that contains surface data.
- static empty(secondary_id=0)¶
Create an empty surface identifier for the current zone.
- Parameters:
secondary_id (int, optional) – The secondary id to give to the surface identifier. Default is 0.
- Returns:
An empty surface identifier.
- Return type:
- static from_surface_identifier(surface_identifier)¶
Convert a SurfaceIdentifier into a CommonSurfaceIdentifier.
- Parameters:
surface_identifier (Union[SurfaceIdentifier, CommonSurfaceIdentifier]) – An instance of a surface identifier.
- Returns:
An instance of a CommonSurfaceIdentifier or None if it failed to convert.
- Return type:
Union[CommonSurfaceIdentifier, None]
- property primary_id¶
The primary identifier for the surface. This value is usually the identifier of a Zone.
- Returns:
The primary identifier.
- Return type:
int
- property secondary_id¶
The secondary identifier for the surface. This value is usually the level at which the surface is.
- Returns:
The secondary identifier.
- Return type:
Union[int, None]
- property type¶
The type of surface.
- Returns:
The type of surface.
- Return type:
Union[SurfaceType, None]
Weighted Value¶
- class CommonWeightedValue(value=0.0, weight=1.0)¶
Bases:
objectA value with a weight. To be used in conjunction with other CommonWeightedValueTally.
- static create_empty()¶
Create an empty CommonWeightedValue.
- Return type:
- has_value()¶
Determine if this weighted value has a value.
- Return type:
bool
- has_weight()¶
Determine if this weighted value has a weight.
- Return type:
bool
- property value¶
The value.
- property weight¶
The weight.
Weighted Value Tally¶
Transform¶
- class CommonTransform(translation, orientation)¶
Bases:
objectA class that contains transformational data.
- static empty()¶
Create an empty transform.
- Returns:
An empty transform.
- Return type:
- static from_transform(transform)¶
Convert a Transform into a CommonTransform.
- Parameters:
transform (Union[Transform, MathPb2Transform, CommonTransform]) – An instance of a transform.
- Returns:
An instance of a CommonTransform or None if it failed to convert.
- Return type:
Union[CommonTransform, None]
- property orientation¶
The orientation.
- Returns:
The orientation.
- Return type:
- property translation¶
The translation.
- Returns:
The translation.
- Return type:
Vector3¶
- class CommonVector3(x, y, z)¶
Bases:
objectA class that contains positional data with three coordinates.
- classmethod deserialize(data)¶
- Return type:
Optional[CommonVector3]
- static distance_between(position_one, position_two)¶
Calculate the distance between two vectors.
- Parameters:
position_one (CommonVector3) – An instance of a Vector.
position_two (CommonVector3) – An instance of a Vector.
- Returns:
The distance between the two specified vectors.
- Return type:
float
- static empty()¶
Create an empty vector.
- Returns:
An empty vector.
- Return type:
- static flatten(vector)¶
Flatten a Vector.
- Parameters:
vector (Union[Vector3, Vector3Immutable, MathPb2Vector3, CommonVector3]) – An instance of a vector.
- Returns:
An instance of a flattened CommonVector3.
- Return type:
- static from_vector3(vector)¶
Convert a Vector into a CommonVector3.
- Parameters:
vector (Union[Vector3, Vector3Immutable, MathPb2Vector3, CommonVector3]) – An instance of a vector.
- Returns:
An instance of a CommonVector3 or None if it failed to convert.
- Return type:
Union[CommonVector3, None]
- static is_empty(vector)¶
Determine if a vector is empty or not.
- Parameters:
vector (Union[Vector3, Vector3Immutable, MathPb2Vector3, CommonVector3]) – The vector to check.
- Returns:
True, if the vector is empty. False, if not.
- Return type:
bool
- magnitude_squared()¶
- Return type:
float
- static normalize(vector)¶
Normalize a Vector.
- Parameters:
vector (Union[Vector3, Vector3Immutable, MathPb2Vector3, CommonVector3]) – An instance of a vector.
- Returns:
An instance of a normalized CommonVector3.
- Return type:
float
- static serialize(vector)¶
- Return type:
Union[str,Dict[str,Any]]
- property x¶
The x position.
- Returns:
The x position.
- Return type:
float
- property y¶
The y position.
- Returns:
The y position.
- Return type:
float
- property z¶
The z position.
- Returns:
The z position.
- Return type:
float