Module sim stdlib

sim
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
4
Imported by:
3
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

Aliases

This section is empty.

Constants

#constant default_rope_length

default_rope_length     = 0.25

#constant default_bearing_mass

default_bearing_mass    = 0.03

#constant default_magnet_spacing

default_magnet_spacing  = 0.05

#constant default_magnet_height

default_magnet_height   = 0.03

#constant default_magnet_strength

default_magnet_strength = 10.0

#constant default_gravity

default_gravity         = 4.9

#constant default_width

default_width  = 600

#constant default_height

default_height = 600

Sum types

This section is empty.

Functions

#fn compute_result

fn compute_result(request SimRequest) &SimResult

#fn log

inline
fn log(info string)

log is a helper function to print debug info

#fn new_state

fn new_state(state SimState) SimState

#fn run

fn run(params SimParams, settings RunnerSettings)

#fn sim_params

fn sim_params(params SimParams) SimParams

#fn sim_worker

fn sim_worker(id int, request_chan chan &SimRequest, result_channels []chan &SimResult)

#fn vector

fn vector(data Vector3D) Vector3D

vector creates a Vector3D passing x,y,z as parameteres

Structs

#struct SimParams

params
pub struct SimParams {
	rope_length     f64 = default_rope_length
	bearing_mass    f64 = default_bearing_mass
	magnet_spacing  f64 = default_magnet_spacing
	magnet_height   f64 = default_magnet_height
	magnet_strength f64 = default_magnet_strength
	gravity         f64 = default_gravity
}

#fn (SimParams) get_rope_vector

fn (params SimParams) get_rope_vector(state SimState) Vector3D

#fn (SimParams) get_forces_sum

fn (params SimParams) get_forces_sum(state SimState) Vector3D

#fn (SimParams) get_grav_force

fn (params SimParams) get_grav_force(state SimState) Vector3D

#fn (SimParams) get_magnet_position

fn (params SimParams) get_magnet_position(theta f64) Vector3D

#fn (SimParams) get_magnet_force

fn (params SimParams) get_magnet_force(theta f64, state SimState) Vector3D

#fn (SimParams) get_magnet_dist

fn (params SimParams) get_magnet_dist(theta f64, state SimState) f64

#fn (SimParams) get_magnet1_force

fn (params SimParams) get_magnet1_force(state SimState) Vector3D

#fn (SimParams) get_magnet2_force

fn (params SimParams) get_magnet2_force(state SimState) Vector3D

#fn (SimParams) get_magnet3_force

fn (params SimParams) get_magnet3_force(state SimState) Vector3D

#fn (SimParams) get_tension_force

fn (params SimParams) get_tension_force(state SimState, f_passive Vector3D) Vector3D

#struct GridSettings

params
pub struct GridSettings {
pub:
	width  int = default_width
	height int = default_height
}

#fn new_grid_settings

fn new_grid_settings(settings GridSettings) GridSettings

#struct RunnerSettings

params
pub struct RunnerSettings {
pub:
	grid       GridSettings
	on_request SimRequestHandler
	on_start   SimStartHandler
	on_finish  SimFinishHandler
}

#struct SimState

pub struct SimState {
mut:
	position Vector3D
	velocity Vector3D
	accel    Vector3D
}

#fn (&SimState) satisfy_rope_constraint

fn (mut state &SimState) satisfy_rope_constraint(params SimParams)

#fn (&SimState) increment

fn (mut state &SimState) increment(delta_t f64, params SimParams)

#fn (SimState) done

fn (state SimState) done() bool

#struct Vector3D

pub struct Vector3D {
	x f64
	y f64
	z f64
}

Vector3D is a 3D vector

#fn (Vector3D) operator+

fn (v Vector3D) + (v2 Vector3D) Vector3D

addition

#fn (Vector3D) operator*

fn (v Vector3D) * (v2 Vector3D) f64

dot product

#fn (Vector3D) scale

fn (v Vector3D) scale(scalar f64) Vector3D

scale gets a scaled vector

#fn (Vector3D) norm_squared

fn (v Vector3D) norm_squared() f64

norm_squared returns the square of the norm of the vector

#fn (Vector3D) norm

fn (v Vector3D) norm() f64

norm returns the norm of the vector

#struct SimRequest

pub struct SimRequest {
	params SimParams
	state  SimState
pub:
	id int
}

#struct SimResult

pub struct SimResult {
	state SimState
pub:
	id               int
	magnet1_distance f64
	magnet2_distance f64
	magnet3_distance f64
}

Interfaces

This section is empty.

Enums

This section is empty.