Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Trapezoid mesh

Subject: Trapezoid mesh

From: Ali

Date: 21 Sep, 2012 18:15:16

Message: 1 of 5

Hello,

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!

I appreciate any Help!
Thank You!

Ali

Subject: Trapezoid mesh

From: Ali

Date: 22 Sep, 2012 09:37:08

Message: 2 of 5

"Ali" wrote in message <k3iark$dlg$1@newscl01ah.mathworks.com>...
> Hello,
>
> 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!
>
> I appreciate any Help!
> Thank You!
>
> Ali

Subject: I Need Help to Trapezoid mesh

From: Ali

Date: 22 Sep, 2012 16:20:11

Message: 3 of 5

"Ali" wrote in message <k3iark$dlg$1@newscl01ah.mathworks.com>...
> Hello,
>
> 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!
>
> I appreciate any Help!
> Thank You!
>
> Ali

Subject: Trapezoid mesh

From: Roger Stafford

Date: 23 Sep, 2012 22:30:12

Message: 4 of 5

"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

Subject: Trapezoid mesh

From: Ali

Date: 24 Sep, 2012 07:33:09

Message: 5 of 5

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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us