Force Field#

class genesis.engine.force_fields.ForceField[source]#

Base class for all force fields. This class should not be used directly.

Note

It’s called ForceField, but it’s actually an acceleration field, as force doesn’t have a notion of spatial density.

activate()[source]#

Activate the force field.

deactivate()[source]#

Deactivate the force field.

get_acc(pos, vel, t, i)[source]#
property active#

Whether the force field is active.

class genesis.engine.force_fields.Constant(direction=(1, 0, 0), strength=1.0)[source]#

Constant force field with a static acceleration everywhere.

Parameters:#

direction: array_like, shape=(3,)

The direction of the force (acceleration). Will be normalized.

strength: float

The strength of the force (acceleration).

property direction#
property strength#
class genesis.engine.force_fields.Wind(direction=(1, 0, 0), strength=1.0, radius=1, center=(0, 0, 0))[source]#

Wind force field with a static acceleration in a cylindrical region.

Parameters:#

direction: array_like, shape=(3,)

The direction of the wind. Will be normalized.

strength: float

The strength of the wind.

radius: float

The radius of the cylinder.

center: array_like, shape=(3,)

The center of the cylinder.

property direction#
property strength#
property radius#
property center#
class genesis.engine.force_fields.Point(strength=1.0, position=(0, 0, 0), falloff_pow=0.0, flow=1.0)[source]#

Point force field gives a constant force towards (positive strength) or away from (negative strength) the point.

Parameters:#

strength: float

The strength of the wind.

position: array_like, shape=(3,)

The position of the point.

flow: float

The flow of the force field.

falloff_pow: float

The power of the falloff.

property strength#
property position#
class genesis.engine.force_fields.Drag(linear=0.0, quadratic=0.0)[source]#

Drag force field gives a force opposite to the velocity.

Parameters:#

linear: float

The linear drag coefficient.

quadratic: float

The quadratic drag coefficient.

property linear#
property quadratic#
class genesis.engine.force_fields.Noise(strength=1.0)[source]#

Noise force field samples random noise at each point.

property strength#
class genesis.engine.force_fields.Vortex(direction=(0.0, 0.0, 1.0), center=(0.0, 0.0, 0.0), strength_perpendicular=20.0, strength_radial=0.0, falloff_pow=2.0, falloff_min=0.01, falloff_max=inf, damping=0.0)[source]#

Vortex force field revolving around z-axis.

Parameters:#

strength_perpendicular: float

The strength of the vortex flow in the perpendicular direction. Positive for counterclockwise, negative for clockwise.

strength_radial: float

The strength of the vortex flow in the radial direction. Positive for inward, negative for outward.

center: array_like, shape=(3,)

The center of the vortex.

falloff_pow: float

The power of the falloff.

falloff_min: float

The minimum distance (in meters) for the falloff. Under this distance, the force is effective with full strength.

falloff_max: float

The maximum distance (in meters) for the falloff. Above this distance, the force is ineffective.

property direction#
property radius#
property center#
property strength_perpendicular#
property strength_radial#
property falloff_pow#
property falloff_min#
property falloff_max#
class genesis.engine.force_fields.Turbulence(strength=1.0, frequency=3, flow=0.0, seed=None)[source]#

Turbulence force field generated using Perlin noise.

Parameters:#

strength: float

The strength of the turbulence.

frequency: float

The spatial frequency of repeated patterns used for Perlin noise.

flow: float

The flow of the turbulence.

seed: int | None

The seed for the Perlin noise.

property strength#
property frequency#
class genesis.engine.force_fields.Custom(func)[source]#

Custom force field with a user-defined force(acceleration) function f(pos, vel, t, i).

Parameters:#

func: A callable taichi func (a python function wrapped by @ti.func)

The acceleration function. Must have the signature f(pos: ti.types.vector(3), vel: ti.types.vector(3), t: ti.f32) -> ti.types.vector(3).

class genesis.engine.force_fields.PerlinNoiseField(wrap_size=256, frequency=10, seed=None, seed_offset=0)[source]#

Perlin noise field for generating 3D noise. Each PerlinNoiseField object has will create a different noise field.