Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Name

function — Manipulate data with mathematical expression

Syntax

Panel
bgColor#ffffaa
borderWidth1
borderStylesolid

function function string

Description

The function command can be used to manipulate data values in Polydata (i.e. points and lines) and Structured Points (i.e. grids). The specified function will be performed on each point in the dataset.

The function string can be a combination of several sub functions for each component you want to manipulate. Each sub function should be separated with a semi colon character (;) .

Each sub function is a combination of a target variable, an equal sign, and a mathematical expression.

for example:

No Format
bgColor#eeeeee
borderWidth1
function "x = x + 100 ; y = x + y"
{noformat}

The

...

variables

...

in

...

the

...

function

...

are

...

always

...

from

...

the

...

original

...

dataset.

...

In

...

the

...

example

...

above,

...

the

...

x,

...

and

...

y

...

variable

...

in

...

the

...

second

...

sub

...

function

...

will

...

not

...

be

...

affected

...

by

...

result

...

of

...

the

...

the

...

first

...

sub

...

function.

...

The

...

mathematical

...

expression

...

may

...

contain

...

these

...

operators:

...

+,

...

-,

...

*,

...

/,

...

abs,

...

exp,

...

ceil,

...

floor,

...

ln,

...

log10,

...

sqrt,

...

sin,

...

sinh,

...

cos,

...

cosh,

...

tan,

...

tanh,

...

asin,

...

acos,

...

atan,

...

min,

...

max,

...

sign.

...

A

...

conditional

...

expression

...

is

...

also

...

supported.

...

An

...

"if"

...

test

...

may

...

be

...

a

...

part

...

of

...

the

...

mathematical

...

expression.

...

The

...

syntax

...

should

...

be

...

if(condition,

...

result

...

if

...

true,

...

result

...

if

...

false).

...

For

...

example:

...

No Format
bgColor#eeeeee
borderWidth1
function "z = if(z<0, 5, z)"
{noformat}

will

...

replace

...

all

...

values

...

with

...

z

...

less

...

than

...

zero

...

with

...

5.

...

Polydata target variables:

x = the x value of the current point
y = the y value of the current point
z = the z value of the current point
s = the scalar value of the current point

Structured Points target variables:

z = the value of the current point.
dx = point spacing in x direction.
dy = point spacing in y direction
origo_x =  the X coordinate of the grid origo which is the lower left corner of the Structured Points dataset
origo_y =  the Y coordinate of the grid origo which is the lower left corner of the Structured Points dataset

Common Function variables:

The following variables are available to all datasets:

x = the x value of the current point
y = the y value of the current point
z = the z value of the current point

Polydata Function variables:

In addition to the common variables, the following variables are available for polydata

x_ = the x value of the next point
y_ = the y value of the next point
z_ = the z value of the next point
_x = the x value of the previous point
_y = the y value of the previous point
_z = the z value of the previous point
s_ = the scalar value of the previous point
s = the scalar value of the current point
_s = the scalar value of the next point

Structured Points Function variables:

In addition to the common variables, the following variables are available for structured Points

xmin = the x value of the leftmost column of the Structured Points dataset
xmax = the x value of the rightmost column of the Structured Points dataset
ymin = the y value of the uppermost row of the Structured Points dataset
ymax = the y value of the bottommost row of the Structured Points dataset
dx = point spacing in x direction
dy = point spacing in y direction
rows = number of rows
cols = number of columns
origo_x = xmin = the x coordinate of the grid origo which is the lower left corner of the Structured Points dataset
origo_y = ymin = the Y coordinate of the grid origo which is the lower left corner of the Structured Points dataset

Examples:

Example 1: Switch Polydata x and y values 

No Format
bgColor#eeeeee
borderWidth1
function "x=y ; y=x"
{noformat}

h4. Example 

Example 2:

...

Multiply

...

z

...

by

...

1000

...

(Structured

...

Points

...

or

...

Poly

...

Data)

...

No Format
bgColor#eeeeee
borderWidth1
function "z=z*1000"
{noformat}

h4. Example 

Example 3:

...

Translate

...

polydata

...

100

...

in

...

x

...

direction

...

No Format
bgColor#eeeeee
borderWidth1
function "x=x+100"
{noformat}

h4. Example 

Example 4:

...

Translate

...

structured

...

points

...

dataset100

...

in

...

x

...

direction

...

No Format
bgColor#eeeeee
borderWidth1
function "origo_x=origo_x+100"
{noformat}

h4. Example 

Example 5:

...

Use

...

formula

...

on

...

a

...

structured

...

points

...

dataset

...

This

...

example

...

may

...

be

...

run

...

on

...

a

...

grid.

...

It

...

will

...

replace

...

the

...

grid

...

values

...

with

...

a

...

wave

...

pattern.

...

Try

...

the

...

following

...

command

...

No Format
bgColor#eeeeee
borderWidth1
function "z=dy*sin(sqrt(x*x +y*y)/(dx*10))"
{noformat}

h2. See also

[swi - Switch coordinates] , [add - Add to dataset]

{pagebreak}

See also

swi - Switch coordinates , add - Add to dataset