-
Notifications
You must be signed in to change notification settings - Fork 2
Osmosis Force
extends Force
implements N/A
Osmosis Force is a component which inherits from Force and applies an osmosis force to a group of edges assigned to it, derived from all edges making up a single mesh.
Accessibility | Type | Field Name | Description |
---|---|---|---|
public | List(Edge) | edges | Edges over which force will be applied |
public | float | constant | osmosis constant |
public | float | initialArea | initial area of the mesh |
Accessibility | Return Type | Method Name | Description |
---|---|---|---|
public | void | setConstant | sets the value for constant |
public | void | setTargetLengthRatio | sets the value for targetLengthRatio |
public | Vector | calculateOsmosisForceMagnitude | calculates osmosis force |
public | void | restore | applies osmosis force to all edges |
Our osmosis force is very similar to spring forces, using very similar equations to Hooke's law, denoted as:
F = -k(l - l0)
Where F is the force applied by the spring, k is the spring's stiffness constant, l is the current length of the spring and l0 is the resting length of the spring. For the osmosis force, we use a 2D version of this equation, so that
F = -k(a - a0 Where a and *a0 are area and initial area, respectively.
Due to the fact that everything is in 2 dimensions (and thus units are in length2 as opposed to length, the constant for the osmosis force is much smaller than that of "normal" spring forces, typically by a factor of 100-1000.