Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Trapezoid mesh
Date: Mon, 24 Sep 2012 07:33:09 +0000 (UTC)
Organization: Universit&#228;t Erlangen-N&#252;rnberg
Lines: 23
Message-ID: <k3p2bl$on2$1@newscl01ah.mathworks.com>
References: <k3iark$dlg$1@newscl01ah.mathworks.com> <k3o2hk$cc5$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1348471989 25314 172.30.248.47 (24 Sep 2012 07:33:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 24 Sep 2012 07:33:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2391882
Xref: news.mathworks.com comp.soft-sys.matlab:779081

Thank you so much- that worked perfectly!

"Roger Stafford" wrote in message <k3o2hk$cc5$1@newscl01ah.mathworks.com>...
> "Ali" wrote in message <k3iark$dlg$1@newscl01ah.mathworks.com>...
> > I have a trapezoid in 3D with the following vertices:
> > vertices =  [110 110 -350;...
> >               -110 110 -350;...
> >               30 45 -150;...
> >               -30 45 -150];
> > 
> > How can I generate a mesh, this means three 2D matrices  xd, yd and zd for my trapezoid. These matrices should be suitable for the functions surf and mesh!
> - - - - - - -
>   Let 'v' be short for 'vertices'.  To make an n x n mesh:
> 
>  [S,T] = ndgrid(linspace(0,1,n));
>  G00 = (1-S).*(1-T); G10 = S.*(1-T); G01 = (1-S).*T; G11 = S.*T;
>  xd = v(1,1)*G00+v(2,1)*G10+v(3,1)*G01+v(4,1)*G11;
>  yd = v(1,2)*G00+v(2,2)*G10+v(3,2)*G01+v(4,2)*G11;
>  zd = v(1,3)*G00+v(2,3)*G10+v(3,3)*G01+v(4,3)*G11;
> 
>   (This should work for any convex planar quadrilateral provided the vertices are ordered so that v(1,:) and v(4,:) are at opposite ends of a diagonal.)
> 
> Roger Stafford