Hi all,
is there an easy way in matlab to plot a function whose support is a
triangle ?
I just want to plot f(x,y)=2*(1-x-y)^2-(1-x-y) on (x,y) in [0,1]*[0,1-
x]
I know the trimesh function for instance, but it meshes a square, not
a triangle, with triangles
Otherwise, I know that I can use the patch function to draw whatever I
want, but I am just looking for an easy to use built-in function..
Thank you,
Pluton
|
|
0
|
|
|
|
Reply
|
plutonesque (390)
|
11/13/2008 6:16:18 PM |
|
pluton <plutonesque@gmail.com> wrote in message <90fa8900-fdb1-4215-b313-615c4e9793d6@t39g2000prh.googlegroups.com>...
> Hi all,
>
> is there an easy way in matlab to plot a function whose support is a
> triangle ?
>
> I just want to plot f(x,y)=2*(1-x-y)^2-(1-x-y) on (x,y) in [0,1]*[0,1-
> x]
>
> I know the trimesh function for instance, but it meshes a square, not
> a triangle, with triangles
> Otherwise, I know that I can use the patch function to draw whatever I
> want, but I am just looking for an easy to use built-in function..
>
> Thank you,
>
> Pluton
There are probably heaps of ways to get MATLAB to do this, one way is to construct a mesh of the triangular domain. You could use "mesh2d", available on the FEX to build an unstructured triangular mesh.
As you've noted you could then use the "trisurf/trimesh" routines.
Darren
|
|
0
|
|
|
|
Reply
|
d_engwirda.nospam (14)
|
11/13/2008 6:51:01 PM
|
|
pluton <plutonesque@gmail.com> wrote in message <90fa8900-fdb1-4215-b313-615c4e9793d6@t39g2000prh.googlegroups.com>...
> Hi all,
>
> is there an easy way in matlab to plot a function whose support is a
> triangle ?
>
> I just want to plot f(x,y)=2*(1-x-y)^2-(1-x-y) on (x,y) in [0,1]*[0,1-
> x]
>
> I know the trimesh function for instance, but it meshes a square, not
> a triangle, with triangles
> Otherwise, I know that I can use the patch function to draw whatever I
> want, but I am just looking for an easy to use built-in function..
>
I recall at least one code on the file exchange that will
triangulate a 2-d polygon. Look for mesh2d.
John
|
|
0
|
|
|
|
Reply
|
woodchips (7921)
|
11/13/2008 6:53:01 PM
|
|
"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gfht2d$ct2$1@fred.mathworks.com>...
> pluton <plutonesque@gmail.com> wrote in message <90fa8900-fdb1-4215-b313-615c4e9793d6@t39g2000prh.googlegroups.com>...
> > Hi all,
> >
> > is there an easy way in matlab to plot a function whose support is a
> > triangle ?
> >
> > I just want to plot f(x,y)=2*(1-x-y)^2-(1-x-y) on (x,y) in [0,1]*[0,1-
> > x]
> >
> > I know the trimesh function for instance, but it meshes a square, not
> > a triangle, with triangles
> > Otherwise, I know that I can use the patch function to draw whatever I
> > want, but I am just looking for an easy to use built-in function..
> >
>
> I recall at least one code on the file exchange that will
> triangulate a 2-d polygon. Look for mesh2d.
>
>> help mesh2d
mesh2d.m not found.
--
A sloppy way, if you could live with some edges in the figure:
clear all;clc;clf reset
n=20;
u=linspace(0,1,n);
v=linspace(0,1,n)/sin(pi/4);
[U,V]=meshgrid(u,v);
%map rect grid onto tri-grid by linear transform
x=U-V*cos(pi/4);
y=V*sin(pi/4);
y(x<-1/n)=NaN; %will be ignored in surf
x(x<-1/n)=NaN;
fun=2*(1-x-y).^2-(1-x-y);
figure(1), clf;surf(x,y,fun);
shading interp;lighting phong;light;axis tight
%view(2)
%plot points in triangular mesh
plot(x,y,'.');axis equal;
/Per
|
|
0
|
|
|
|
Reply
|
per.sundqvist1 (22)
|
11/13/2008 7:37:02 PM
|
|
ok, thank you all !
|
|
0
|
|
|
|
Reply
|
plutonesque (390)
|
11/13/2008 7:48:35 PM
|
|
"Per Sundqvist" <per.sundqvist@live.com> wrote in message <gfhvku$ohc$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message <gfht2d$ct2$1@fred.mathworks.com>...
> > pluton <plutonesque@gmail.com> wrote in message <90fa8900-fdb1-4215-b313-615c4e9793d6@t39g2000prh.googlegroups.com>...
> > > Hi all,
> > >
> > > is there an easy way in matlab to plot a function whose support is a
> > > triangle ?
> > >
> > > I just want to plot f(x,y)=2*(1-x-y)^2-(1-x-y) on (x,y) in [0,1]*[0,1-
> > > x]
> > >
> > > I know the trimesh function for instance, but it meshes a square, not
> > > a triangle, with triangles
> > > Otherwise, I know that I can use the patch function to draw whatever I
> > > want, but I am just looking for an easy to use built-in function..
> > >
> >
> > I recall at least one code on the file exchange that will
> > triangulate a 2-d polygon. Look for mesh2d.
> >
>
> >> help mesh2d
>
> mesh2d.m not found.
Read my lips. I said to look on the file exchange.
John
|
|
0
|
|
|
|
Reply
|
woodchips (7921)
|
11/13/2008 8:37:02 PM
|
|
|
5 Replies
47 Views
(page loaded in 0.036 seconds)
Similiar Articles: Plotting data with nonuniform mesh/grid? - comp.soft-sys.matlab ...2d unstructured mesh generation - comp.soft-sys.matlab I want to mesh 1x1 square domain using some ... of each triangle which I don't know yet" The data you ... Export COMSOL FEM mesh to MATLAB - comp.soft-sys.matlabExport COMSOL FEM mesh to MATLAB - comp.soft-sys.matlab... COMSOL mesh 1. x and y coordinates of ... to compile the triangle mesh generation ... Extracting data from a 2D ... Shading problem - comp.graphics.api.openglHello! I'm new at this group. I think I need help... I'm doing a 3D viewer of triangle meshes. I load them from an STL file. So, when I read the data ... Matlab Code for Automatic Quadrilateral Mesh generation - comp ...... http://math.mit.edu/~persson/mesh/ > > Can it handle quadrilateral mesh? It seems it can only generate triangular one. > > Bruno There is only triangle mesh, but ... How to Find Surface Normal of each triangle in a Surface. - comp ...Question: Hi!!! i have created delaunay triangles of a surface using x,y,z co ordinates. now i want to find Surface Normal of each triangle in a Su... Print triangle of star/blank inside the rectangle of char - comp ...Hello,I want to print a triangle, made of blanks or asterics inside arectangle made of alphabets.It's as follows;ABCDEFGFEDCBAABCEEF FEDCBAABCDE ... SPEED TEST: DirectX9 vs openGL - comp.graphics.api.opengl ...2) If you use DirectX's own Mesh primitive with the OptimizeMesh function, compared to all the tricks of the trade openGL suggests (using triangle strips, vertex arrrays ... tsearchn for non-convex - comp.soft-sys.matlabIs there an alternative to tsearchn that works for non-convex domains (tetrahedron mesh in 3d, triangle mesh in 2d)? I wrote my own, but it is very sl... Rendering Shafts of Light - comp.graphics.api.openglIf a sphere's radius comes next, render the sphere by, e.g., rendering a triangle mesh with the vertices P of that sphere. You should choose smooth color interpolation ... triangle wave function in C Code-S Functions - comp.soft-sys ...Dear All, I am trying to make a function to generate triangle wave in C code S-Functions. This will be used to make the carrier for PWM inverter si... Triangle mesh - Wikipedia, the free encyclopediaA Triangle mesh is a type of polygon mesh in computer graphics. It comprises a set of triangles (typically in three dimensions) that are connected by their common ... Triangle: A Two-Dimensional Quality Mesh Generator and Delaunay ...Jonathan Richard Shewchuk's Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. 7/17/2012 3:54:28 PM
|