neurorosettes.physics#
This module deals with physical interactions between objects.
Module Contents#
Classes#
Class with the mechanical properties of a physical object. |
|
Class with the mechanical properties of a sphere. |
|
Class with the mechanical properties of a cylinder with a spring axis. |
|
Class to compute the contact forces between two objects, represented as spheres. |
|
Class to compute simple contact forces between two spheres. The force components |
|
Class to compute contact forces between two spheres based on potentials. The force components |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
Functions#
|
Returns the direction and magnitude components of a vector that connects two points. |
|
Returns the input array normalized to a unit vector. |
|
Returns the overlap between two objects represented as spheres. |
|
Returns the closest point on the cylinder axis to the sphere. |
|
Returns the closest point between two cylinders. |
- neurorosettes.physics.get_distance_components(point1, point2)[source]#
Returns the direction and magnitude components of a vector that connects two points.
- Parameters
point1 (np.ndarray) – The coordinates of the first point.
point2 (np.ndarray) – The coordinates of the second point.
- Returns
np.ndarray – The unit vector that defines the direction between the two points.
float – The distance between the two points.
- Return type
Tuple[numpy.ndarray, float]
- neurorosettes.physics.normalize_vector(vector)[source]#
Returns the input array normalized to a unit vector.
- Parameters
vector (numpy.ndarray) – The array to be normalized.
- Returns
The normalized vector.
- Return type
np.ndarray
- neurorosettes.physics.get_sphere_overlap(radius1, radius2, distance)[source]#
Returns the overlap between two objects represented as spheres.
- Parameters
radius1 (float) – The radius of the first object (represented as a sphere).
radius2 (float) – The radius of the second object (represented as a sphere).
distance (float) – The distance between the centres of the two objects.
- Returns
The overlap between the two objects.
- Return type
float
- neurorosettes.physics.get_sphere_cylinder_intersection(center, base, top)[source]#
Returns the closest point on the cylinder axis to the sphere.
The intersection is given by the dot product. Taking the dot product between the cylinder axis and the axis that connects the cylinder base to the sphere, the dot product gives us the projection of the cylinder-sphere axis on the cylinder axis. For dot products between 0 and 1, the closest point is on the cylinder axis. For dot products below 0 or above 1, the closest points are the base and the extremity of the cylinder, respectively.
- Parameters
center (np.ndarray) – The coordinates for the center of the sphere object.
base (np.ndarray) – The coordinates for the base of the cylinder object.
top (np.ndarray) – The coordinates for the extremity of the cylinder object.
- Returns
The coordinates of the closest point to the sphere on the cylinder axis
- Return type
np.ndarray
- neurorosettes.physics.get_cylinder_intersection(base_1, top_1, base_2, top_2)[source]#
Returns the closest point between two cylinders.
The cross product is used to evaluate if the cylinder axes are parallel. If they are, the closest points between the two objects are considered to be their middle points. If not, the projection of each axis on the other axis is computed to find the closest point on each axis.
- Parameters
base_1 (np.ndarray) – The coordinates for the base of the first cylinder object.
top_1 (np.ndarray) – The coordinates for the extremity of the first cylinder object.
base_2 (np.ndarray) – The coordinates for the base of the second cylinder object.
top_2 (np.ndarray) – The coordinates for the extremity of the second cylinder object.
- Returns
np.ndarray – The closest point on the axis of the first cylinder.
np.ndarray – The closest point on the axis of the second cylinder.
- Return type
Tuple[numpy.ndarray, numpy.ndarray]
- class neurorosettes.physics.PhysicalProperties(radius, interaction_factor)[source]#
Class with the mechanical properties of a physical object.
- Parameters
radius (float) – The radius of the physical object.
interaction_factor (float) – The factor used to calculate the radius of interaction.
- property radius#
Returns the radius of the object. Raises an error if a negative or non-numerical value is set.
- property interaction_factor#
Returns the interaction factor of the object. Raises an error if a negative or non-numerical value is set.
- property interaction_radius: float#
Returns the radius of interaction of the physical object.
- Return type
float
- class neurorosettes.physics.SphereProperties(radius, interaction_factor)[source]#
Bases:
PhysicalPropertiesClass with the mechanical properties of a sphere.
- Parameters
radius (float) – The radius of the physical object.
interaction_factor (float) – The factor used to calculate the radius of interaction.
- class neurorosettes.physics.CylinderProperties(radius, interaction_factor, spring_constant, default_length)[source]#
Bases:
PhysicalPropertiesClass with the mechanical properties of a cylinder with a spring axis.
- Parameters
radius (float) – The radius of the physical object.
interaction_factor (float) – The factor used to calculate the radius of interaction.
spring_constant (float) –
default_length (float) –
- class neurorosettes.physics.ContactForces[source]#
Bases:
abc.ABCClass to compute the contact forces between two objects, represented as spheres.
- adhesion_coefficient :float#
- repulsion_coefficient :float#
- abstract compute_adhesion(distance, radius1, radius2)[source]#
Returns the magnitude of the adhesion force between two objects
- Parameters
distance (float) – The distance between two spheres.
radius1 (float) – The radius of the first sphere object.
radius2 (float) – The radius of the second sphere object.
- Returns
The magnitude of the adhesion contact forces.
- Return type
float
- abstract compute_repulsion(distance, radius1, radius2)[source]#
Returns the magnitude of the repulsion force between two objects
- Parameters
distance (float) – The distance between two spheres.
radius1 (float) – The radius of the first sphere object.
radius2 (float) – The radius of the second sphere object.
- Returns
The magnitude of the repulsion contact forces.
- Return type
float
- class neurorosettes.physics.SimpleContact[source]#
Bases:
ContactForcesClass to compute simple contact forces between two spheres. The force components are proportional to the adhesion/repulsion coefficients, the overlap between the spheres and, in the case of adhesion forces, the equivalent radius of the spheres. Same approach as done in Cx3D.
- class neurorosettes.physics.PotentialsContact[source]#
Bases:
ContactForcesClass to compute contact forces between two spheres based on potentials. The force components take into account the adhesion/coefficient coefficients, a smoothness factor and the distance between two objects. Same approach as done in PhysiCell.
- smoothness_factor :int#
- class neurorosettes.physics.ContactFactory[source]#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- class neurorosettes.physics.SimpleFactory[source]#
Bases:
ContactFactoryHelper class that provides a standard way to create an ABC using inheritance.
- sphere_sphere_adhesion :float#
- sphere_sphere_repulsion :float#
- sphere_cylinder_adhesion :float#
- sphere_cylinder_repulsion :float#
- cylinder_cylinder_adhesion :float#
- cylinder_cylinder_repulsion :float#
- class neurorosettes.physics.PotentialsFactory[source]#
Bases:
ContactFactoryHelper class that provides a standard way to create an ABC using inheritance.
- sphere_sphere_adhesion :float#
- sphere_sphere_repulsion :float#
- sphere_sphere_smoothness :int#
- sphere_cylinder_adhesion :float#
- sphere_cylinder_repulsion :float#
- sphere_cylinder_smoothness :int#
- cylinder_cylinder_adhesion :float#
- cylinder_cylinder_repulsion :float#
- cylinder_cylinder_smoothness :int#