DeformationExpression

From K-3D

Jump to: navigation, search

Description

Displace a mesh using functional expressions in x, y, and z.
Plugin Status:Stable
Categories:All Plugins, Stable Plugins, Deformation Plugins

Metadata

Name Value

Properties

Label Description Type Script Name
Input Mesh Input mesh k3d::mesh* input_mesh
Output Mesh Output mesh k3d::mesh* output_mesh
Mesh Selection Input Mesh Selection k3d::selection::set mesh_selection
X Function Output X coordinate function, in terms of x, y, z, and any user-defined scalars. k3d::string_t x_function
Y Function Output Y coordinate function, in terms of x, y, z, and any user-defined scalars. k3d::string_t y_function
Z Function Output Z coordinate function, in terms of x, y, z, and any user-defined scalars. k3d::string_t z_function


Description

DeformationExpression lets you create a deformation modifier based on a mathematical expression.
This means each point's position is recalculated based on its X,Y and Z components.

Note: Take in count that the evaluation is on the object's local space and not in the global space.

Example

Lets suppose the object has the following points:

(1,1,0)
(1,0,2)

Now lets suppose we have the following expressions:

For the X component: x+y
For the Y component: y^2
For the Z component: z-x

The evaluation in the corresponding order

First point  ( 1+1, 1^2, 0-1) = ( 2, 1,-1)
Second point ( 1+0, 0^2, 2-1) = ( 1, 0, 1)

Creating complex modifiers

One technique for creating complex modifiers is thinking of vectors, then replacing this vectors on the components functions.
For example this vector expression creates like a bulge near the coordinates center.

|x| is the module of x
pi: initial point vector
pf: final point vector
pf = pi + (pi / |pi|) * exp(-|pi|^2)

That means adding to the initial vector a vector in the same direction, proportional to the Gauss function of its module. Translating to components:

 pi  -> the corresponding component of the function (x,y,z)
|pi| -> sqrt(x^2+y^2+z^2)

The resulting functions:

For the X component: x + x/sqrt(x^2+y^2+z^2) * exp(-(x^2+y^2+z^2))
For the Y component: y + y/sqrt(x^2+y^2+z^2) * exp(-(x^2+y^2+z^2))
For the Z component: z + z/sqrt(x^2+y^2+z^2) * exp(-(x^2+y^2+z^2))

You will notice I directly optimized sqrt(x^2+y^2+z^2)^2 to (x^2+y^2+z^2)

Personal tools