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.
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
).
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 fieldsum
- sum of two fieldscomposition
- composition of the fieldsYou can derive scalar fields from given vector field(s):
jacobian
- determinant of jacobian matrixdivergence
- divergence of the fieldcross
- cross product of the fields (as a determinant of the 2x2 matrix of vectors)dot
- dot productangle-between
- angle between vectors from fields.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 maprandomize-configuration
- change parametrization for given configuration.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.
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.
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]`.
(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
{:type :operation :name OPERATION :amount AMOUNT :var1 VAR1 :var2 VAR2}
where
{:type :operation :name :derivative :amount AMOUNT :var VAR :step STEP}
where
Possible OPERATIONs are:
:add
- sum of two variations:mult
- multiplication:comp
- composition:angles
- vector field from anglesSee 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.
(composition f1 f2)
(composition f1 f2 amount)
Compose two vector fields.
Compose two 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.
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.
(curl f)
(curl f h)
Curl (2d version) of the field.
Curl (2d version) of the field. See: https://youtu.be/rB83DpBJQsE?t=855
(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`).
(divergence f)
(divergence f h)
Divergence of the field.
Divergence of the field. See: https://youtu.be/rB83DpBJQsE?t=855
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.
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.
(grad-x f)
(grad-x f h)
(grad-x f amount h)
Calculate gradient along x axis.
Calculate gradient along x axis.
(grad-y f)
(grad-y f h)
(grad-y f amount h)
Calculate gradient along y axis.
Calculate gradient along y axis.
(heading f)
Angle of the vectors from field.
Angle of the vectors from field.
(jacobian f)
(jacobian f h)
Det of Jacobian of the field
Det of Jacobian of the field
(magnitude f)
Magnitude of the vectors from field.
Magnitude of the vectors from field.
(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).
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]].
(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.
(random-field)
(random-field depth)
Create randomized field (optional depth can be provided).
Create randomized field (optional depth can be provided).
(randomize-configuration f)
Randomize values for given configuration. Keeps structure untouched.
Randomize values for given configuration. Keeps structure untouched.
(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.
(sum f1 f2)
(sum f1 f2 amount)
Add two vector fields.
Add two vector fields.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close