Liking cljdoc? Tell your friends :D

fastmath.fields

Vector field functions.

Vector fields are functions R^2->R^2.

Names are taken from fractal flames world where such fields are call variations. Most implementations are taken from JWildfire software.

Creation

To create vector field call field multimethod with name of the field as keyword.

Some of the vector fields require additional configuration as a map of parameters as keywords and values. Call parametrization to create random one or to merge with provided.

Additionally you can provide amount parameter which is scaling factor for vector field (default: 1.0).

Derived fields

You can use several method to derive new vector field from the other one(s). Possible options are:

  • derivative, grad-x, grad-y - directional derivative of the field
  • sum - sum of two fields
  • [[multiply]] - multiplication of the fields
  • composition - composition of the fields
  • [[angles]] - angles of the field vectors

Scalar fields

You can derive scalar fields from given vector field(s):

  • jacobian - determinant of jacobian matrix
  • divergence - divergence of the field
  • cross - cross product of the fields (as a determinant of the 2x2 matrix of vectors)
  • dot - dot product
  • angle-between - angle between vectors from fields.

Combinations

The other option is to create vector field using some of the above possibilities. Combination is a tree of field operations with parametrizations. Functions:

Vector field functions.

Vector fields are functions R^2->R^2.

Names are taken from fractal flames world where such fields are call `variations`. Most implementations are taken from [JWildfire](http://jwildfire.org/) software.

### Creation

To create vector field call [[field]] multimethod with name of the field as keyword.

Some of the vector fields require additional configuration as a map of parameters as keywords and values. Call [[parametrization]] to create random one or to merge with provided.

Additionally you can provide `amount` parameter which is scaling factor for vector field (default: `1.0`).

### Derived fields

You can use several method to derive new vector field from the other one(s). Possible options are:

* [[derivative]], [[grad-x]], [[grad-y]] - directional derivative of the field
* [[sum]] - sum of two fields
* [[multiply]] - multiplication of the fields
* [[composition]] - composition of the fields
* [[angles]] - angles of the field vectors

### Scalar fields

You can derive scalar fields from given vector field(s):

* [[jacobian]] - determinant of jacobian matrix
* [[divergence]] - divergence of the field
* [[cross]] - cross product of the fields (as a determinant of the 2x2 matrix of vectors)
* [[dot]] - dot product
* [[angle-between]] - angle between vectors from fields.

### Combinations

The other option is to create vector field using some of the above possibilities. Combination is a tree of field operations with parametrizations. Functions:

* [[combine]] - create vector field randomly of from given parametrization.
* [[random-configuration]] - returns random configuration as a map
* [[randomize-configuration]] - change parametrization for given configuration.
raw docstring

*skip-random-fields*clj

When random configuration for combine is used. Skip vector fields which are random.

When random configuration for [[combine]] is used. Skip vector fields which are random.
sourceraw docstring

angle-betweenclj

Angle between input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from result of vector fields.

Resulting value is from range [-PI,PI].

Angle between input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from result of vector fields.

Resulting value is from range `[-PI,PI]`.
sourceraw docstring

combineclj

(combine)
(combine {:keys [type name amount config var step var1 var2]})

Create composite vector field function based on configuration

Call without argument to get random vector field.

Configuration is a tree structure where nodes are one of the following

  • {:type :variation :name NAME :amount AMOUNT :config CONFIG} where
    • NAME is variation name (keyword)
    • AMOUNT is scaling factor
    • CONFIG is variation parametrization
  • {:type :operation :name OPERATION :amount AMOUNT :var1 VAR1 :var2 VAR2} where
    • OPERATION is one of the operations (see below)
    • AMOUNT is scaling factor
    • VAR1 and VAR2 two variations to combine
  • {:type :operation :name :derivative :amount AMOUNT :var VAR :step STEP} where
    • AMOUNT is scaling factor
    • VAR variation, subject to calculate derivative
    • STEP dx and dy value

Possible OPERATIONs are:

  • :add - sum of two variations
  • :mult - multiplication
  • :comp - composition
  • :angles - vector field from angles

See random-configuration for example.

Create composite vector field function based on configuration

Call without argument to get random vector field.

Configuration is a tree structure where nodes are one of the following

* `{:type :variation :name NAME :amount AMOUNT :config CONFIG}` where
    * NAME is variation name (keyword)
    * AMOUNT is scaling factor
    * CONFIG is variation parametrization
* `{:type :operation :name OPERATION :amount AMOUNT :var1 VAR1 :var2 VAR2}` where
    * OPERATION is one of the operations (see below)
    * AMOUNT is scaling factor
    * VAR1 and VAR2 two variations to combine
* `{:type :operation :name :derivative :amount AMOUNT :var VAR :step STEP}` where
    * AMOUNT is scaling factor
    * VAR variation, subject to calculate derivative
    * STEP dx and dy value

Possible OPERATIONs are:

* `:add` - sum of two variations
* `:mult` - multiplication
* `:comp` - composition
* `:angles` - vector field from angles

See [[random-configuration]] for example.
sourceraw docstring

compositionclj

(composition f1 f2)
(composition f1 f2 amount)

Compose two vector fields.

Compose two vector fields.
sourceraw docstring

crossclj

2d cross product (det of the 2x2 matrix) of the input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from results of vector fields.

2d cross product (det of the 2x2 matrix) of the input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from results of vector fields.
sourceraw docstring

curlclj

(curl f)
(curl f h)

Curl (2d version) of the field.

See: https://youtu.be/rB83DpBJQsE?t=855

Curl (2d version) of the field.

See: https://youtu.be/rB83DpBJQsE?t=855
sourceraw docstring

derivativeclj

(derivative f)
(derivative f h)
(derivative f amount h)

Calculate directional derivative of fn. Derivative is calculated along [1,1] vector with h as a step (default 1.0e-6).

Calculate directional derivative of fn. Derivative is calculated along [1,1] vector with `h` as a step (default `1.0e-6`).
sourceraw docstring

divergenceclj

(divergence f)
(divergence f h)

Divergence of the field.

See: https://youtu.be/rB83DpBJQsE?t=855

Divergence of the field.

See: https://youtu.be/rB83DpBJQsE?t=855
sourceraw docstring

dotclj

Dot product of the input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from result of vector fields.

Dot product of the input vector and result of the vector field.

In case when two vector fields are given, cross product is taken from result of vector fields.
sourceraw docstring

fieldcljmultimethod

Return vector field for given name and options: amount (scaling factor) and parametrization.

Default scaling factor is 1.0, default parametrization is random.

Resulting function operates on [[Vec2]] type.

Return vector field for given name and options: amount (scaling factor) and parametrization.

Default scaling factor is 1.0, default parametrization is random.

Resulting function operates on [[Vec2]] type.
sourceraw docstring

fields-listclj

source

fields-list-not-randomclj

source

fields-list-randomclj

source

grad-xclj

(grad-x f)
(grad-x f h)
(grad-x f amount h)

Calculate gradient along x axis.

Calculate gradient along x axis.
sourceraw docstring

grad-yclj

(grad-y f)
(grad-y f h)
(grad-y f amount h)

Calculate gradient along y axis.

Calculate gradient along y axis.
sourceraw docstring

headingclj

(heading f)

Angle of the vectors from field.

Angle of the vectors from field.
sourceraw docstring

jacobianclj

(jacobian f)
(jacobian f h)

Det of Jacobian of the field

Det of Jacobian of the field
sourceraw docstring

magnitudeclj

(magnitude f)

Magnitude of the vectors from field.

Magnitude of the vectors from field.
sourceraw docstring

multiplicationclj

(multiplication f1 f2)
(multiplication f1 f2 amount)

Multiply two vector fields (as a element-wise multiplication of results).

Multiply two vector fields (as a element-wise multiplication of results).
sourceraw docstring

parametrizationcljmultimethod

Return random parametrization map for given field.

Optinally you can pass part of the parametrization. In this case function will add remaining keys with randomly generated values.

If field doesn't have parametrization, empty map will be returned.

See field.

Return random parametrization map for given field.

Optinally you can pass part of the parametrization. In this case function will add remaining keys with randomly generated values.

If field doesn't have parametrization, empty map will be returned.

See [[field]].
sourceraw docstring

random-configurationclj

(random-configuration)
(random-configuration depth)
(random-configuration depth f)

Create random configuration for combine function. Optionally with depth (0 = only root is created).

See combine for structure.

Bind *skip-random-fields* to true to exclude fields which are random.

Create random configuration for [[combine]] function. Optionally with depth (0 = only root is created).

See [[combine]] for structure.

Bind `*skip-random-fields*` to true to exclude fields which are random.
sourceraw docstring

random-fieldclj

(random-field)
(random-field depth)

Create randomized field (optional depth can be provided).

Create randomized field (optional depth can be provided).
sourceraw docstring

randomize-configurationclj

(randomize-configuration f)

Randomize values for given configuration. Keeps structure untouched.

Randomize values for given configuration. Keeps structure untouched.
sourceraw docstring

scalar->vector-fieldclj

(scalar->vector-field scalar f)
(scalar->vector-field scalar f1 f2)

Returns vector field build from scalar fields of the input vector and result of the vector field.

Returns vector field build from scalar fields of the input vector and result of the vector field.
sourceraw docstring

sumclj

(sum f1 f2)
(sum f1 f2 amount)

Add two vector fields.

Add two vector fields.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close