Laborator Rezolvari Geometrie Cpmputationala

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

]J (,b&

^i" .Ia

.L) (*,, xr,xr,b) = (-t, -7, , -ol,, " )


\
L, c-a.h er,l* ce Ann* pn^ &
(&, 3n, I ,,\) -- (' ,
z t l, a) _l
4 f d. t " t**a7a{aw &/^5" *

)-) (x., *,,Nr,\r,rq,xrtrr)=Ca, - qbr*Tr,o t f/e ,?r, l)


Q",%n,'A,,.ar, 1r, br,**):(:zt z, t, 1, /, r,-i)

,
f/^*' z *tryu{;n,
t*ia.oule:
,-

't) (*., \r,x.,*u)


\rv+",*,1;
*{*+ *w& * fu^ ,y ru a&
{:,
,) 0 ) ,Yq , Yr, x6 ) \
d*--LL- xr. ?tn^

)l @, CL, o,, *, ,6)) = €, ,, t,z+) |


7 *r-*
^

e3n""7
(%,Ir, ],,L) = e,4, z, J) .?'*Afu
c4 y) .+i (F :
1= xn (n/r)

4) ,s) ,6) &r^'^p^*^"

zl ,L) (*k B/t "n


1 clear;
2 x0:- t ,'
3 xt*-t- / .J ;
4 x2=*t / ;
5
6 yQ=*l);
7 T L-1, T

8 y2=:.;
9 y3="!;
10
11 h:ii"i.i l;
L2 x:xo : h: x3;
13
L4 n0*,. (x0-x1) * (x0*x2) * (x0*x3) ;
15 L0-( (x-x1) .* (x*x2) .* {x-x3) ) lnO;
16
l7 n1:1x1-x0) * (x1-x2) * (x1^x3) ;
18 11*1 1x-xO) . * (x-x2) .* (x-x3) ) /n1;
19
20 n2= (x2-x0) * 1x2-x1) * (x2-x3) ;
2L L2= ( (x-xO) " * (x-x1) . * (x-x3) ),/n2;
22
23 n3= (x3-x0) * (x3-x1) * (x3*x2) ;
24 13*1(x-x0) .* (x*x1) .* lx-x2) ) /n3;
25
26 1:y0 *L0 +y1 *LL+y2*L2+y3 *L3 ;
27
28 ploL (x, L, ' ::' )
29 hold on
30 plot (x0, y0t'ni,)
31 plot (x1-, yL, ' .'i: ;i
32 plot (x2 ,y2|''"i:1
33 plot {x3. y3, ' ,'i: '
1 clear;
2 x0:-;;
3 x1--,,r/ i;
4 x2=* : /::i;
5 x3:lr;
6 vo:*t;
7 yt.*',.;
I y2:: ;
9 v3--': ;
10
11 h*ir . i, l.;
L2 x:x0 :h:x3;n6: (x0-x1) * (x0*x2) * (x0-x3) ;
13 L0-- ( {x-x1) . * (x-x2) "* (x-x3)) /n0;
1tl
15 nl-* {x1-x0) * lx]-*x2) * (xl--x3);
16 Ll-: ( (x-x0) . *. 1;-x2 ) .* (x-x3l) /nL;
L7
1g r,2: 1x2 _x0 ) * (x2-xL) * (x2*x3) ;
19 12_ 1 1x*x0) . * (x*xl- ) .*(x*x3l)/n2;
20
2L n3* (x3-x0) * {x3-x1) * (x3*x2) ;
22 13:1 1x*x0). * (x-x1) .*(x*x2)),/n3;
23
24 1:y0 *L0+y1 *L1-+y2*L2+y3 *L3;
25
26 plot (x, L, ' r

27 hol-d on
28 plot (x01 y0,
29 plot (x1, y1 ,
30 pIoL(x2,y2,
31 plot (x3, y3,
32
33 xO*; ;
34 xL:') / :t;
35 x2*.:' / j;
36 x3:i;
37 yO=;i ,'
38 y1"= ;
39 y2:::::;
40 y3:-1.;
4l
42 h=il .ll ;
43 x=x0;h:x3;
44 n0: (x0-xl- ) * (x0-x2) * (x0""x3);
45 L0: ( (x-xl") *ix-x2).*(x*x3))/n0;
"
45
47 n1: {x1*x0) * (x1*x2) * (x1-x3);
48 11* 1 1x_x0) . *(x-x2).*(x*x3))/n1;
49
50 n2* (x2*x0) * (x2*x1) " (x2-x3);
51 L2: ( (x*xO) . r" 1x*x1).* (x-x3l) /n2;
52
53 n3:1;3*x0) * (x3-x1) * (x3*x2);
54 13.. q (x*xO) *(x*x1).*(x-x2\\/n3;
.
55
56 f*yO *L0+y1 *LL+y2*L2+ y3 *L3 ;
57 plot(x/L,';')
58 hold on
59 plot (x0, y0,
60 plot (xL, y1 ,
61 pLol lx2, y2,
62 plot ix3, y3,
1 cl-ear;
2 x0=i: ;
3
4
5
6 Y0:tJ;
7 y1:; ;
8 v2:i:;
i .
9 -.2-
.I r* 't
1o
11 h:il ,. l: ;
L2 x*xo : h: x3;
t3 ng= (x0-x1) * (x0-x2) * (x0-x3) ,.L0: ( (x-x]") . * (x-x2) * (x-x3)),/n0;
L4
15 n1: (x1*x0) * (x1-*x2) * (x1-x3) ;
16 11* { (x*xO}, * (x-x2) . * (x-x3l } /nl;
L7
18 n2* (x2-x0) * (x2-x1) * (x2-x3) ;
19 12:1 {x*x0).* {x-x1).x lx*x3}l /n2;
20
2L n:: (x3*x0) * (x3*x1) * (x3*x2) ;
22 13:i (x-xO) .* (x-x1) .* (x-x2) ),/n3;
23
24 1*y0 * L0+y1 * Lt+y2* L2+y3 * L3 ;
25 plot (x,L, ' ;: ')
26 hold on
27 plot (x0, y0, ' , i, ' )
28 plot (x1, y1 , " i:, ' )
29 plot {x2 | y2 | ' "''i.:.'1 )
30 plot(x3,y3,',', 1,',
31 plot (x, x. ^ (1./."i) ,
1 '.f. i;r ;:ritr.i ,l i aE;'ulnu \,lrtLaiLc,L ii t_rian,luial:ea De aut-=7
2
3 r:l-ear all
4 x: irr ,,. . . i I .,1;
5 y - lri i] :. ir r .,1i
6
7 T : delaunay (x, y);
8 [2, tl : voronoi (x, y, T) ;
9
10 trrplot (T, x, y, );
11 hclcl on
12 p1ol-iz, t, );
13 xlim([-:r .,., 1); ylim([-i .]);
t4
1 %Dandu- se -j-:2 si j:4 spui-reti daca celuf ele V _i si V j srlnl- vet'i ne
2
3 clear al1
4 x: [| : ij ,] I I li.l,,l;
5 y - [i.] t.r ,i. :rt ,,1 I i_t.-iirI;
6 voronoi (x, y)
'7 xlim([- r] :l); ylim(l-t ,l);
t
9 x: [x(:) y(:)];
10 LV Cl : voronoin(X) ;
11
t2 for i: -L :lenqth(C)
13 disp(C{i});
L4 end
15
t6 N : length(V)-1;
t7 i : . i - ,r .
18 u : c{i
19 V c{j
20 r : (l;
27
22 for k:,i :length(u)
z3 for f : I:length(v)
z4 if u (k)::v (f) r:rr1
25 end
26 end
27 end
28
29 if r::l dlsp ( 'l;i:.r:i_ r,'i.rir.iir,-' )
30 else disp ( 'l.rt..i ,...::-L:i: vri:r.--it1i:r )
31 end
32

V- "n.l+,i^-&
L-* l^,Lgi,, ,tr{r*t*
J*""tr*^^rr (66"<e.
d,e'
(e c*A**
U04i<4"u
-ll
V= i--r- )

[=

lt^/L

\ --
-L-0\
f\^{M^;^$dt ( i*l;,*k)

c- 7 2 *f ' -^*-nl;t)
( wra -L
g 3
( 5
4 tr6
1 iltrf L .,rl". i i ,tti irecinii L-rrre:r Ce-l-L1l e \/or:CnOi ( r-4 l

2
3 cfear all
4 x - tir.: r, L i -t 1.,];
5 y- li, i,: : .. . i';:':',fi
6 voror o i x, y.
7 xlim([-i] l-' - 'li:r l); yltm([-,1 -,]);
8
9 x : [x (: ) y(: ) l ; tr:iiagraraa Vo:ortoi ei i:'urrcl-elc:: c]e coor:d. x,l'
l-0 iV,Cl : voronoin(x);
t-1
12 N - length(V)-r;
l-3 r : ,.;
14 for j :,i :N
15 r : r.r ,'

J-b u: L{a},'
1"'7 v: C{j};
18 for k: I:Iength(u)
L9 for I - .l : length (v)
20 if u(k)--v(l)
2L r:rr ' i
22 end
23 end
24 end
z3
26 if r--' disp (t)
27 end
28 end
29
30
7 Z Averri L'0, Pl, P2-, P3 ca irr problema 1 si P'1 : (2a, 6a), P"2 : (6a, 2a) " ( qZ
2 eo P,:.:iltr:u poliqJoanele cle cr:nf-roI P0P1P2P3 si P0P'7P'2Pj, sa se Clt=sene ze irr i"o't;L
3 % sr;bferesti:e (cu subplot) . curbele 86zier ccrespurrzal-oare si sa se c,)rnp.;f i.
4
5 clear al |;
6
7
a-l;
t:it : i; . il .1. : -1, ,.
frP'') ,?,(t, t) ,P"(0, z) ,idr,r)
R

9 x0:..-r-a i
10 y0 : i;;
11
1a AI- -: / * A
-,1 - .
r
1?
rJ ,,1_-
t-a .
I r
t4
A- A,
16 y2:,:.* a;
1,7
18 x3-1,'
1O rr?:.
J :
'r-r9| .
f

20
27 x1p i-ai
a.) ..1^-r+-.
YLV-' at
23 x2P:',:'* u'
24 y2p-.)t* a;
25
26 b0-(1-r)"^_r;
U1 l-. I --."1 * \r
/ -l L/.\ * /- \ .
\l -l t) t
2g b2:3 *t.*t.*(1_t);
29 b3:t . ^,'l ;
30
31 subplot ().,':,1)
32 x:x0*b0+x1*b1+x2*b2+x3*b3;
33 y:yo*b0+yl*bL+y2*b2+y3*b3; I
34 plot (x, y, '.r ' )
35 hold on *,'lil \la*
36
37
plot ( [x0 x1 x2 x3] , [y0 yl y2 y3))
hold on
t, *"^"
38 xlim([i], {rl ) I
39 ylim([0, ] t;; )
40
47 subplot (1 ,::. , |.)
42 x:x0*b0+x1p*b1+x2p*b2+x3*b3 t 'lO
tr
43 y:yO*bO+y1p+b1+y2p*b2+y3*b3;prot (x, y, ' , ,') Crr$-- N**
44 hodon t"*
45 plot ( [x0 xlp x2p x3], [y0 y1p y2p y3] )
I
^
|
46 hold on .l
47 xlim ( [0, i:; )
I

48 ylim([ti, {i] )
L Z Ccrs j cle_raur c,.rrba j1,-arnma: (a*cos(pi-*t)na*sin(p.*t),c*t), und.L" a s-i c si:.nt
2 00 --.utt:ita'rrt r-.:a_e (e licea circr-rlar:a). Fie punctele: P0 : )iamrna(0):(a.,0,0),
3 ? -P3 : lra.mmar(1)-(,-a ,A,C) " Fie acum P1 : P0+(1/3)u-yamma'(0):(a,anL.l,i:,c13) si
4 ? P::F i- 1 1 .i ) *yanlna ' i l; : ( -.a, a Lpi/ :, 2.;,! 31
?,

5 ? 3:, s,l r"t[,re:irrte qrafic elicea pe intervalul l-2,2).


6 e" Sa se reprezinte cur:Jra Bezler corespunzatoare poligoirulu.i de conlrol P0P1P:P3
7
I clear
o - t.
10 c-:i ;
11 h-il"iri;
1,2 t-ii : h: 1. ,'

l-3 s--L : h: h ;
t4
15 x:a*cos (pins ); I
16 y-a*sin(pt*s); I
77
l-8
L9
z-c* s;
plot3 (x,y,z) I
hold on
h J*
1'r lr'l
t
oLwo
20
2t b0=(l-t).^,:-l;
22 bl:t+u.' (,1-t).*(t-L );
23 b2:-l*t.*t"*(j_t);
aA h1-r ':.
LA UJ_L. );
25
26 x0-a;
27 yO:i:'
28 za:i);
29
30 x3:-a;
31 y3-i;
32 z3:c;
33
1A ..4-
La- -,
at
2tr ,,)-/-.!^i,
y.-\a /a.
Ptt/ t
36 z2-(1,*c) 1:;
37
?R wT:: .

39 yl: (a*pi) /,-r;


40 z7:c /': ;
47
42 x:xo*b0 rxl *b1r-x2 *b2 +x3*b3; 1

43 y-yo *b0 r-yl*bl 1y2'kb2


44
45
z-zakba+zl+bL+22*b2
plot3 (x, y, z, ',J' ) I
l;i::i; I c^/,,{," blo*
46
47
48
49
50
**:[x0 x1 x2 x3];
yy:[yO yt y2 y3);
.r:\za zl z2 z3l;
plor 3 (xx, yy , ZZ, ' . )
{,t^^ (rh

You might also like