Skip to content

Osmosis Force

jsutlive edited this page Nov 15, 2022 · 1 revision

Osmosis Force

extends Force

implements N/A

Introduction

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.

Fields

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

Methods

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

Physics/ Mathematics

2D Hooke's law derivation

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.

Clone this wiki locally