16.01.2015 Views

sborník

sborník

sborník

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

COMPUTATIONAL GEOMETRY WITH MAPLE<br />

DCEL is suited to represent a connected planar graph embedded<br />

in the plane. Edge is given by its nodes and with information about<br />

incident edges and faces.<br />

>A[1]:=[0,0]:A[2]:=[0,2]:A[3]:=[1,3]:A[4]:=[2,2]: ...<br />

>e[1]:=[A[1],A[2],0,1,10,5]:e[2]:=[A[2],A[3],0,2,1,3]: ...<br />

By using the for loops to iterate over the coordinates we can transform<br />

the DCEL to the simple ordered list of faces and draw the<br />

two-dimensional polygons F[i].<br />

> for i to nops(F) do<br />

> F[i]:={}:<br />

> for j to nops(e) do<br />

> if list_e[j][3]=i or list_e[j][4]=i then<br />

F[i]:={op(F[i]),list_e[j][1],list_e[j][2]}end if:<br />

> end do:<br />

> end do:<br />

> listF:=[seq(convert(F[i],list),i=1..5)];<br />

>plots[polygonplot](listF);<br />

2.2 Arithmetics<br />

We will represent the coordinates with integer rather than with floating<br />

point numbers wherever possible.This will permit us to avoid<br />

the issue of floating-point round-off error and allow us to write code<br />

that is verifiably correct within a range of coordinate values. Maple<br />

performs the arithmetic computation in the floating-point environment.<br />

For arithmetic operations if one of the operands is a floatingpoint<br />

number then floating-point arithmetics takes place automatically.<br />

The global namedigits which has 10 as its default, determines<br />

the number of digits in the significant which Maple uses when calculating<br />

with floating-point number.<br />

3 Maple programming language<br />

Writing a Maple program can be very simple. It may only involve<br />

putting a command proc() and end proc around a sequence of commands.<br />

We can write useful Maple programs in a few hours, rather<br />

then a few weeks that it often takes with other languages. This<br />

289

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!