# Using f(x)

Jump to navigation Jump to search
Other languages:
English

## Functions

Using functions in Valentina is a very useful tool avoiding to add numerous and confusing intermediate objects to draw a single point.

The basic syntax is function=(argument1,argument2), or function(argument1+argument2) - or any operator -/*^, and so on-.

Refer to feature overview of muparser for additional syntax.

See the list below of the functions implemented in Valentina :

abs - absolute value

acos - cosine arcus working with radians

acosD - cosine arcus working with degrees

acosh - hyperbolic cosine arcus

asin - sine arcus working with radians

asinD - sine arcus working with degrees

asinh - hyperbolic sine arcus

atan - tangent arcus working with radians

atanD - tangent arcus working with radians

atanh - hyperbolic tangent arcus

moyenne - mean value of all arguments

cos - cosine function working with radians

cosD - cosine function working with degrees

cosh - hyperbolic cosine function

csrCm - cut, split and rotate, cms units

csrInch - cut, split and rotate, inches units

degTorad - converts degrees to radians

exp - e to the x power

fmod - retourns the floating point remainder of a number (rounds towards 0)

ln - logarithm to base e

log

log10 - logarithm to base 10

log2 - logarithm to base 2

max - returns the maximum value of all arguments

minimum - retourns the minimum value of all arguments

r2cm - round to 1 decimal

radTodeg - converts radians to degrees

rint - round to nearest integrer

signe - sign function -1 if x<0; 1 if x>0

sin - sine function working with radians

sinD - sine function working with degrees

sinh - hyperbolic sine function

sqrt - square root of a value

somme - sum of of all arguments

tan - tangent function working with radians

tanD - tangent function working with degrees

tanH - hyperbolic tangent function

Examples

### Adding the 3rd point of a right-angled triangle whose two sides-of lenghts are known

Let's assume a 4ABC, right-angled at C, and composed of 3 segments AB (hypothenus), AC (adjacent side), and BC (opposite side).

Let's remind Pythagorean theorem :

Length_hypothenus^2=Length_adjacent^2+Length_opposite^2, where ^2 means argument raised to the power of 2

Which means :

Length_hypothenus = sqrt(Length_adjacent^2+Length_opposite^2) Length_adjacent=sqrt(Length_hypothenus^2-Length_opposite^2) Length_opposite=sqrt(Length_hypothenus^2-Length_adjacent^2), where sqrt means square root.

There are many situations in pattermaking in which these trigonometric functions are very useful and avoid using graphical methods.

Let's imagine the patternmaking method you use, tells you to place the line figuring the distance between armscyes at the narrowest width across chest, not according to the height from the neck, but according to this length line and according to the distance between the shoulder start and the end point of this line.

This can be translated as follows in geometrical terms :

• First create a preview calculation for the length of the adjacent side :

Distance between Armscyes - 1/2 neckline (called #LC_moins_demi_enc in the dialog box example).

• Then create a preview calculation for the opposite side, where its length will be the square root of the known value between the shoulder point start and the armscye, minus the half distance between armscyes,

Haut_sommet_Dvt_Carr=sqrt(@HSEPCDvt^2-#LC_moins_demi_enc^2)

• The point C1 representing the start of the line between armscyes, has only to be placed with this value #Haut_sommet_Dvt_Carr, vertically from point s1, on the center front line.

Let's note this could have been obtained by drawing :

• an arc from center point s1 with radius = known value between the shoulder point start and the armscye ;
• a vertical line parallel to the center front line, at the 1/2 distance between armscyes
• a point at the intersection between the arc and the line, which represents the end point of the armscyes point.

But this would have created a lot of objects instead of just adding one point !