C.a.R. > Documentation > Expressions
You can use arithmetic expression in C.a.R. to
Use the expression tool to place expressions on the screen (and the right mouse button to move them). You will have to enter a valid expression into the dialog. Expressions may have an explaining text, and normally display the computed value. They are moved like any other object with the right mouse button.
Expressions can have a slider. Then the value can be set with the slider in the specified range.
Here is a short description of the valid elements. This description is also contained in the on-line help.
Name |
Example |
Description |
---|---|---|
+, -, *, /,^ or ** |
3.5*3+3/(4-5^2) |
Elementary math. |
Name of object |
AB/CD |
The name of a segment, circle, angle and other expression. The object must be defined before the object that uses the expression. |
@Name of object |
x(@P1) |
This form can refer to objects defined later, but will not work in macros. It is used automatically, if a direct reference would create cyclic dependencies. |
Function |
sin(a) |
The functions abs, sign, sin, cos, tan, arcsin, arccos, arctan, sqrt, exp, log, round, ceil, floor, angle180 and angle360. Note that sin works in degrees. There is a function deg to convert and rad to convert back. There are also rsin, rcos, rtan, rarcsin, rarccos, rarctan working in radians. |
Pi |
pi |
The constant Pi. |
x,y |
x(P), y(P) |
x- and y-coordinates of a point. |
d |
d(P,Q) |
Distance of two points. |
d |
d(x) |
Computes changes of the expression x. If x is a point, it computes movements. |
sum |
sum(x,f) |
Sums up x. If f is negative or invalid, the sum is reset to 0. |
a | a(P,Q,Z) | Size of angle PQZ. |
scale | scale(x,a,b) | The relative position of x in [a,b), if x is in that interval. Else the expression becomes invalid. |
if | if(e,e1,e2) | Returns e1, if e is valid, else e2. |
invalid | invalid | Returns an invalid expression. |
&&,||,! | ! (x<4 && y<4) | Logical expressions. 1 is true, 0 is false. |
<, >, <=, >=, ==, ~= | x<y | Comparing numbers. ~= means "about equal". |
integrate | integrate(f,a,b) integrate(f) |
Integrates the function f from a to b using the Romberg method. f must be a function object. The y-part is used. integrate(f) computes the Riemann sum for functions that are reduced to points and the trapezoidal sum for normal functions. For parametric curves or automatic tracks it computes the area inside the curve. For a track arc, a point (a,b) can be added from which the area is computed. |
length | length(f) | Computes the length of a parametric curve or an autmiatc track. |
zero | zero(f,a,b) | Find the zero of f between a and b using the secant method with interval check. f must have opposite sign in a and b. |
min,max | min(f,a,b) | Returns the point of minimal value of f between a and b. f is assumed to be convex for the minimum, concave for the maximum. |
diff | diff(f,x) | Differentiate f in x. |
windowcx, windowcy windoww, windowh, pixel |
Constants for the screen center and dimensions in coordinate units. Pixel returns the number of pixels per unit. | |
simulate | simulate(e,x,f) | Sets the expression e to x, re-computes the construction, and returns the value of f. Only one "simulate" can be computed per construction simultaneously! If another simulate command appears in the computation, an error will occur. For e, one can use an expression, a fixed angle or a fixed circle. |
C.a.R. > Documentation > Expressions