next up previous contents index
Next: Plane transforms Up: Basic constructions Previous: 3.8.1.4 Circles   Contents   Index


3.8.1.5 Polygons

Polygons are sequences of points, called vertices. Polygons are defined using the command polyg :


 - funct -> polyg P 100


creates a polygon whose name is P, with 100 vertices. The number of vertices can be changed by subsequent commands. The default coordinates for the vertices of a polygon are (0,0). The command coord can then be used to change them :


 - funct -> coord P 52 0.7 2.4


will give the coordinates (0.7,2.4) to the 52th vertex of P. Instead of 52, 0.7, 24 we could put numerical expressions understood by the expression evaluator.

The command show is used to give informations about a polygon :


 - funct -> show P


will print something like this


number of vertices : 100
not curvilinear
sides not computed


and the variables pol_nb, pol_curv, pol_calc, pol_step will contain respectively 100, 0, 0, 0.

The command polyg_curv can be used to transform a polygon in a curvilinear one :


 - funct -> polyg Q 10
 - funct -> polyg_curv P Q 1000


will first define a new polygon Q, with 10 vertices. The second instruction will change this number of vertices to 1001, and will use P to compute the vertices of Q : they are equally spaced and on P, the first and last ones beeing the same as P. Moreover the unit tangent vectors and acceleration vectors at each vertex of Q will be computed. The command


 - funct -> show Q


will then print something like this


number of vertices : 1001
curvilinear
length : 23.35688555774
sides computed


and the variables pol_nb, pol_curv, pol_calc, pol_step will contain respectively 1001, 1, 1, 0.02335688555774.

The command length_pol is used to compute the length of a curvilinear polygon :


 - funct -> length_pol Q


will set the value of the variable length_pol to the length of Q.

It is possible to define polygons from real functions. They can be used to define and draw parametric curves. Two real double precisions must be used for this : one for the x coordinate and the other for the y coordinate. They must have the same xrange. So a parametric curve is defined as follows : first define the functions


 - funct -> xrange xr 1 1001
 - funct -> fix_xrange xr 0 pi/500
 - funct -> function X xr
 - funct -> function Y xr


(cf. 3.1). This creates two functions X, Y, defined on the interval $\lbrack 0,2\pi\rbrack$ on 1001 equally spaced points. One must then fill these functions. For example :


 - funct -> fill_func X sin(3*x)
 - funct -> fill_func X sin(4*x)


We must then define a polygon and associate it to the preceeding functions :


 - funct -> polyg P 10
 - funct -> polyg_funct P X Y


We have then a polygon P with 1001 vertices whose i-th vertex is the point of coordinates $(sin(i\frac{\pi}{500}),cos(i\frac{\pi}{500}))$.


next up previous contents index
Next: Plane transforms Up: Basic constructions Previous: 3.8.1.4 Circles   Contents   Index
2009-11-12